Hi, how can I grab the Terrain Normal in World Space in the Material Graph with a custom node? Also, where can I find any documentation or resources concerning custom nodes and API available for custom hlsl?
Thanks
Hi, how can I grab the Terrain Normal in World Space in the Material Graph with a custom node? Also, where can I find any documentation or resources concerning custom nodes and API available for custom hlsl?
Thanks
Hi Stephane,
The only way to access information from the landscape in another material graph would be via RVT. You would have your landscape material output the normal to a RVT and then simply sample that RVT from the grass material.
You can find documentation about how to setup RVTs here. You will want to use the RVT type “Base Color, Normal, Roughness, Specular”. If you only want to access the normal, that seems a bit overkill but in general, if your targeted platform supports it, it’s a very good idea to use RVT to render even landscape itself because it’s much more efficient than regular landscape materials, so the cost of outputting all that information is well absorbed.
As for custom HLSL node, there’s no particular documentation besides what can be found in the official Unreal doc.
Cheers,
Jonathan
Thanks for the information. I was hoping there might be a way to access it without using RVTs.
No, RVT, being a single global texture, is easily accessible from any material, unlike individual landscape heightmaps, which are per-landscape component so if you want to access them from another material (to compute the normal), you’d need to gather the landscape component that corresponds to the position you need, access its heightmap from there and pass it to your material via texture parameters in a Material Instance Dynamic. That becomes problematic when your object’s area overlaps several landscape components. Plus, you’d also to address the heightmap data in a specific way since it’s laid out in a peculiar way…
So… RVT is definitely the simplest option (and the most efficient, for all the reasons explained earlier), if you can afford the cost in memory (since it lives alongside regular heightmaps/weightmaps).
Cheers,
Jonathan