Search Unity

Help Wanted Set Gradient Node Value from Script

Discussion in 'Shader Graph' started by OldLegWig, Oct 7, 2019.

  1. OldLegWig

    OldLegWig

    Joined:
    Mar 18, 2018
    Posts:
    81
    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.
     
  2. alexandral_unity

    alexandral_unity

    Unity Technologies

    Joined:
    Jun 18, 2018
    Posts:
    110
    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.
     
    OldLegWig likes this.
unityunity