The "Geometry" shader node provides normal information for the geometry being shaded. This can be useful, for example, to mix a snow shader with a rock shader depending on how "flat" the geometry is (angle relative to Z axis). This normal information seems to be calculated after any displacement is applied by the shader (Cycles). In my case, I would like to get the normal information before displacement is applied. Is this possible?
-
$\begingroup$ The way with Geometry Nodes as the given answer by @Nathan suggests is the only way as far as I know, at least you cannot preserve them in the Shader Editor itself. Because the order before rendering is always first comes the original mesh, then the modifiers and afterwards the materials at last, so everything you do there with normals is executed on the altered mesh. $\endgroup$– Gordon BrinkmannAug 30 at 9:46
1 Answer
Assuming we're not using custom normals or sharp edges-- which would be weird with true displacement-- we can capture the vertex normal in geometry nodes and use it in the shader:
The geometry nodes are evaluated before any shader based displacement. Our output will be in object space, giving us interpolated values, so we need to normalize the vectors and transform into world space in order to use them the same way we'd typically use a normal in the shader.