Faces missing on semi transparent objects at certain angles

I have lego blocks. Most of them are opaque, but some are semi transparent.

For some reason, the semi transparent blocks have missing faces. I have checked the normals on the faces and they are all facing outwards. Models are imported .glb files created in Blender 2.8.

Missing faces

Here are the two materials:

Opaque (all faces visible and works fine):

THREE.MeshStandardMaterial({color: 0xffffff, roughness: .7})

Semi-transparent (some faces missing):

THREE.MeshStandardMaterial({color: 0xffffff, roughness: .7, transparent: true, opacity: .7}))

I’ve tried MeshLambertMaterial and MeshPhongMaterial material types and that makes no difference.

It is the same for all the different shape lego pieces.

The angle of view seems to make a difference. See here with the scene rotated 45 degrees. You can see that the faces nearest us (pointed to with arrow) are now visible:

Missing faces2

Any idea how I solve this please? Thank you!

check your camera near and far values. unreasonably large range like 1-100000 when your scene is in 10-20 can create similar bugs.

Thank you very much. I did have quite a wide range for the near and far values. So I just changed that as recommended and unfortunately it hasn’t solved the issue. I’ve calculated (by watching the objects getting clipped) that the optimal near and far values are 50 and 80 which clips just in front of the scene and just behind it.

Even if I clip more tightly the issue remains:

Camera setting is:

this.camera = new THREE.PerspectiveCamera(12, 1000 / 750, 50, 80);

The FOV is intentionally very small by the way because I need the “nobbins” of the blocks to overlap, but don’t want an ortho camera. Might that be the cause?

Thank you :slight_smile:

It’s in general recommended to set Material.depthWrite to false whenever you set Material.transparent to true. This already happens for all transparent glTF assets you load via THREE.GLTFLoader.

Thank you for your response. I have just tried this and unfortunately that’s not helping either. The transparent material is now:

THREE.MeshStandardMaterial({color: 0xffffff, roughness: .7, transparent: true, opacity: .7, depthWrite: false})

Still looks the same:

Missing faces4

I’ll leave this setting in place though as it’s recommended. Thank you :slight_smile:

holy crap, who came up with that :open_mouth: this is seriously inobvious behavior

Well, it’s not a solution for all cases but in general recommended. Anyway, depth sorting issues are somewhat an unsolved problem right now and possible workarounds use case sensitive. TBH, I don’t know how to solve this for you Lego block.

OK. Thanks for looking at it anyway. Much appreciated.

Doug, did you ever find the reason? I am curious

No I’m afraid I didn’t. I’m just going to live with it. It seems to be related in some way to being a transparent material at certain camera angles, but beyond that I’m stumped.

Drop the jsfiddle link then. Or maybe scene.toJSON() output.

Thank you that’s very kind of you. Unfortunately is in a deeply complicated Angular implementation so extacting that would be pretty hard. If you want to have a play with the live thing though you can do so here: https://oodlu.org/share-app/blocs

Lol, what do you expect me to do with this:
Screen Shot 2020-04-16 at 14.45.22

I am not on that level :slight_smile:

1 Like

Yeah, you wouldn’t be able to do anything with that as it’s compiled bundles. I just thought you might be interested to see the app. I’m not too worried about solving this so worry not. I appreciate your offer though, thank you :slight_smile:

Could this be the reason, you can set :mesh.frustumCulled = false

Apologies for the delay, I’ve been up to my eyeballs. Thank you for this. I just tried it and unfortunately it didn’t help. I appreciate the suggestion though.

I have just run into this issue, it happens when I set my blender materials to alpha hashed and move the camera to certain angles.
Are there any new developments on this?
Did you manage to fix it?