NME: vertex shader normals

First of all: thank you for an absolutely outstanding project, documentation and community around babylonjs - it is such a delight to experience such a wealth of information and helpful people all around.

I have followed Jason’s “Node Material Editor: Vertex Shader” youtube video and would like to know if anyone can help me in the right direction with regards to this:

It seems that normals are not calculated for the vertices when they are calculated as demonstrated in the youtube video. What I mean is - the waves displayed in the video are not individually affected by lighting which leads me to think that they need to have normals recalculated.

I should say that I am somewhat mathematically challenged so I may be wrong.

How would one go about solving this and can it be done within the Node Material Editor?

Thank you very much in advance for any help you may be able to provide.

Welcome aboard!

The waves are not affected by lighting because it’s a direct color which is used as the fragment output, the Lights block is not used.

Here’s an updated material which is using the Lights block:

The normal can be computed by taking the x/y derivatives of the world position and by taking the cross product of both.


This is amazing - this was exactly the response I was hoping for - thank you so much :smiley: