Announcement

Collapse
No announcement yet.

Problems with calculating wave normals.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    Thanks for the quick reply Deathrey!

    So if I'm understanding this correctly, for a sine wave with amplitude A and direction (1,0,0) the normal would read (-(A*sinx),0,1-(A*cosx)) ?
    Apologies if that's not correct, I'm not the strongest mathematically. I've only just started looking deeper into this stuff. Would you possibly be able to post a simple graph of a sine wave setup so I can better visualise it?

    Thanks for your time!

    Leave a comment:


  • replied
    Normal's red and green components are minus sine, multiplied by projection of direction vector on x and y axis respectively. Blue component is one minus cosine.
    GPU gems has pretty detailed paper on simple waves.

    If you are set on following a unity tutorial, mind potential differences with Y being up axis and default period of sine/cosine material expression in Unreal.

    Leave a comment:


  • started a topic Problems with calculating wave normals.

    Problems with calculating wave normals.

    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:



    But the result looks as follows:



    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))



    However the result of that looks like this:



    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
    Attached Files
    Last edited by toddy1991; 07-01-2019, 12:02 PM.
Working...
X