Search Unity

SetColor vs SetFloat vs SetGlobalFloat RE minimizing material change

Discussion in 'General Graphics' started by uani, Mar 10, 2022.

  1. uani

    uani

    Joined:
    Sep 6, 2013
    Posts:
    232
    https://docs.unity3d.com/2021.1/Documentation/Manual/SRPBatcher.html

    states

    "In Unity, you can modify the properties of any Material at any time during a frame. However, this has some drawbacks. For example, there is a lot of work to do when a DrawCall is using a new Material."

    I guess "new Material" means "same Material having changed properties".


    Hi,

    I like to minimize material changes for ~10,000 GameObjects

    Currently my Coroutines use
    SetColor
    .

    1. Is
      SetFloat("_Color")
      the same as
      SetColor
      ?
    2. Is
      SetGlobalFloat
      avoiding Material change per GO, note GOs are grouped into groups having the same sharedMaterial within but distinct across groups?
      If yes, can I duplicate Shaders on the fly? How?

    What else do you have in mind RE minimizing material change? I use the Standard built-in Pipeline.
     
  2. uani

    uani

    Joined:
    Sep 6, 2013
    Posts:
    232
    Is there a difference wrt above in the URP or HDRP (BRG in HR excluded) ?