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.
次に、オブジェクトの位置に対応するテクスチャの色を取得し、それを現在の草の色とブレンドする必要があります (デモ用に赤い草があるとします)。
どのように始めればよいのか、現時点ではわかりません。シェーダーを介してワールド内の草の X および Z 位置 (現在は持っていません) を取得する必要があることはわかっていますが、対応するテクスチャ ピクセルを計算する必要があります。
これを解決するためのアドバイスをいただければ幸いです。