包含此页的版本:
不含此页的版本:
贴花通常用于在运行时向材质添加细节(例如,子弹撞击)。它们在延迟渲染中特别有用,因为它们会在GBuffer点亮之前改变它,从而节省性能。
在典型场景中,贴花应在不透明对象之后渲染,而不应该是阴影投射器,如ShaderLabUnity用于定义 Shader 对象结构的语言。更多信息
请参阅术语表“标签”。
Shader "Example/Decal" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" "Queue"="Geometry+1" "ForceNoShadowCasting"="True" }
LOD 200
Offset -1, -1
CGPROGRAM
#pragma surface surf Lambert decal:blend
sampler2D _MainTex;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
}