Help needed to understand NodeMaterial dissolve effect not working properly with cylinders

Hi everyone!

I have a question regarding to a node material I copied and slightly edited, that doesn’t quite work with cylinder type 3d models. I’m trying to create a dissolve effect that I can easily swap to my imported glb models (that’s why there is a PBR node), but with cylinderish objects it kind of fails, as seen in the image below. I’d like to understand why this happens, since I’m kind of a noob when it comes to shaders :grin:

cylender

The NME in question is here: Babylon.js Node Material Editor

The problem is that the alpha input of the FragmentOutput block is connected, so the system considers the mesh to be transparent. In that case, the mesh does not write to the zbuffer and only depth sorting is used before drawing the meshes.

Here there’s a single mesh and the faces (triangles) are drawn in the order they were created. That’s why depending on the camera position some triangles are drawn after some others and overwrite them whereas they would not in a non-transparent case.

You can either check the “Render with depth pre-pass” toggle in the preview window (this icon
image) or (better) don’t connect something to the alpha input of the FragmentOutput block and use a Discard block instead:

4 Likes

Thank you so much for the explanation! It works like a charm now :star_struck:

Also have to say that I really enjoy the workflow with NME after I’ve gotten into it. Super handy to work with the json files that can be thrown back to the editor and loaded in the code.

2 Likes