Shadow Mapping With PCF

其实就基本SM加上一个靠近百分比过滤·

下面这里是使用对周边取样的片段·

     float t_DepthMap = DepthMap.Sample( DepthMapSampler, t_ProjPos.xy ).r;
	float4 t_OutColor = t_DepthMap >= t_DepthScene ? s_OutColor : s_ShadowColor;

	t_DepthMap = DepthMap.Sample( DepthMapSampler, t_ProjPos.xy + float2(-viewport_inv_width, 0) ).r;
	t_OutColor += t_DepthMap >= t_DepthScene ? s_OutColor : s_ShadowColor;

	t_DepthMap = DepthMap.Sample( DepthMapSampler, t_ProjPos.xy + float2( viewport_inv_width , 0) ).r;
	t_OutColor += t_DepthMap >= t_DepthScene ? s_OutColor : s_ShadowColor;

	t_DepthMap = DepthMap.Sample( DepthMapSampler, t_ProjPos.xy + float2( 0,-viewport_inv_height) ).r;
	t_OutColor += t_DepthMap >= t_DepthScene ? s_OutColor : s_ShadowColor;

	t_DepthMap = DepthMap.Sample( DepthMapSampler, t_ProjPos.xy + float2( 0, viewport_inv_height) ).r;
	t_OutColor += t_DepthMap >= t_DepthScene ? s_OutColor : s_ShadowColor;

	t_DepthMap = DepthMap.Sample( DepthMapSampler, t_ProjPos.xy + float2(-viewport_inv_width, -viewport_inv_height) ).r;
	t_OutColor += t_DepthMap >= t_DepthScene ? s_OutColor : s_ShadowColor;

	t_DepthMap = DepthMap.Sample( DepthMapSampler, t_ProjPos.xy + float2( viewport_inv_width, -viewport_inv_height) ).r;
	t_OutColor += t_DepthMap >= t_DepthScene ? s_OutColor : s_ShadowColor;

	t_DepthMap = DepthMap.Sample( DepthMapSampler, t_ProjPos.xy + float2(-viewport_inv_width,  viewport_inv_height) ).r;
	t_OutColor += t_DepthMap >= t_DepthScene ? s_OutColor : s_ShadowColor;

	t_DepthMap = DepthMap.Sample( DepthMapSampler, t_ProjPos.xy + float2( viewport_inv_width,  viewport_inv_height) ).r;
	t_OutColor += t_DepthMap >= t_DepthScene ? s_OutColor : s_ShadowColor;	

 

大概就这样子·

posted @ 2013-10-30 22:24  macom  阅读(449)  评论(0)    收藏  举报