Announcement

Collapse
No announcement yet.

Blueprint Time exactly 2*PI times slower than material time?

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

    Blueprint Time exactly 2*PI times slower than material time?

    Hey,
    I'm creating an ocean shader and need to replicate the water movements in blueprints to achieve buoyancy for actors.
    What's really weird to me is that the Time node in materials and the "Get Time Seconds" (or any other game time blueprint node) seem to not match.
    I would understand if they were just offset because they weren't synced but the blueprint time seems to run significantly slower which is really weird.
    By some testing I found that it seems to be exactly 2*PI times slower.

    I use the same sine (radians) in both material and blueprint and here are both functions to calculate the water height (I reduced it to the simplest waves possible).
    I uploaded both functions as pictures. These versions sync perfectly and as you can see I multiply the time by "2*PI". The only other difference is the "+ Water Height" in the blueprint version which just shifts the actor to the water plane height. The "Pos" input is the actor's world position and the "Height" value gets used to update the actor's Pos.z on tick.
    I've been staring on this for the past hour and can't figure it out, it seems so strange to me.

    Obviously I could work with the 2*PI Version for now but firstly I want to be sure that they sync perfectly and still do so after an arbitrary amount of time, secondly this just confuses the hell out of me and I'm just interested in a solution.

    Has anyone else ever noticed this? Am I just a little tired and am missing an obvious mistake? Is it my engine or does the same thing happen for someone else?
    I would appreciate any feedback.

    Kind regards,
    foodius

    #2
    I got it. I was also writing an ocean shader - and had exactly the same problem.

    It's not the time: time is precisely the same for material and BP. You can check it with a simple material that takes the time and fractures it - they will match.

    It's the Sine/Cosine functions. For whatever reason the ones in material editor multiply whatever you put into them by 2*pi. I don't know why - but i am certain: i have been experimenting on it for the last 6 hors straight.

    To have the same results for ocean wave functions in BP and materials - just take it as a rule of thumb for BluePrints to multiply whatever you want to plug into the Sine/Cosine function by 2*pi, not just the time.

    So, for material it's:
    • Sine(x)
    • Cosine(x)
    But for blueprints it's:
    • Sine(2*Pi*x)
    • Cosine(2*Pi*x)
    Last edited by LudeosShaft; 06-04-2020, 04:34 AM.

    Comment


      #3
      because 2pie radians is a full circle.
      meaning the units are different one is degrees one is radians.
      Last edited by MostHost LA; 06-04-2020, 05:31 AM.

      Comment


        #4
        The Sine and Cosine nodes in materials have a 'Period' value that determines the cycle time - they aren't the same as the mathematical sin/cos nodes that Blueprint uses. If you set the period value to PI * 2, you will notice that the output values will then match.

        Comment


          #5
          Thank you guys very much, that explains a lot! I didn't see the notification sooner but that makes sense, so the material sin/cos basically aims to perform one full rotation every one unit per default. That's a reason I can get behind, when before I thought I found the weirdest bug. Thanks!

          Comment


            #6
            Thank you guys, I couldn't figure out why the offset in the waves, you really saved the day!!!

            Comment

            Working...
            X