-
-
Save RPDevJesco/d34d60cc5d223d1cae2d76a5b75c3d68 to your computer and use it in GitHub Desktop.
This file contains 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 | |
} | |
Fallback "Diffuse" | |
} |
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.
-Split82
I fixed the errors that were present in the original code (line ending issues and rogue space inbetween - and 1 for the offset).
Changed brackets to better suit my coding style of choice and added a Fallback for Diffuse.