question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

glTF 2.0 models dark on Android of Qualcomm platform

See original GitHub issue

Hi, Recently I used cesium to work on the mobile side. I found that my 3dtile model will become very dark on the Android platform. I found similar problems in issues. #6622 and #7403 ,But it seems that I have not found a solution. I have done a lot of testing on this problem and found that the problem comes from the value of ellipsoid.radii.x in processPbrMaterials.js, but I found this to be a fixed value of 6378137.0 in the czm_getWgs84EllipsoidEC method. But I replaced ellipsoid.radii.x with a specific value, and the program works fine on mobile devices, so I don’t think this is a problem caused by float precision. I found some relevant information here, struct will have problems when initializing on Android devices, https://github.com/KhronosGroup/WebGL/issues/1302.

I tried to make the following modifications,Can display my model correctly on my phone。 I am not sure that this modification is the best. If there is a better way, please let me know, I am willing to continue working for it and contribute my code. image image

1552634222682

I wrote a test code that will display a green square on the pc, but will display a red square on Android, the phone processor is Snapdragon 845, the browser is chrome, Both tests failed on Xiaomi and Samsung phones… But I tested it on Huawei phones. pc: image xiaomi: image

this is my test code:

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Struct constructor/initializers highp bug.</title> </head> <body> <canvas id="canvas" width="256" height="256"> </canvas> <script type="application/javascript"> "use strict"; var canvas = document.getElementById('canvas'); var gl = canvas.getContext('webgl'); gl.viewport(0, 0, canvas.width, canvas.height); gl.clearColor(0, 0, 1, 1); gl.clear(gl.COLOR_BUFFER_BIT);
    var vs = gl.createShader(gl.VERTEX_SHADER);
    var vs_code =`
        attribute vec4 pos;
        void main(){
            gl_Position = pos;
        }
    `;
    gl.shaderSource(vs, vs_code);
    gl.compileShader(vs);

    var fs = gl.createShader(gl.FRAGMENT_SHADER);
    var fs_code =`
        precision highp float;
        struct Test {
             vec3 color;
         };
         void main() {
             vec3 color = vec3( 6378137.0, 0.0, 0.0 );
             Test test;
             test.color = color;
             if (test.color.x == 6000000.0) {
                gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
             } else {
                gl_FragColor = vec4( 0.0, 1.0, 0.0, 1.0 );
             }
         }
    `;
    gl.shaderSource(fs, fs_code);
    gl.compileShader(fs);

    var prg = gl.createProgram();
    gl.attachShader(prg, vs);
    gl.attachShader(prg, fs);
    gl.linkProgram(prg);
    gl.useProgram(prg);

    var posLocation = gl.getAttribLocation(prg, 'pos');
    gl.enableVertexAttribArray(posLocation);

    var vertex = new Float32Array([
        -0.8, -0.8, 0,
        -0.8, 0.8, 0,
        0.8, 0.8, 0,
        0.8, -0.8, 0
    ]);

    var index = new Uint8Array([0, 2, 1, 0, 3, 2]);

    var vertexBuffer = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer);
    gl.bufferData(gl.ARRAY_BUFFER, vertex, gl.STATIC_DRAW);
    gl.vertexAttribPointer(posLocation, 3, gl.FLOAT, false, 0, 0);

    var indexBuffer = gl.createBuffer();
    gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
    gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, index, gl.STATIC_DRAW);
    gl.drawElements(gl.TRIANGLES, index.length, gl.UNSIGNED_BYTE, 0);
</script> </body> </html>

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:20 (19 by maintainers)

github_iconTop GitHub Comments

1reaction
OmarShehatacommented, Jun 27, 2019

Yeah the PR referenced above does solve this issue, I’m just reviewing for code style and tests now, I expect it to be merged end of this week/weekend.

0reactions
cesium-conciergecommented, Jun 28, 2019

Congratulations on closing the issue! I found these Cesium forum links in the comments above:

https://groups.google.com/d/msg/cesium-dev/qYjFtc3Ktg8/cjc_JId9BwAJ

If this issue affects any of these threads, please post a comment like the following:

The issue at https://github.com/AnalyticalGraphicsInc/cesium/issues/7651 has just been closed and may resolve your issue. Look for the change in the next stable release of Cesium or get it now in the master branch on GitHub https://github.com/AnalyticalGraphicsInc/cesium.

Read more comments on GitHub >

github_iconTop Results From Across the Web

gltf 2.0 model show dark side in android device
Now I want to move the application to my android device (Samsung S8). But the model looks dark on the other side of...
Read more >
Using the Android Configuration Rules System in Unreal Engine
The Android Configuration Rules system gives Android developers using Unreal Engine control over determining if a particular Android-based device has the ...
Read more >
glTF RUNTIME 3D ASSET DELIVERY - Khronos Group
glTF (GL Transmission Format) is a royalty-free specification for the efficient transmission and loading of 3D scenes and models by engines and applications ......
Read more >
New in: Explore Wikitude SDK 9.3
Download Wikitude SDK 9.3 to update your platform free of charge. ... This means you can use glTF 2.0 files, CAD models, and...
Read more >
glTF, GLB, and USDZ - Sketchfab Help Center
Point Clouds are not available in USDZ. · Quick Look does not have a Shadeless mode, so 3D scans and other models set...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found