How to smooth normals useing NME?


When we use an a displacement for vertex shader positions is changing but normals isn’t. For some cases i can get normal data like i did that here:

But i don’ t know how i can smooth this normals. I think this is an important question because i faced with this too many cases and it can be an bottleneck for large spectre of shaders.

I am not sure there is a nice trick here besides trying to generate the normals in the vertex. Maybe @PatrickRyan would know ?

I think recalculate normals is not a big problem (for flat surfaces). But smoothing is the question for wich i’m not find an answer. The result that i got in preview of this material demo is sooo close to result that i have to achieve but sharpy faces just destroy my minds about material that i want

Here is the recalculation part of shader:

Maybe this tutorial How to Calculate Shader Graph Normals - Game Dev Bill may help. The article uses shader graph, but you should be able to recreate in NME and/or recreate in NME through translating the code. This isn’t something I do a lot of so I don’t have any tried and true methods.


You can also have a look here: Calculating vertex normals after displacement in the vertex shader - Resources - three.js forum

Here’s an example PG using a custom material, as implementing it in a node material is a little more involved:


Thank you guys!

I’ll check your replays tomorrow!

I try to use your way in NME but…I just don’ t know what i do wrong…I hadput nodes to frames with accordance to your script for better navigation. Would you may to check this please?

Your computations of displacedNeighbour1/2 is wrong in the NME, you should apply the displace transformation to neighbour1/2, not do neighbour1/2 + displacedPosition.

This seems to do it:

Note that I had to use an elbow node to connect the output of the (final) normal vector merger block to the transform block (to compute the world normal), directly connecting both would not work for some reasons…


Thank you soo much you are helped me a lot!!!

PR up for the connection issue, it should have shown an error dialog but it wasn’t showing: Fix NME dialog box styling by carolhmj · Pull Request #12624 · BabylonJS/Babylon.js (