Godot Version
Godot 4.5
Question
Hey all! I have a terrain mesh that I have generated. It is a hexagonal grid. In the shader for the terrain I also have it draw the grid "outline" so we can see the outline of every hex. That is all working great - no issues.
Now, when navigating with a mouse, I have a Sprite3D node that I draw on top of the terrain mesh which essentially is meant to convey to the user which hex the mouse is currently hovering over.
It looks something like this:
Please note the black hexagon in the center is the Sprite3D that conveys to the user which hex the mouse is currently hovering over. The other hex outlines you see are done in shader code for the terrain mesh.
Now, I am having an issue with the Sprite3D and whether it gets drawn on top or not. I have tried several things such as changing the rendering order, enabling/disabling depth test, etc. But nothing I have tried gets it to be 100% how I want it. Here are some examples:
(1) With depth testing enabled, I get the following (bad) result:
(2) With depth testing disabled, I get the following (good) result:
(3) On the other hand, with depth testing enabled, I get the following (partially good) result:
(4) And when depth testing is disabled, I get the following (bad) result:
(5) Finally, you may ask “why not just do this in the shader and partially re-use the shader code that I am using to draw the hex grid on the terrain?” My reason for that is because I don’t want this “overlay” to match that hex grid 100% of the time. Here is a (good) example of when the hex overlay should NOT match the hex grid done in the shader:
(This is how I want it because I want the “mouse-over hex” overlay to be displayed on top of the hex terrain instead of being rendered with it).
I would appreciate any suggestions as to how to get this overlay to render how I would like it in each of these scenarios!
Thanks!





