Last active
June 1, 2023 18:22
-
-
Save pema99/9250708139ad5793ff7c6fdda63a1dea 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 "Unlit/Shadowed" | |
{ | |
SubShader | |
{ | |
Pass | |
{ | |
Tags { "LightMode"="Always" } | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment frag | |
#pragma shader_feature SHADOWS_SCREEN | |
#include "UnityCG.cginc" | |
#include "AutoLight.cginc" | |
struct appdata | |
{ | |
float4 vertex : POSITION; | |
}; | |
struct v2f | |
{ | |
float4 pos : SV_POSITION; | |
SHADOW_COORDS(1) | |
}; | |
v2f vert (appdata v) | |
{ | |
v2f o; | |
o.pos = UnityObjectToClipPos(v.vertex); | |
TRANSFER_SHADOW(o); | |
return o; | |
} | |
fixed4 frag (v2f i) : SV_Target | |
{ | |
return SHADOW_ATTENUATION(i); | |
} | |
ENDCG | |
} | |
// Must be present to receive shadows | |
Pass | |
{ | |
Tags {"LightMode" = "ShadowCaster"} | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment frag | |
#include "UnityCG.cginc" | |
struct appdata { | |
float4 vertex : POSITION; | |
float3 normal : NORMAL; | |
}; | |
struct v2f { | |
float4 pos : SV_POSITION; | |
}; | |
v2f vert (appdata v) { | |
v2f o; | |
TRANSFER_SHADOW_CASTER_NORMALOFFSET(o) | |
return o; | |
} | |
float4 frag (v2f i) : SV_Target { | |
return 0; | |
} | |
ENDCG | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment