Search Unity

Graphics.Blit and delta time: speed changes with FPS

Discussion in 'Shaders' started by AlexTemina, Nov 3, 2016.

  1. AlexTemina

    AlexTemina

    Joined:
    Feb 19, 2014
    Posts:
    44
    Hi guys,

    I'm making a shader that calculates splash animations for water. The shader is used in blitting because it uses a texture to make the calculation. The calculation depends on the texture itself: red is energy and green the elevation. Energy is calculated depending on neighbours and the base line, and elevation is the previous elevation plus the current energy.


    (http://imgur.com/tpJvxkE)

    The thing is that, since this is done with Graphics Blit and that line is called with every Update, depending on the FPS the water will flow faster or slower. I tried adding deltatime in lots of places, but It just doesn't work. Maybe it dissipates faster, neighbours may get more or less energy, but it's not making the exact same calculation. I'm afraid the only way is depending on how many times you call Blit.

    I tried putting Blit in FixedUpdate and it works, but this is not a solution. Firstly because is not a physics calculation, and secondly because all our blits are batched inside an Update call.

    Do you have a solution for this?

    The calculations are based on this thread.

    I attatched the Shader Forge Node tree.

    Thanks a lot for any help.
     

    Attached Files:

  2. cowtrix

    cowtrix

    Joined:
    Oct 23, 2012
    Posts:
    322
    Unfortunately it really does seem like DeltaTime would be the solution here.
     
  3. AlexTemina

    AlexTemina

    Joined:
    Feb 19, 2014
    Posts:
    44
    No, no, that is awesome. The problem is that I tried ti put unity_deltaTime in lots of places (after speed, next to mass...) and it never works properly. So I would like to know where or how to introduce it.

    Thanks for the help.