|
|

楼主 |
发表于 2008-5-24 23:59:00
|
显示全部楼层
Re: shadowmap怎么才能透射alpha透明贴图?
刚改了一下
void BuildShadowMapVS(float3 posL : POSITION0,
float3 normalL : NORMAL0,
float2 tex0 : TEXCOORD0,
out float4 posH : POSITION0,
out float2 depth : TEXCOORD0,
out float2 tex1 : TEXCOORD1
)
{
// Render from light's perspective.
posH = mul(float4(posL, 1.0f), gLightWVP);
// Propagate z- and w-coordinates.
depth = posH.zw;
tex1 = tex0;
}
float4 BuildShadowMapPS(float2 depth : TEXCOORD0, float2 tex1 : TEXCOORD1) : COLOR
{
// Each pixel in the shadow map stores the pixel depth from the
// light source in normalized device coordinates.
float a = tex2D(TexS, tex1).a;
if(a < 0.5f)
return 1.0f;
else
return depth.x / depth.y; // z / w
}
六水兄,感谢你的帖子,我稍微改了改,结果,出现了和你说的一样的遮挡问题,树干明显不正确,人的影子竟然被树遮了,出现了错误的影子,我想知道,渲染出的ps怎么知道前一次的结果是那个象素,如果是当前的值比它浅就不改变这个值了,这样一来问题才能解决,我就不清楚怎么才能知道前一次渲染的象素值?
至于压缩问题,思路很清楚,怎么知道之前的象素alpha值啊?
能否把你的这段shader发上来看看?
我在考虑是否把当前的PosH投影到 light的view平面上,得到其坐标,然后找到成像贴图上的象素值,对这个问题我很模糊 |
|