Transparent objects and depth writes

Hi,

is there a way to actually write to the dephbuffer with transparent objects? I know that I can use material.forceDepthWrite = true but if I visualize the depthbuffer I see that it did not get updated.

Hey you should be able to get it with material.needDepthPrePass = true

1 Like

Ok, this kind of seems to work. I only realized now that the custom renderingGroupId has an impact on this as well. I created a PG to show the effect: https://www.babylonjs-playground.com/#JY6FFW#17

I think the code is self explanatory - everything works as expected unless one uses custom renderingGroupIDs. Any ideas what I’m doing wrong?

I’m an idiot :grinning_face_with_smiling_eyes: I’ve set the renderingGroupID on the wrong object :grinning:

1 Like

I thought everything is working correctly. When I updated my actual code it again didn’t work. So I continued debugging and realized that the initialization sequence has an influence if custom renderingGroupIDs are used. I outlined the problem here: https://www.babylonjs-playground.com/#JY6FFW#20

I just realized that my sorting function was incorrect - in order to access the metadata I had to change it to:
const sortfunc = (a, b) => (a._mesh.metadata < b._mesh.metadata ? -1 : a._mesh.metadata > b._mesh.metadata ? 1 : 0);

Now everything works as expected - sry for the confusion!

1 Like

I totally prefer that honestly :smiley: