TokisanGames / Terrain3D

A high performance, editable terrain system for Godot 4.
MIT License
2.09k stars 120 forks source link

Draw region grid in shader instead of gizmos #100

Open TokisanGames opened 1 year ago

TokisanGames commented 1 year ago

Todo


Using the editor gizmos for regions is a bit ugly and doesn't occlude. This would look so much better if drawn directly on the terrain, which will traverse the heights and occlude when close. We could even inject that code into custom shaders when inside the editor.

image

A preview of shader based region grid is in the grid debug view shader. It nicely occludes and stays the same size regardless of distance. Just needs mouse position and highlight color and the region gizmo can be dispensed with.

image

However, we can't draw on the terrain where no terrain exists. So I'm not sure what to do about the grid for empty regions. Perhaps we do a hybrid and use gizmos for empty slots.

TokisanGames commented 6 days ago

The region_grid is still a debug shader, but the setting is now exposed in the main inspector under Regions. I've updated the Op with remaining steps.

Xtarsia commented 4 hours ago

since we are tracking the mouse pos (only compatibility for now), it would be reasonable to render the currently hovered region even when BG mode is none, but just checking if the region the mouse is in == current region for this vertex.