Skip to content

Instantly share code, notes, and snippets.

@lyuma
Created August 19, 2019 22:40
Show Gist options
  • Select an option

  • Save lyuma/82e5cbc67b5a1e4b111faec7565750e2 to your computer and use it in GitHub Desktop.

Select an option

Save lyuma/82e5cbc67b5a1e4b111faec7565750e2 to your computer and use it in GitHub Desktop.
Pass {
Name "SHADOWCASTER"
Tags { "LightMode" = "ShadowCaster" }
CGPROGRAM
#pragma target 3.0
#pragma multi_compile_shadowcaster
#pragma multi_compile_instancing
#pragma vertex vertShadowCaster
#pragma fragment fragShadowCaster
#include "UnityCG.cginc"
sampler2D _MainTex;
uniform float4 _MainTex_ST;
uniform float _DisableShadow;
uniform float _Cutoff;
struct VertexOutputShadowCaster
{
V2F_SHADOW_CASTER_NOPOS
float2 tex : TEXCOORD1;
float3 posWorld : TEXCOORD2;
float4 pos : SV_POSITION;
};
VertexOutputShadowCaster vertShadowCaster (appdata_full v)
{
VertexOutputShadowCaster o = (VertexOutputShadowCaster)0;
UNITY_SETUP_INSTANCE_ID(v);
TRANSFER_SHADOW_CASTER_NOPOS(o,o.pos)
o.tex = TRANSFORM_TEX(v.texcoord.xy, _MainTex);
o.posWorld = mul(unity_ObjectToWorld,float4(v.vertex.xyz, 1.0)).xyz;
if (_DisableShadow > 0) {
o.pos = float4(2,2,2,1);
}
return o;
}
half4 fragShadowCaster (VertexOutputShadowCaster i) : SV_Target
{
half alpha = tex2D(_MainTex, i.tex).a;
clip (alpha - _Cutoff);
SHADOW_CASTER_FRAGMENT(i)
}
ENDCG
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment