https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@7.7/manual/writing-shaders-urp-unlit-color.html
Shader "Example/URPUnlitShaderColor" {
Properties{
_BaseColor("Base Color", Color)=(1, 1, 1, 1)
}
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;
};
// 要使 Unity shader 兼容 SRP Batcher,请在名为 UnityPerMaterial 的 CBUFFER 块中声明与材质相关的所有属性。
CBUFFER_START(UnityPerMaterial)
half4 _BaseColor;
CBUFFER_END
Varyings vert(Attributes input) {
Varyings output;
output.positionCS=TransformObjectToHClip(input.positionOS.xyz);
return output;
}
half4 frag(Varyings input): SV_Target {
// 返回 _BaseColor 值.
half4 output = _BaseColor;
return output;
}
ENDHLSL
}
}
}