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

Question How can I set the MaterialPropertyBlock of Terrain TreeInstances

Discussion in 'General Graphics' started by jarrednorris, Apr 20, 2022.

  1. jarrednorris

    jarrednorris

    Joined:
    Aug 8, 2020
    Posts:
    5
    I have a material property I'd like to override
    _ClassColor("Color", Color) = (1,1,1,1)
    at runtime that exists on the materials used by the prefab in each tree prototype


    Each instance of the same prototype will share a colour which is passed to the shader

    Is there a way I can access the renderer for tree instances on a terrain?
    and if not is there a workaround that will let me set this value in the shader?
     
  2. Ne0mega

    Ne0mega

    Joined:
    Feb 18, 2018
    Posts:
    745
    If you are using Shadergraph, in C#

    Shader.SetGolbal("Color", Color);

    then the shadergraph property node, turn off "exposed" and it will use the global shader value.