Created
March 6, 2016 15:52
-
-
Save Split82/186cd137e8992c60e9fe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Decal
Decal are commonly used to add details to materials at runtime (bullets impacts are for example). They are a great tool especially in deferred rendering as they alter the GBuffer before it is lit, thus saving on performance.
In a typical scenario Decal should probably be rendered after the opaque objects and should not be a shadow caster as seen in the shaderlab “Tags” in the example below.