Fixing Z render order

This video should be self-explanatory.

Basically the Z order is wrong for translucent entities inside the interior prop is wrong and I’m hoping it’s possible to fix with lua, or a VMT command (wasn’t sure if I should post this in lua or modelling).

Quick necro:
I was having the same problems, if the entity is closer to the viewport origin it will render on top of other entities despite overlapping in some parts.
I managed to fix it with this inside of the ENT:Draw (In my case, ENT:DrawTranslucent):

 render.OverrideDepthEnable(true, true)
 self:DrawModel()
 render.OverrideDepthEnable(false)

I am putting this out in case people are having the same problem as I did.

Keywords to make the search easier

Gmod
Z Depth
Render Order
Drawing Order
Double Pass
Rendering on top
Drawing on top

3 Likes

Thanks mate, this may actually still be useful to me!

1 Like