subtitlesStandard Shader

Add a Gradient Property to Standard Shader

The gradient property is a Texture2D. This means that you need to add a Texture2D property to your shader.

  1. Add a Texture2D property to your shader.

  2. You must include "GradientTexture" anywhere in the reference name (letter case doesn't matter).

  3. Add the [GradientGUI] attribute flag.

Shader "GPFS/Demo/Sample"
{
    Properties
    {
        [GradientGUI] _Gradient_gradienttexture ("Gradient", 2D) = "white" {}
    }
    SubShader
    {
        ...
    }
    FallBack "Diffuse"
}
  1. The package includes a helper method to sample the gradient from the Texture2D property. Make sure to include; #include "Assets/Gradient Property for Shader/Assets/Sample Gradient.hlsl"

  2. Now, you can use the float4 SampleGradient(sampler2D gradient, float t) method to sample the graident at point t (clamped 0-1).

Last updated