Unity CG Shaders: Grass painting
Sometime ago I've posted an article about a geometry grass shader I came up with to simulate that toon grass look you can find in games like Zelda Breath of the wild or in Studio Ghibli movies.
So I thought that it would be cool to expand that shader so that I could paint grass on surfaces to make it look more dynamic and real.
The solution for this is quite simple! I put up a simple system to paint on a RenderTexture then I use this RenderTexture inside my grass shader.
The grass shader sample the pixels of the RenderTexture, white pixels means generate grass while black pixels means don't.
That way I can add and then delete tufts of grass wherever I like.
It's still in early development, I'm planning to add brush size/opacity gizmo and to vary the grass blades height based on the color of the pixels on the RenderTexture.
So I thought that it would be cool to expand that shader so that I could paint grass on surfaces to make it look more dynamic and real.
The solution for this is quite simple! I put up a simple system to paint on a RenderTexture then I use this RenderTexture inside my grass shader.
The grass shader sample the pixels of the RenderTexture, white pixels means generate grass while black pixels means don't.
That way I can add and then delete tufts of grass wherever I like.
It's still in early development, I'm planning to add brush size/opacity gizmo and to vary the grass blades height based on the color of the pixels on the RenderTexture.