You could use your weight map texture for a mask. The TerrainBlend texture uses a weight map to describe how to splat the terrain textures, so you could just load a copy of that texture CPU-side, and query pixels directly to determine where to instance your grass.
Thanks! But how do you read the mask black vs. white pixels in Urho? And what object do I instantiate? Do I have to create my own object with quads, or is there a built-in way of doing grass efficiently?
There is no built in way of doing grass, outside of the usual static meshes and mesh groups. You can go off into the weeds with shell/fur rendering, volume rendering, etc… but that will all take a bit of custom development and probably a few hours spent reading theses and siggraph papers. I did a brief experiment with a scheme that uses a static mesh of billboards constantly centered on the player (thread: Grass/vegetation mapping repo: https://github.com/JTippetts/Urho3DGrassTest ) with mixed results. With a bit of artistic finesse it could maybe be made to work.
As far as querying the weight map, that is a simple matter of loading the map into an image and sampling a pixel directly. The map will have one color component mapped to your grass base texture, so you can just test that component vs some threshold and enable/disable grass at that spot depending on the result.
Thanks for the link, I’ll definitely learn from your implementation. Thank you!
As for the sampling, I think I have to phrase my question a little better: With Urho, once I read the mask and know what is closer to 0 or 1 and therefore how much grass I want, how do I get the transform (X, Y, Z) where to create my quad?