kingBook

导航

URP 编写自定义 Shader (1) URPUnlitShaderBasic

https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@7.7/manual/writing-shaders-urp-basic-unlit-structure.html

Shader "Example/URPUnlitShaderBasic" {
    Properties{

    }

    SubShader{
        Tags { "RenderType"="Opaque" "RenderPipeline"="UniversalPipeline" }

        Pass {
            HLSLPROGRAM

            #pragma vertex vert
            #pragma fragment frag

            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"

            struct Attributes {
                float4 positionOS   : POSITION;
            };

            struct Varyings {
                float4 positionCS  : SV_POSITION;
            };

            Varyings vert(Attributes input) {
                Varyings output;
                // 从对象空间到裁剪空间
                output.positionCS=TransformObjectToHClip(input.positionOS.xyz);
                return output;
            }

            half4 frag(Varyings input): SV_Target {
                half4 output=half4(0.5, 0, 0, 1);
                return output;
            }
            ENDHLSL
        }
    }
}

posted on 2022-02-14 20:22  kingBook  阅读(139)  评论(0编辑  收藏  举报