How to get 'As Normal Map' in shader code?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Macryc

Switching on ‘As Normal Map’ for a noise texture in the inspector turns said noise into a normal map by calculating bump from the texture.

Question: how do I recreate this in the shader code or in visual shader?

:bust_in_silhouette: Reply From: cm

I don’t know of a built in function, but the basic idea is to sample a height map at least times (north, south, east, and west of the current sample point) and use the difference between those samples to create normals:

Generating a normal map from a height map