阴影Pass

作者:追风剑情 发布于:2016-11-8 15:18 分类:Shader

// 投射阴影Pass
Pass 
{
	Name "ShadowCaster"
	Tags { "LightMode" = "ShadowCaster" }
	
	Fog {Mode Off}
	ZWrite On ZTest LEqual Cull Off
	Offset 1, 1

	CGPROGRAM
	#pragma vertex vert
	#pragma fragment frag
	#pragma multi_compile_shadowcaster
	#include "UnityCG.cginc"

	struct v2f { 
		V2F_SHADOW_CASTER;
	};

	v2f vert( appdata_base v )
	{
		v2f o;
		TRANSFER_SHADOW_CASTER(o)
		return o;
	}

	float4 frag( v2f i ) : SV_Target
	{
		SHADOW_CASTER_FRAGMENT(i)
	}
	ENDCG
}

// 接受阴影Pass
// note: editor needs this pass as it has a collector pass.
Pass
{
	Name "ShadowCollector"
	Tags { "LightMode" = "ShadowCollector" }
	
	Fog {Mode Off}
	ZWrite On ZTest LEqual

	CGPROGRAM
	#pragma vertex vert
	#pragma fragment frag
	#pragma multi_compile_shadowcollector

	//定义SHADOW_COLLECTOR_PASS宏,以开启阴影相关的辅助宏功能
	#define SHADOW_COLLECTOR_PASS
	#include "UnityCG.cginc"

	struct appdata {
		float4 vertex : POSITION;
	};

	struct v2f {
		V2F_SHADOW_COLLECTOR;
	};

	v2f vert (appdata v)
	{
		v2f o;
		TRANSFER_SHADOW_COLLECTOR(o)
		return o;
	}

	fixed4 frag (v2f i) : SV_Target
	{
		SHADOW_COLLECTOR_FRAGMENT(i)
	}
	ENDCG
}

标签: Shader

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号