How to modify HDRP LayeredLit baseColor runtime?

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

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

1 Like