Set Gradient Node Value from Script

I’ve found that you can set a gradient as a property in a shader and sample it for a color using the sample gradient node, but I cannot find info on how to set the value of the gradient property from a C# script.

It would be helpful to know how to do this directly to a material (i.e. “material.SetGradient”) and for a MaterialPropertyBlock.

1 Like

Gradients are not a supported material property, that implementation is specific to Shader Graph. The intent of it being on the blackboard is to re-use the same gradient in multiple places, but the material doesn’t support it as a property, limitation of Shader Lab.

1 Like

Is there any way around this limitation today? I need to be able to set gradient changes at runtime from code.

Thank you!

1 Like

I guess the closest thing would be creating a texture containing the gradient and using that instead.
However I am dishartened as well to hear that it is not posible otherwise.