鸟语天空
阴影Pass
post by:追风剑情 2016-11-8 15:18
// 投射阴影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
}
评论:
发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容