Hi all! New to 3JS and trying to see if a certain rendering trick is possible. i have two objects in 3d scene. object 1 is in front of object 2. I have a seperate object, object 3, that i want to use as an invisible occluder geo for object 1, but i DONT want it to affect object 2. Is that possible? Every trick i've tried so far with rendering order/layers and such never works, the occluder affects both objects in the scene.
If it helps, the specific example is this, I have a a-frame scene with face tracking courtesy of 8th wall. I have a pair of sunglasses tracked to my face, and another face geo that deforms with my face through face tracking. I have a full face size tatoo overlaid on top of my face on the face mesh. While the occluder works good for hiding the sunglass handles/ear rest (and the face tatoo if i rotate my head), it keeps colliding with the mesh containing the tatoo texture face as it deforms, creating clipping issues.
#Occluding one object with geometry but not others...
9 messages · Page 1 of 1 (latest)
You’d use the Stencil Buffer for this. You’d have object 3 write a certain ref in the stencil buffer an have object 2 read from the stencil buffer
Note transparent materials are always sorted after non-transparent ones so if you manually set renderOrder you might need to also make all materials transparent. Safari web inspector has canvas debugging which lets you replay the render calls to verify the actual render order.
@gusty ore would the stencil buffer replace the render layers then in this case?
@craggy ore when you say make the materials transperent, you mean give them the option to use transparency, but keep the opacity at 100%?
Yes, but you’d need to set Mesh.render order to make sure object 2 renders first then, the others
Yup, its opaque objects sorted by render order followed by "transparent" objects sorted by render order. If you were wondering why it seemed the tattoo mesh always seemed to be rendering last, that might be the explanation
Thanks so much for your help y'all!
Keep in mind, even with render order set, transparent and non transparent materials are sorted separately. So make sure everything is one or the other