只有阴影pass,请自行合并,需要指定高度,忽略深度检测,需要控制好排序,或者去掉忽略,视情况而定,最后我觉得还是shadowmap好
Shader "Custom/MeshShadow"
{
Properties
{
_ShadowOffset("ShadowOffset",vector) = (,,,)
_ShadowHeight("ShadowHeight",float) =
}
SubShader
{
Tags { "RenderType"="Opaque" "Queue"="Transparent"}
Pass
{
Name "MeshShadow"
Tags {"LightMode" = "Always"} Blend One OneMinusSrcAlpha
ZWrite Off
ZTest Always Stencil
{
Ref
Comp NotEqual
Pass Replace
} CGPROGRAM
#include "UnityCG.cginc"
#pragma vertex vert
#pragma fragment frag float4 _ShadowOffset;
float _ShadowHeight; struct v2f
{
float4 pos : POSITION;
float4 texcoord : TEXCOORD0;
}; v2f vert ( appdata_base v )
{
v2f o;
float4x4 _RotMatrix = _Object2World;
_RotMatrix[][] = ;
_RotMatrix[][] = ;
_RotMatrix[][] = ;
float3 tempPos = float3(_Object2World[][],_Object2World[][],_Object2World[][]); float4 vertexPos = mul(_RotMatrix,v.vertex);
vertexPos.x += _ShadowOffset.x * vertexPos.y + _ShadowOffset.x;
vertexPos.z += _ShadowOffset.y * vertexPos.y + _ShadowOffset.y;
vertexPos.xyz += tempPos;
vertexPos.y = _ShadowHeight; o.pos = mul(UNITY_MATRIX_VP, vertexPos);
o.texcoord = v.texcoord;
return o;
} fixed4 frag(v2f i) :COLOR
{
return fixed4(,,,0.3);
}
ENDCG
}
} }