Version: Unity 6.2 Alpha (6000.2)
Language : English
Add a shader pass in a custom shader
Writing HLSL shader programs

Include a shader pass with the UsePass command

The UsePass command inserts a named Pass from another ShaderA program that runs on the GPU. More info
See in Glossary
object. You can use this command to reduce code duplication in shader source files.

Example

This example code creates a Shader objectAn instance of the Shader class, a Shader object is container for shader programs and GPU instructions, and information that tells Unity how to use them. Use them with materials to determine the appearance of your scene. More info
See in Glossary
called ContainsNamedPass, which contains a Pass called ExampleNamedPass.

Shader "Examples/ContainsNamedPass"
{
    SubShader
    {
        Pass
        {    
              Name "ExampleNamedPass"
            
              // The rest of the Pass contents go here.
        }
    }
}

This example code creates a Shader object called UseNamedPass, which uses the named Pass from the example code above.

Shader "Examples/UsesNamedPass"
{
    SubShader
    {
        UsePass "Examples/ContainsNamedPass/EXAMPLENAMEDPASS"
    }
}

Additional resources


对文档有任何疑问,请移步至开发者社区提问,我们将尽快为您解答
Add a shader pass in a custom shader
Writing HLSL shader programs
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961