2

I am making a procedural bump shader that needs to interact with other directional data in realtime within the material (as opposed to external lighting). Therefore I need to get the normals from this bump/height data, and cannot use the baking method to do it.

I adopted the node setup from this answer, and I believe I'm doing it basically correctly, however there are a couple of things that seem "off", and I'm wondering if the result can be improved.

Left: A bump / height map. Center: Normal data derived from that bump map. Right: A reference for how accurate normal data is expected to look.

Above: The center image is a plane that uses a spherical bump map as its source (left), to derive the normal vectors. When compared with spherical geometry that has a normal-colored shadeless material (right), we can see the discrepancy in accuracy.

In comparison to the reference on the right, the center plane that derives its normals from a bump map appears less spherical. It is more flattened and the shading produces crescent shapes on all four sides, so the gradient is not completely accurate. This is what I am hoping to improve.

The node tree I am currently using to obtain normals from a bump map

In the material's node tree there is a Mapping node that has values X:1.4 and Y:-1.4. These values are totally arbitrary and I arrived at this by moving the sliders until I got the result that looked best to me. If there are "correct", more precise values, I don't know what the basis would be.

In my result there is a Moiré pattern artifact that can be seen when zoomed in closely. It becomes less noticeable as the source bump texture's render resolution is increased. I'm not concerned with it because I will ultimately be using procedural textures that don't rely on pixel resolution, but I'm pointing it out for the sake of establishing that it is not part of the matter this question is concerned with.

It's worth noting that the bump map was derived from the same hemisphere as the reference. It has a value of pure black at its base, and pure white at its summit. In other words, a range of 0.0 to 1.0.

Finally, I'm not ruling out the possibility that obtaining accurate normals from bump data alone might have its limitations. Maybe this node setup is already the best that can be done. But hopefully there's a way to improve the accuracy. Seeing the result of the bake technique is encouraging. If that result is accurate, the math to achieve that should, in theory, be possible using material nodes too.


Edit:

Below is an example of how 3D angles can be isolated in a 2D image when there is normal data available.

Selecting regions of a normal map by matching colors

↑ The above GIF is not a 3D mesh, but an image plane using a normal map of Suzanne. ↓

While in this example a normal map image texture already exists, my question is mainly for the purpose of using procedural textures that have only height data and did not originate as 3D geometry.

I know this is possible (refer to the first two screenshots), however I was wondering if there is a way to improve the accuracy.

Mentalist
  • 19,092
  • 7
  • 94
  • 166
  • I don't understand your question. What I read: you want internal (procedural) light-like source to interact with normals calculated from height map (procedural either). But what you show is more about bump map node accuracy. Am I wrong? Could you explain more? – lemon Mar 24 '23 at 07:54
  • @lemon I added more details and some images to my question. I hope this helps. – Mentalist Mar 29 '23 at 19:21
  • Little experiment: https://i.stack.imgur.com/EB9df.jpg . Color management set to "raw". On the left, bump (in normal 'view' and normal map view). On the right, normal map (in normal view and normal map view). Both from procedural information. Visually, they look equivalent. But the center view show the difference (magnified twice). – lemon Mar 30 '23 at 12:03
  • And if we pseudo light the sphere https://i.stack.imgur.com/gLFMb.png from the position of the empty: center from bump map (confirms the difference above) and upper left from normal map (no unwanted artefact. This seems to show that there is an X/Y axis involved in the bump calculation. I'm not able to imagine a way to enhance that. But if that can give you some ideas (?) https://blend-exchange.com/b/6Q2y1ML7 – lemon Mar 30 '23 at 12:03
  • @lemon I think your "bump to map" plane object in your .blend contains the solution I was looking for! Specifically, the combination of the Bump node and the "Normals to map" Group node (that contains a Vector Math node set to Multiply Add). Furthermore, I noticed that after adding a Vector Math node to Multiply it by itself, the luminosity darkened to almost the exact same color as when Color Management's View transform is set to Raw. The essential nodes: https://i.stack.imgur.com/4Yi3m.png Thank you for your help. Please post as an answer if you feel inclined to. – Mentalist Apr 03 '23 at 10:56
  • Mentalist, these node groups were juste some test cases.. I don't have the feeling that I've answered your question. I think, if you will, you could write something more accurate than I'm able to do. – lemon Apr 03 '23 at 13:28

0 Answers0