Hi People,

I’ve recently being getting into writing more complex shaders and have been getting to grips with the maths. However I have followed as many tutorials and read as many articles as I can find on calculating normals, but my results just don’t seem to be correct and I’m struggling to understand why. (I’ll link the articles below for anyone interested)

I am following this tutorial for an ocean shader, it is for Unity, but is easy enough to translate to UE4. I got stuck at the normals part, here is what I have so far:

[ATTACH=JSON]{“data-align”:“none”,“data-size”:“full”,“data-tempid”:“temp_167714_1561996919449_556”}[/ATTACH]

But the result looks as follows:

[ATTACH=JSON]{“data-align”:“none”,“data-size”:“full”,“data-tempid”:“temp_167713_1561996928478_898”}[/ATTACH]

I decided to boil it down and just try to get the normals of a simple static sine wave working. As far as I understand, calculating the normals should look something like this:

Sine wave = (x,y,(sinx))

Tangent = (1,0,(cosx)) = (T.x,T.y,T.z)

Normal = (-T.z,T.y,T.x) = Cross(Tangent, (0,1,0))

[ATTACH=JSON]{“data-align”:“none”,“data-size”:“full”,“data-tempid”:“temp_167716_1561996935497_276”}[/ATTACH]

However the result of that looks like this:

[ATTACH=JSON]{“data-align”:“none”,“data-size”:“full”,“data-tempid”:“temp_167715_1561996940401_49”}[/ATTACH]

I’m not sure if I’m missing something here but any help would be really appreciated! And if anyone could post a screenshot of a graph that’d be great, as all this maths is starting to hurt my brain now!

https://stackoverflow.com/questions/…urve-sine-wave

https://www.gamedev.net/forums/topic…n-a-sine-wave/

https://www.khanacademy.org/math/mul…ector-to-curve