Query texture of another Mesh from within Grass shader

Godot Version

4.7.1

Question

I am trying to work out the best way to add grass to an existing 3D model. I am stealing and borrowing from this sample: GitHub - 2Retr0/GodotGrass: Per-blade grass rendering inspired by "Ghost of Tsushima", implemented in Godot · GitHub, which has a nice LOD system that I would like to do similar to. My model is a sports field (large field at y=0, with some parts of the field that are not grass) - i.e. has other surfaces that aren’t grass. I want to be able to use the tiled approach in the linked sample to make my grass, and then hide the grass if the surface is not grass (open to other suggestions - I know that there’s an option in the godot editor to wrap a mesh in MultiMeshes, but I’m not sure that will mesh (pun intended) with the LOD optimization).

I am currently thinking of making a mask texture of the grass parts of the field using a Viewport and orthographic camera, and querying that in the grass shader, but I wonder if I can just query the texture that the sports field uses directly by adjusting the UV of the grass material - if I can get them to line up (the sports field mesh in question is largely flat), then I can just say “if the texture sample is green, show grass”.

I’m just looking for general advice / pointers on the best way to add grass to an existing 3d asset.

Yes you can use a coverage texture.

Ideally I would like to automate the “coverage texture” generation - how would you recommend I map from world space on the grass plane to this mask texture?

Render the texture into an orthographic viewport whose viewing area is exactly the size of your field.