Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Last active June 9, 2019 05:24
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save tsubaki/055575f78334ed727350 to your computer and use it in GitHub Desktop.
透明な床に影を落とすシェーダー改
Shader "Custom/TransparentShadowCollector"
{
Properties
{
_ShadowIntensity ("Shadow Intensity", Range (0, 1)) = 0.6
}
SubShader
{
Pass
{
Tags {
"Queue"="geometry-1"
"RenderType"="opaque"
}
ColorMask 0
}
Pass
{
Tags {
"RenderType"="Transparent"
"Queue"="Transparent"
"LightMode" = "ForwardBase"
}
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fwdbase
#include "UnityCG.cginc"
#include "AutoLight.cginc"
uniform fixed4 _Color;
uniform float _ShadowIntensity;
struct v2f
{
float4 pos : SV_POSITION;
LIGHTING_COORDS(0,1)
};
v2f vert(appdata_base v)
{
v2f o;
o.pos = mul (UNITY_MATRIX_MVP, 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
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment