mAlkAv!An is correct when he states that manually calculating the derivatives using calculus will give superior results. Much faster generally and won’t require duplicating a whole tree of nodes 3 times. Sometimes though the math is out of reach or you just want to see what it would look like first before deciding whether to invest the necessary time. That’s really what the normalfromfunction function is for, it is a bit messy and expensive to do too much with it.

This is copied from the JBaldwin wave thread where he integrated the Position part of the following math:

Gerstner Waves:

http://http.developer.nvidia.com/GPUGems/elementLinks/013equ01.jpg

http://http.developer.nvidia.com/GPUGems/elementLinks/013equ02.jpg

http://http.developer.nvidia.com/GPUGems/elementLinks/013equ03.jpg

http://http.developer.nvidia.com/GPUGems/elementLinks/013equ04.jpg

So in this case, Position would be the math used in the world position offset shader. B= binormal, T=tangent, N=normal.

Those last 3 would all be considered the derivatives. You could elect to solve any one of them and then re-formulate the other two using cross products, or you could solve all three to get the most robust possible results. Usually we end up solving one derivative and then derive the other two using a cross product with 0,0,1 and the function “CreateThirdOrthogonalVector”. The obvious weakness there being the result fails if the vector is ever exactly 0,0,1 but you can solve that using clamps or Ifs generally.

For some functions like cos(x) the derivative is simply sin(x). So for some shapers it is easy. You should try messing with an online derivative calculator they can be very informative. Or just search about finding the derivative. What the normalfromfunction route does is test 2 points on either axis manually rather than solve the derivative using calculus. Kind of a brute force way of doing things really.

(edit: those attached images below are just redundant images I cant seem to remove).