Inevitable alpha issues

My scene consists of a head GLTF model with a skin texture and an alpha texture used to hide pieces of the head geometry. There is a separate GLTF model for the hair.

Without the alpha texture in place, things appear to work as expected.

With the alpha texture in place on the head, the hair shows and hides depending on the angle it is being viewed.

I wasn’t able to get permission to share a Fiddle with the code/assets so I made a video…
I’ve tried combinations of depthTest, depthWrite, alphaTest etc. on the alpha map material without any success.

Can anyone suggest something else to try?

Once again, proving the most effective way to find an answer yourself is to ask for help here and wait a few seconds…

I discovered object.renderOrder and it appears to have helped a lot - still not 100% correct but progress!

2 Likes

Definitely renderOrder is good for these kinds of things, also make sure the hair material is marked as .transparent and the body materials are not. that will make the hair be in the second sorting pass for transparent stuff.

Also worth experimenting with is trying .frustumCulled = false and see if it affects anything.
Sometimes skinned meshes have ill defined boundingboxes which can make frustum culling unreliable… if it does affect things, you know you may have to adjust bounding boxes.
Another thing to check/experiment with on the hair:
.alphaTest = .5 or similar value. that can help prevent transparent stuff from clipping other geometry.

Thank you (again) @ manthrax - lots to try there.

Using renderOrder worked in my standalone test but not in the app so there is something else I need to account for.

make sure the hair material is marked as .transparent and the body materials are not

Sadly, I need to apply an alpha to the head mesh part of the model to mask out part of it - the hair has several layers of transparency too.

A better solution might be to make the piece I have to mask out, a separate mesh and only adding it to the scene if required. Adding that head alpha seems to be the root cause of the problem.

Cheers.

1 Like