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

Can You Override Built-in Global Shader Parameters with Shader.SetGlobalFloat?

Discussion in 'Shaders' started by sgoodrow, May 20, 2015.

  1. sgoodrow

    sgoodrow

    Joined:
    Sep 28, 2012
    Posts:
    150
    Specifically I want to override the _Time shader parameter (to allow for pausing). I have many shaders which reference this parameter, and would like to override it rather than change them all.

    When does Unity update the _Time shader parameter? Is there an opportunity to set it after, every frame, before the frame renders?
     
  2. geroppo

    geroppo

    Joined:
    Dec 24, 2012
    Posts:
    140
    I don't think that's possible, but you could add ( on all the shaders...) a new variable like _CustomTime and mupltiply your _Time with it, and with that you could use SetGlobalFloat on the CustomTime.