Interactive grass shader with a currently too obvious lod system. Made in godot 4.0 beta 9

#madewithgodot #GodotEngine #godot

@darias How did you place the grass blades? When you go far away, do the blades actually go away or are they just hidden?
@troido The floor is divided in tiles of 25*25m. The blades are a multimeshinstance of triangles randomly generated to fill each area. When the grass is far away a low density multimeshinstance is shown and the high density hidden. Eventually if the tile is too away no multimesh instance is shown at all for that tile
@darias Thanks! How do you set the random location of the triangle? is that from a CPU script? or is there a way to distinguish the instances in shaders? How many blades of grass can you place without impacting performance?
I'm trying to do something similar (but using particles instead of a multimesh), but if I'm getting a dense grassy field then performance seems to be suffering (and sometimes the grass is flashing over the whole screen)
@troido Random location is generated in the godot editor itself, its a special menu for multimesh instance to fill another mesh. I think the particle approach should be better, but i need to investigate further. Multimeshinstance paints all blades in each tile with a single drawcall so its not so horrible performance wise. Also there's the primitive lod system and I discard some fragments depending of distance. Do you want me to send you a minimal project so you can test it by yourself?
@darias Playing around with it would be useful. I'd like to learn and compare techniques. My own projects is https://github.com/jmdejong/s6 by the way
GitHub - jmdejong/s6: experimental 3d open world stuff

experimental 3d open world stuff. Contribute to jmdejong/s6 development by creating an account on GitHub.

GitHub
@troido Hello again! I made a quick and dirty extraction of the shader from my game, so expect some garbage there haha https://drive.google.com/file/d/1Jiuw0LW9Y7j80dry_FLvZ1Ji7y0h1nBY/view?usp=sharing
@darias Thanks. I don't have a drive account so I can't see it yet though.
by the way, I tweaked some things with my grass and performance is much better now. I think the most important tweaks were using `alpha scissor` instead of `alpha` and setting the draw order back to `index`
@troido Damn! I thought i made the link downloadable for anyone :(. Let me be in the oc again and i will share you this by another method. Yeah, regular alpha forces a sorted render pass for every node that uses it while alpha scissor just discards fragments and its done in the regular pass.
@troido I changed the permissions and I think you should be able to download it now without an account
@darias Thank you! I'm trying it out