Skip to content

Instantly share code, notes, and snippets.

@thorikawa
Created January 13, 2022 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thorikawa/a80349974d5e78af95f116a894c4f724 to your computer and use it in GitHub Desktop.
Save thorikawa/a80349974d5e78af95f116a894c4f724 to your computer and use it in GitHub Desktop.
透明だけど影を落とすシェーダー
//This is based on a shader from https://alastaira.wordpress.com/2014/12/30/adding-shadows-to-a-unity-vertexfragment-shader-in-7-easy-steps/
Shader "Custom/MobileARShadow"
{
SubShader {
Pass {
Tags { "LightMode" = "ForwardBase" "RenderType"="Opaque" "Queue"="Geometry+1" "ForceNoShadowCasting"="True" }
LOD 150
Blend Zero SrcColor
ZWrite On
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#pragma multi_compile_fwdbase
#include "AutoLight.cginc"
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(1.0,1.0,1.0,1.0) * attenuation;
}
ENDCG
}
}
Fallback "VertexLit"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment