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:

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:

You don’t have light in your scene

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?

I just rendered sphere after rending your model


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


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.