Im trying to make a snow shader that displaces a plane to cover a section of terrain. Right now Im using terrain.TerrainData.heightmapTexture, passing that to my shader, and then sampling from that. But from what I can tell, the heightmap is just a solid red texture.
Does TerrainData.heightmapTexture not give me the current heightmap data for the terrain? Theres basically no documentation on it.
I would assume it’s an RFloat or RHalf texture, not sure what range it uses, like if it’s 0.0 to 1.0, or some other range, or possibly even an RInt or R16. But one thing for sure is it’s not the straight world height. It’s going to be relative to the terrain transform world Y, and scaled by the terrain’s height scale in some way.
You can look in the instancing code to see how it’s unpacked; if I recall it’s a float packed into a RGBA32 texture, but the code will tell you for sure. It also might only be filled out when GPU instancing is enabled.
Have u found any solution? Tried to scale by terrain height, but no luck. Seems encoded, but can’t find it in any shader source.
Built in shader source:
I know where to download source. I can’t find here any decoding stuff. BTW texture red channel (terrain heightmap is r16) multiplied by TerrainData.size.y * 2 (extents or smth?) looks promising.