Created
September 5, 2017 17:08
-
-
Save nicoplv/b23c6e55facf60f946fbc2009209d675 to your computer and use it in GitHub Desktop.
A mobile decal shadow shader for Unity
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 "Mobile/Decal Shadow" { | |
Properties{ | |
_MainTex("Base (RGB)", 2D) = "white" {} | |
_alpha("AlphaMulti", Range(0,1)) = 1 | |
} | |
SubShader{ | |
Tags { "RenderType" = "Opaque" "Queue" = "Geometry+1" "ForceNoShadowCasting" = "True" } | |
LOD 200 | |
Offset -1, -1 | |
CGPROGRAM | |
#pragma surface surf Lambert decal:blend | |
sampler2D _MainTex; | |
float _alpha; | |
struct Input { | |
float2 uv_MainTex; | |
float3 viewDir; | |
}; | |
void surf(Input IN, inout SurfaceOutput o) { | |
half4 c = tex2D(_MainTex, IN.uv_MainTex); | |
o.Albedo = c.rgb; | |
o.Alpha = c.a * _alpha * sqrt(dot(normalize(IN.viewDir), o.Normal)); | |
} | |
ENDCG | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment