Skip to content

Object is black on some Android devices #679

Closed

Description

@AytoMaximo

Description

The relevant THREE github issue on this case: mrdoob/three.js#14137. It was opened more than year ago and there is still no solution. Model-view player based on the same THREE.js library, but it does not work on a lot of popular devices. For example, many Xiaomi phones (even flagman ones) can't work with it. Tested on Redmi 4A (Adreno 308), Mi A1 (Adreno 506), Mi6 (Adreno 540). More devices with black textures issue can be found by the link above.

Errors in the console:

  • WEBGL_depth-texture extension not supported
  • OES_texture_float_linear extension not supported
  • EXT_shader_texture_lod extension not supported.

Screenshot of our own test , but can also be produced on the main page with astronaut.
ShooterScreenshot-22-18-07-19

Browser Affected

  • Chrome
  • Firefox

I guess all available for Android platform browsers are affected.

OS

  • Android

Additional information

  1. The problem is in MeshStandartMaterial (https://threejs.org/docs/#api/en/materials/MeshStandardMaterial). We use difuse, normal, metallic and roughness maps with this shader and get black texture problem in our own project with THREE.js too. I think the astronaut in model-viewer inherits the same issue.
  2. From the documenation about MeshStandartMaterial we can get that it's about "physically based rendering (PBR) has recently become the standard in many 3D applications, such as Unity, Unreal and 3D Studio Max.". Ok, I'm Unity developer, so let's do the test.
  • Open Unity 2019.1
  • Create project with LightWeightPipeline
  • Choose shader for material object similiar to THREE's MeshStandartMaterial. I'll attach the screenshots from Unity and THREE editor. Shaders parametres are very similiar.
  • Make a build
  • That's it, rendering is fine!

Unity-PBR-LWP
THREE-Editor-PBR

So, I supppose the phones are OK with PBR and can handle diffuse/normal/metallic/rougness shader. THREE's developers think that there is nothing they can do.

I hope google engineers can handle this issue together with THREE developers, because Web AR really depends on it.

Activity

  1. cdata commented on Jul 30, 2019

    @cdata
    Contributor

    @AytoMaximo thanks for reporting. I only glanced at the upstream Three.js issue, but it sounds like they decided that this is a WebGL / vendor-specific issue?

    Are you seeing this problem on all devices, or on a specific Android device?

  2. AytoMaximo commented on Jul 31, 2019

    @AytoMaximo
    Author

    @cdata I've tested on Xiaomi devices, all of them have this issue.

    • Redmi 4A (Adreno 308)
    • Mi A1 (Adreno 506)
    • Mi6 (Adreno 540).

    Also, you can get a big list of devices from the mrdoob/three.js#14137 thread:

    • LG Aristo (LG-M210) (by me)
    • LG Fiesta (LG L63BL) (by me)
    • Motorolla Moto G3
    • Samsung Galaxy J3 Mission (SM-J327VPP)
    • Huaweï MediaPad T3 10 (AGS-L09) - Androïd 7 / EMUI 5.1 / Snapdragon 425 / 2Go RAM / 800x1280
    • Samsung SM-T555 (Galaxy A)
    • Acer Predator 8 (GT-810 rolex), Android 7.1
    • LG K20 Plus (lv517), Android 7.0
    • Galaxy Tab A 9.7 (gt510wifi), Android 7.1
    • Moto G4 Play (harpia), Android 7.1
    • Galaxy Tab E 9.6 (gtelwifiue), Android 7.1
    • Galaxy J5(2016) (j5xnlte), Android 7.1
    • Galaxy Tab A 9.7 (gt510wifi), Android 7.1
    • HM NOTE 1LTETD (dior), Android 4.4](#12679 (comment))

    They can't decide that it is a WebGL issue 'cas from the first post we see the following:
    "This doesn't appear to be a problem with all WebGL texturing, though -- https://fltr.world/ (simple texture demo implemented with three.js shaders) works fine, as does https://webglsamples.org/aquarium/aquarium.html "(c).

    The first link is unreachable, however the aquarium is really fine.

    Also, that's why it is not vendor-specific issue, because aquarium is fine, and my example with Unity is fine.

    I also posted the same issue on Chromium bug tracker, they asked me produce a minimal test case that shows that there is a problem with handling of a valid shader on this phone. And suggested these links: https://github.com/KhronosGroup/WebGL , in particular the tests under https://github.com/KhronosGroup/WebGL/tree/master/sdk/tests/conformance/glsl/misc , can be used as a template.

    But I'm not shader developer and don't understand what is going on there :(

    It seems like guys really need some help, because they struggle this issue for a year or longer with no results. Moreover, I think the list of devices is very big and it's not over yet, so developing Google AR view with THREE.js library inherits a serious bug.

  3. paluh commented on Aug 20, 2019

    @paluh

    I was able to "fix" rendering on my "Moto G4" by passing precision: 'lowp' here: https://github.com/GoogleWebComponents/model-viewer/blob/6eb788f5417ca34155c282199cb92f63cae3507a/src/three-components/Renderer.ts#L75

    This is suggested as a workaround in this thread:

    mrdoob/three.js#14137

    Of course hardcoding this value doesn't seem like a good solution to the problem.

  4. paluh commented on Aug 20, 2019

    @paluh

    I'm not sure if my previous post adds any value to the discussion as @AytoMaximo is aware of this workaround as an active participant of the pointed (in my comment) threejs issue thread. @AytoMaximo should I delete the above workaround suggestion?

  5. elalish commented on Aug 26, 2019

    @elalish
    Contributor

    Would you be so kind as to upgrade to our just released 0.6 version and repro? We did a bunch of work in this release to address device-specific rendering issues and I'm hoping this is solved, but I don't have access to enough test devices here to be certain.

  6. AytoMaximo commented on Sep 3, 2019

    @AytoMaximo
    Author

    @elalish, sorry for the late answer, had plenty of work to do :)
    Unfortunately, now it's black everywhere. On my Windows PC (Chrome) and iOS device too. The same test link: https://image.faradise.ru/arcore.html
    Did we mess up something after the update? We turned on automatic updates for this mini-project.
    image

  7. added this to the milestone on Sep 3, 2019
  8. cdata commented on Sep 3, 2019

    @cdata
    Contributor

    @AytoMaximo We have a similar report in #736

    @elalish I'm tentatively creating a v0.6.1 milestone in case we discover a rendering regression

  9. AytoMaximo commented on Sep 3, 2019

    @AytoMaximo
    Author

    @cdata I've noticed a very funny thing: my Xiaomi Redmi 4A is not showing model in the scene anymore (before it was just black). The situation is the same in our test project and in model-viewer.glitch.me

    image

  10. elalish commented on Sep 4, 2019

    @elalish
    Contributor

    @AytoMaximo Thanks for the info! I've looked at your model and I think I know why it's black: It has an entirely black AO (ambient occlusion) map:
    image
    I also noticed something strange with the shadow when I turned that on:
    image
    This leads me to believe something else is not quite right with this model - maybe triangle orientation? How was this model created?

    One final question, @donmccurdy this model renders fine in your viewer, which makes me think one or the other of us has a bug. Are we somehow being more strict with our glTF parsing?

  11. donmccurdy commented on Sep 4, 2019

    @donmccurdy
    Contributor

    Is there a link to the model?

    My viewer applies some direct light, which isn't affected by AO. If model-viewer is only using indirect lights, that (combined with a black AO map) may be why it's dark.

  12. elalish commented on Sep 4, 2019

    @elalish
    Contributor

    Ah yes, that explains it! I used the test model link three posts up; you can pull the model out of that.

  13. 12 remaining items

  14. elalish commented on Sep 4, 2019

    @elalish
    Contributor

    Thanks for the detailed analysis! Three.js does not apply AO to direct lighting, since this is a more basic lighting type. It is (and always has been) applied to environmental lighting, but you may not have noticed the difference since the render was dominated by the point lights. We recently removed the directional light from <model-viewer>, so all light is now environmental, which gives us a more consistent render because the two lighting types use different approximations. In fact the directional light was hiding a number of our own errors in environmental lighting which have since been corrected. In this case it was also hiding an AO error in the model.

  15. elalish commented on Sep 4, 2019

    @elalish
    Contributor

    As for brightness, please take a look at our exposure attribute, which provides the easiest way to adjust this.

  16. AytoMaximo commented on Sep 4, 2019

    @AytoMaximo
    Author

    So, I guess we need to find proper shade of gray color for AO map to make the model look not too bright :)

    UPD: just noticed your comment about exposure - we’ll take a look, thank you!

    Seems like old devices the only painful thing that remains...

  17. donmccurdy commented on Sep 4, 2019

    @donmccurdy
    Contributor

    Yeah I wouldn't recommend using AO as a method of controlling overall brightness – if it's going to be a uniform color, you may as well omit AO entirely or use solid white. Anything else is taking you off a physically-plausible rendering path — nothing ever really gets zero indirect light — and lighting adjustments from there on out will likely be hacks.

    Environmental lighting is higher quality than punctual/analytical lighting like directional lights. Changing the IBL or changing exposure should be enough to get realistic results. One could debate whether AO should affect IBL, but that's a thorny question and not the source of the problem here. :)

  18. AytoMaximo commented on Sep 5, 2019

    @AytoMaximo
    Author

    I also noticed something strange with the shadow when I turned that on:

    I guess the wrong scale causes broken shadows. I've found out the chair was exported with some errors, so it's x100 large. Maybe it's need to be handled in model-viewer in some way, maybe not - just sharing the info :)

    image

  19. elalish commented on Sep 5, 2019

    @elalish
    Contributor

    Thanks, that's very helpful! I was just cleaning up the shadow code, so I'll be sure to check that it works properly even at 100x scale in 0.7.

  20. AytoMaximo commented on Sep 5, 2019

    @AytoMaximo
    Author

    Thanks, that's very helpful! I was just cleaning up the shadow code, so I'll be sure to check that it works properly even at 100x scale in 0.7.

    Sounds great! We have some problems with the scale while converting models to GLB. So, if model-viewer can handle such cases, it will be very helpful))

  21. elalish commented on Sep 5, 2019

    @elalish
    Contributor

    I plan to, but keep in mind, you definitely need proper scale for AR.

  22. AytoMaximo commented on Sep 5, 2019

    @AytoMaximo
    Author

    I plan to, but keep in mind, you definitely need proper scale for AR.

    Yes, sure)

  23. modified the milestones: , v0.7.0 on Sep 6, 2019
  24. self-assigned this
    on Sep 9, 2019
  25. Deankovitch commented on Oct 21, 2020

    @Deankovitch

    I'm getting this "black faces error" also on pure Three JS project.
    In my project, the model is partially black. I'm using FBX exported from Maya.
    After checking everything from faces normals, to texture colors and UV smooth values, I decided to make a test recreating the material directly in Three JS. To my surprise, everything starts to render properly.
    So, for those are facing this black faces issue in ThreeJS project, here's a workaround

    FBXloader.load( 'model.fbx', function ( object ) { 
    object.traverse( function ( child ) {
    			if ( child.isMesh ) {
                	var newMat = new THREE.MeshStandardMaterial({
                		map: child.material.map,
                		metalnessMap: child.material.metalnessMap,
                		roughnessMap: child.material.roughnessMap,
                		normalMap: child.material.normalMap,
                		aoMap: child.material.aoMap,
                	});
                	child.material = newMat;
                }
            });
    });

    Unfortunately for the model viewer there isn't a workaround since it is some kind of a black box around the base Three JS

  26. elalish commented on Oct 21, 2020

    @elalish
    Contributor

    @Deankovitch What did you use to convert the FBX to glTF? That's what you'll want for model-viewer, and if it's generating black faces, please file a bug on that glTF exporter. Also make sure to check it with the Khronos glTF validator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions