版本:Unity 6 (6000.0)
语言:English
添加 HLSL 着色器程序
着色器输入

在多个程序中复制 HLSL

要将 HLSL 代码包含在其他 HLSLPROGRAM 部分中,可以使用 HLSLINCLUDE 指令。

示例

Shader "Examples/ExampleShader"
{
    SubShader
    {

        HLSLINCLUDE
            // HLSL code that you want to share goes here
        ENDHLSL

        Pass
        {                
              Name "ExampleFirstPassName"
              Tags { "LightMode" = "ExampleLightModeTagValue" }

              // ShaderLab commands to set the render state go here

              HLSLPROGRAM
                // This HLSL shader program automatically includes the contents of the HLSLINCLUDE block above
                // HLSL shader code goes here
              ENDHLSL
        }

        Pass
        {                
              Name "ExampleSecondPassName"
              Tags { "LightMode" = "ExampleLightModeTagValue" }

              // ShaderLab commands to set the render state go here

              HLSLPROGRAM
                // This HLSL shader program automatically includes the contents of the HLSLINCLUDE block above
                // HLSL shader code goes here
              ENDHLSL
        }

    }
}

其他资源

添加 HLSL 着色器程序
着色器输入