how can i convert height to normal in material?

Id like to convert a greyscale heightmap to a normal map in my material.
anyone know how this is done?

NormalFromHeightmap node does that:


(Add node at the end is not needed – it is there for purpose of taking that screenshot)

Note that ‘Texture object’ has to be texture object (not texture sample)

Ideally, you’ll create the actual normal map, so the 2 minutes you have to invest now, will save few dozen instructions that will have to execute on gpu for each pixel on each frame that each of your players display…

Is this the only way?
I need to create the nmap from a texture sample, because my heightmap is generated by the material (procedural).

found this… d889384cbdf2d7b400048a38ad1f81a22be14d15.jpeg
dunno how well it works yet
Edit: it doesnt work well, just cant seem to get a good result.

Not sure if this is relevant, but you mention that you are generating the heightmap procedurally - perhaps this is of use to you. I use this with very good results. But be advised that you need to turn Tangent Space Normal off on the material, otherwise the lighting freaks out.

Thanks Bluntie, this worked great.
If you’re using it for reflective surfaces like water, I found multiplying the height map by 500(!) turned out really nicely.
If your using a planar reflection capture you should probably adjust the “normal distortion strength” as well.

To convert the texture to a rexture sample you can use a one time render target.

Set up a camera to capture the whole landscape or object in ortho.
set it up so it only captures the object. With only the proper material.
you could even do this by having 2 copies of the object, the second being used and discarded after use.

Once that process is done you have a render texture you can use as an object in the material.