I have got a 2D texture, such as this one, which I am currently just dropping directly onto the terrain.
I am then rendering foliage on top of that texture.
I would like to (using the fragment shader), get the colour of the texture beneath the grass, and set the grass to be the colour of the texture beneath it.
To do this, I need to get the position of each grass vertex on the terrain relative to the texture.
I then need to get the colour of the texture corresponding the the location of the object, and blend it with the current grass colour (let's say I have red grass for demonstration purposes).
I am currently not sure how to start. I know I need to get the grasses' X and Z position in the world (which I currently do not have) through the shaders, but I then need to work out the corresponding texture pixel, which I currently do not know how to do.
Any advice to help solving this would be appreciated.