[SOLVED] Material shader for setting depth testing on individual points?

Hey fellow developers.

I started making a Model-Viewer and decided to program a “Model-Cutter” which slices the model in the respective X-Y-Z axes. I have used a material shader using the opacity shader chunk alongside the models bounding box to create this effect. Basically I just figure out the X / Y / Z Min and Max positions and then in the shader check if the point is inside or outside the range. If it is, Alpha is set to 1, if not, it is set to 0 creating this “Model Cutting” Effect.


In the gif you can also see the reason for this thread. When I cut along an axis (in the Video its the X-axis), the depth for the “hidden” points is still there and occludes the view through the model.

Is there any material shader I could use to also disable the depth rendering of the hidden points?

Thank you very much!

At the moment you change alpha value based on alpha - which makes a pixel transparent, but still there … so it writes to depth buffer.

You need to discard the pixel completely, to avoid writing to depth buffer. So when you evaluate the alpha, add something like this:

if (Alpha < 0.01)

Perfect thank you! Exactly what I was looking for :slight_smile: