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

_Time slower on older devices?

Discussion in 'Shaders' started by naked_chicken, Jan 23, 2016.

  1. naked_chicken

    naked_chicken

    Joined:
    Sep 10, 2012
    Posts:
    186
    I have a shader using _Time.x to pan a texture. I got it looking how I wanted on a iPhone 6s, but then when testing on a iPad and iPhone 5c, its moving super slow. Is the _Time speed different for different devices? If so, is there an easy way to combat this?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    _Time.x is supposed to be time x 20 time / 20, you might try using _Time.y which is just time unmodified. It's possible there's a bug that on some platforms so _Time.x isn't being multiplied.

    edit: cuz I dum
     
    Last edited: Jan 25, 2016
  3. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Little correction. _Time.x should be time / 20. _Time = (t/20, t, t*2, t*3). @bgolus is right otherwise, you probably want to use _Time.y.

    Also, I saw a similar problem related to float precision. The animation wasn't just slow on some devices. It was jerky because of insufficient float precision. It turns out that fixed/half(lowp/mediump) is automatically converted to float(highp) on some mobile gpus and left untouched on others.
     
  4. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,878
    My experience with _Time.xyz values on mobile is that after some point they do reset or hit an infinite wall or something.
    Maybe a precision thing or not, i always use a custom timer which is clamped between some reasonable values and that prevents unwanted results.
     
  5. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    Also on this topic you should pretty much always be using frac() when dealing with _Time, ie:
    uv.xy += frac(_Time.y * _uvPanSpeed.xy);

    The precision of float starts to break down in UVs far more obviously if you don't; basically if the UVs themselves are big numbers the texture will start to appear to be a lower resolution or streaked. If you do the frac() they won't do this, but eventually the motion of the panning might become less smooth or stepped. If _Time is half / mediump this will happen in about a minute using _Time.y, with float / highp this should be ~5 days.
     
    mipha_hg likes this.
  6. ChiuanWei

    ChiuanWei

    Joined:
    Jan 29, 2012
    Posts:
    131
    i have this issue too..
    how to solve this...