Search Unity

How to modify HDRP LayeredLit baseColor runtime?

Discussion in 'Shaders' started by ggot, Nov 8, 2019.

  1. ggot

    ggot

    Joined:
    Jul 17, 2015
    Posts:
    5
    Hi all,

    I need to change a hdrp LayeredLit materials layers' BaseColor runtime.

    Since I could not find any reference documentations, I tried many logical options without success. (like:
    rend.materials[3].SetColor("_MainlayerBaseColor", c);
    rend.materials[3].Mainlayer.SetColor("_BaseColor", c);
    rend.materials[3].Layers[1].SetColor("_BaseColor", c);
    etc.

    Since I can easily change these attributes runtime in editor/inspector, I'm pretty sure that it can be reached via C# code as well.

    Anyone who knows the right syntax pls?
    Thanks,
    Paul
     
  2. ggot

    ggot

    Joined:
    Jul 17, 2015
    Posts:
    5
    Got it. I digged the source code of the LayeredLit shader on GitHub, and turned out that

    rend.materials[3].SetColor("_BaseColorX", c);

    is the right syntax, where X is the index of the layer, 0,1,2 or 3
     
    Andresmonte likes this.