I'm trying to get a good density of grass, what do you think?
Grass shader heightmap problems
Realistically speaking, I think the grass should be facing different directions instead of always facing the viewer.
It's not billboarding if that's what you mean.
- Edited
No? I guess my eyes are playing tricks on me, 'cause all the grass looks like there facing the viewer.
But yeah, the grass density looks good.
Yeah, it's random rotation with the populate surface option. I'll work on adding it to my terrain then.
I added some parameters to make it look a little more random:
Now it looks a little more wild.
- Edited
I've come back to terrain after a long time, and I think heightmap terrain is better than using a mesh. I've been working on generating a mesh from a heightmap, procedural tree placement, and I'm back to the grass shader. I have it mostly working, but the height values are a little off. Almost all the grass is below the terrain, but the shape of the terrain is exaggerated in the grass, as if the height were scaled too high. I'm using the same height scale in the terrain mesh generator and the grass particles shader, both are 64 units high. Also, both the terrain and particles nodes are positioned at (0,0,0), and aren't rotated or scaled in any way(the transform for each is equal to Transform.IDENTITY). And, in the code for each, I have only one place that could possibly affect the Y position, and each gets the red channel from the heightmap and multiplies it by 64. It all works in theory...
The only thing I can think of that would make a difference in height is; for the terrain mesh I get texture data from a script, but for the particles I use the texture() function. I wouldn't think this would make a difference, but is it possible they don't return exactly the same results?
This seems to confirm my theory:
I tried generating a flat terrain mesh, and instead displacing the vertices in a shader. Sure enough, now the grass lines up perfectly:
I could use a heightmap shader instead, but if it's possible I'd rather generate the mesh in a script. Does anyone know what the difference between get_pixel() and texture() might be? I'm not sure if they both return linear values...