Imported mesh not working with disableColorWrite

I have tried numerous meshes locally, including a simple cube, but imported meshes do not seem to respect the disableColorWrite material or onBeforeRenderObservable/After for masking another mesh.

I have a playground here:
https://playground.babylonjs.com/#Z3GIKS

Uncomment lines 52&52 or 56&57 to attempt masking with imported mesh.

try with gltf/glb/babylon file format not .stl , .stl doesn’t support many things.

Yes have already tried all formats and methods of importing - updated playground for glb:
https://playground.babylonjs.com/#Z3GIKS#3

You don’t have light in your scene https://playground.babylonjs.com/#Z3GIKS#4

it still has the same issue - if you uncomment lines 52&53 the barrel still does not mask the sphere. trying to get the imported mesh to mask the sphere in the same manner that the wall mesh created in babylon is doing.

you mean like this? https://playground.babylonjs.com/#Z3GIKS#6

I just rendered sphere after rending your model

2 Likes

nice that’s it! so it’s just the order - thanks for yr help on this:)

2 Likes

It is possible change the order of mesh dynamically ?
In my project, the mask mesh may created after other meshes.
And I need to mask those meshes that created after the mask mesh.

you can do it with renderingGroupId and using scene.setRenderingAutoClearDepthStencil to prevent the subsequent group to clear when needed.

1 Like

Thanks to your reply. I’ll try this.