Skip to content

Instantly share code, notes, and snippets.

@wtekteam
Last active March 6, 2020 16:16
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wtekteam/3f87bf54718538365444 to your computer and use it in GitHub Desktop.
Save wtekteam/3f87bf54718538365444 to your computer and use it in GitHub Desktop.
Shader that set invisible the object but receive shadows (= Matte Shadow effect from 3DSMax). Source: http://forum.unity3d.com/threads/matte-shadow.14438/.
Shader "FX/Matte Shadow" {
Properties {
_Color ("Shadow Color", Color) = (1,1,1,1)
_ShadowInt ("Shadow Intensity", Range(0,1)) = 1.0
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
}
SubShader {
Tags {
"Queue"="AlphaTest"
"IgnoreProjector"="True"
"RenderType"="TransparentCutout"
}
LOD 200
ZWrite off
Blend zero SrcColor
CGPROGRAM
#pragma surface surf ShadowOnly alphatest:_Cutoff
fixed4 _Color;
float _ShadowInt;
struct Input {
float2 uv_MainTex;
};
inline fixed4 LightingShadowOnly (SurfaceOutput s, fixed3 lightDir, fixed atten)
{
fixed4 c;
c.rgb = lerp(s.Albedo, float3(1.0,1.0,1.0), atten);
c.a = 1.0-atten;
return c;
}
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = lerp(float3(1.0,1.0,1.0), _Color.rgb, _ShadowInt);
o.Alpha = 1.0;
}
ENDCG
}
Fallback "Transparent/Cutout/VertexLit"
}
@nntgam
Copy link

nntgam commented Mar 6, 2020

not working with UI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment