Created
March 13, 2023 13:30
-
-
Save barleymalt/c67cbaa98940f3b0ca581a76b70ea76e to your computer and use it in GitHub Desktop.
A collection of useful unity shaders
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
////////////////////////////////////////////// | |
//// TRANSPARENT SHADOW COLLECTOR - START //// | |
////////////////////////////////////////////// | |
// See: https://forum.unity.com/threads/transparent-shader-receive-shadows.325877/#post-2114800 | |
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' | |
Shader "Custom/TransparentShadowCollector" | |
{ | |
Properties | |
{ | |
_ShadowIntensity ("Shadow Intensity", Range (0, 1)) = 0.6 | |
} | |
SubShader | |
{ | |
Tags | |
{ | |
"Queue"="AlphaTest" | |
} | |
Pass | |
{ | |
Tags | |
{ | |
"LightMode" = "ForwardBase" | |
} | |
Cull Back | |
Blend SrcAlpha OneMinusSrcAlpha | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment frag | |
#pragma multi_compile_fwdbase | |
#include "UnityCG.cginc" | |
#include "AutoLight.cginc" | |
uniform float _ShadowIntensity; | |
struct v2f | |
{ | |
float4 pos : SV_POSITION; | |
LIGHTING_COORDS(0, 1) | |
}; | |
v2f vert(appdata_base v) | |
{ | |
v2f o; | |
o.pos = UnityObjectToClipPos(v.vertex); | |
TRANSFER_VERTEX_TO_FRAGMENT(o); | |
return o; | |
} | |
fixed4 frag(v2f i) : COLOR | |
{ | |
float attenuation = LIGHT_ATTENUATION(i); | |
return fixed4(0, 0, 0, (1 - attenuation) * _ShadowIntensity); | |
} | |
ENDCG | |
} | |
} | |
Fallback "VertexLit" | |
} | |
//////////////////////////////////////////// | |
//// TRANSPARENT SHADOW COLLECTOR - END //// | |
//////////////////////////////////////////// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment