Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to use unity_deltaTime in shader

Discussion in 'Shaders' started by dreamerflyer, Jul 10, 2015.

  1. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    927
    Hi all, i want to control vertex position move loop,and use unity_DeltaTime,just like below,but not moving....
    Code (CSharp):
    1. float dxTime=0;
    2. v2f vert()
    3. {
    4.     dxTime+=unity_DeltaTime;
    5. if(dxTime>1)
    6. {
    7. dxTime=0;
    8. }
    9.    pos.x+=dxtime*speed;
    10. }
     
    Last edited: Jul 10, 2015
  2. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    927
    any help?
     
  3. mouurusai

    mouurusai

    Joined:
    Dec 2, 2011
    Posts:
    350
    As far I know you can't do that without storing result into texture or into compute buffer.
     
  4. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    927
    OK,Thanks~
     
  5. Sparrowfc

    Sparrowfc

    Joined:
    Jan 31, 2013
    Posts:
    100
    you would like to use _Time with fmod/sin/cos instructions to do the looping
     
  6. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    927
    Got it ,thanks~
     
  7. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871