游戏开发论坛

 找回密码
 立即注册
搜索
查看: 3154|回复: 8

求助一个pssm里面的SetViewport的问题

[复制链接]

119

主题

1367

帖子

1393

积分

金牌会员

Rank: 6Rank: 6

积分
1393
发表于 2009-6-3 23:02:00 | 显示全部楼层 |阅读模式
我把视锥分割以后设置了新的viewport,这样导致z-buffer混乱了,渲染完场景后,我又想绘制了一个辅助视锥面,发现z-test失效了,上网找了找,有人估计碰到和我一样的问题,我找到一段这样的解释,但还不知道这个问题是如何解决的

原文地址:
http://forums.xna.com/forums/p/26112/142720.aspx


Setting a new viewport does not clear the depth buffer. However, even if the viewport is changed to use Z range 0.25..0.5, say, the entire range of values of the Z buffer is still tested. Thus, any value in the Z buffer that is lower than 0.25 will cause the depth test to fail. You cannot slice the depth buffer depth-wise like that, and use it for different lights, because the depth buffer can only store one value per pixel/texel.

If you keep the depth range 0..1 for all of the lights, and just move the viewport rectangle around, then that should work, though.

最后一段,难道说要去除viewport的范围设定?那分割渲染还有什么意义?

59

主题

984

帖子

1200

积分

金牌会员

Rank: 6Rank: 6

积分
1200
发表于 2009-6-4 02:13:00 | 显示全部楼层

Re:求助一个pssm里面的SetViewport的问题

不太明白你的意思,渲染sm时的z-buufer和正常渲染场景时的z-buffer是不一样的,怎么会影响呢?

119

主题

1367

帖子

1393

积分

金牌会员

Rank: 6Rank: 6

积分
1393
 楼主| 发表于 2009-6-4 08:36:00 | 显示全部楼层

Re:求助一个pssm里面的SetViewport的问题

是这样的,我绘制完整个场景以后,测试剪裁拍摄时想把视锥变换到场景中做视锥体的绘制,这样就不对了。

我也想到原因了,整个场景分割绘制了4次,每次深度设置都不一样,而视锥想在场景绘制完后,想按正常的0-1的深度去绘制一次,这样是做不到的。场景所有的对象都必须在分割的过程中进行绘制。

我上面的那个连接讨论的基本就是这个问题,简单的说就是在pssm 循环之外去按照正常的viewport绘制模型是不允许的

PS:clayman 奋战到2点多还不休息?身体要紧

119

主题

1367

帖子

1393

积分

金牌会员

Rank: 6Rank: 6

积分
1393
 楼主| 发表于 2009-6-4 11:06:00 | 显示全部楼层

Re: 求助一个pssm里面的SetViewport的问题

我已经搞定了,的却要把frustum的绘制放入到"分割"绘制过程中,单独拿出来是不对的。
得到了意外的效果,可以很明显的看到我的frustum被view划分为好几段的,我这个截图用的是3段划分

59

主题

984

帖子

1200

积分

金牌会员

Rank: 6Rank: 6

积分
1200
发表于 2009-6-4 15:34:00 | 显示全部楼层

Re:求助一个pssm里面的SetViewport的问题

呵呵 请教一下tonykee兄,pssm效率如何?
你渲染shadow map的时候是每个viewport一个pass
还是一个pass渲染所有viewport

我还没实现过pssm,感觉好像代价挺大-_-#

119

主题

1367

帖子

1393

积分

金牌会员

Rank: 6Rank: 6

积分
1393
 楼主| 发表于 2009-6-4 20:11:00 | 显示全部楼层

Re:求助一个pssm里面的SetViewport的问题

pssm效率基本还行,没有想象中那么低,每个viewport要一个pass的
所有的viewport一个pass搞不定,每个viewport的深度设置都不一样

227

主题

1794

帖子

1866

积分

金牌会员

Rank: 6Rank: 6

积分
1866
发表于 2009-6-4 20:14:00 | 显示全部楼层

Re:求助一个pssm里面的SetViewport的问题

和原始的sm相比效率肯定低不少
但是大场景的sm也没有效率与效果兼顾的方法

59

主题

984

帖子

1200

积分

金牌会员

Rank: 6Rank: 6

积分
1200
发表于 2009-6-5 00:44:00 | 显示全部楼层

Re:求助一个pssm里面的SetViewport的问题

With PSSMs generated in the preceding step, shadows can now be synthesized into the scene. In the multipass method, we need to synthesize the shadows immediately after rendering the shadow map.

For optimal performance, we should render the splits from front to back. However, some special considerations are needed. We need to adjust the camera's near and far planes to the respective split positions to provide clipping, because the objects in one split may also overlap other splits. However, as we modify the near and far planes, we are also changing the range of values written to the depth buffer. This would make the depth tests function incorrectly, but we can avoid this problem by using a different depth range in the viewport. Simply convert the split-plane positions from view space to clip space and use them as the new depth minimum and maximum.

45

主题

1163

帖子

1165

积分

金牌会员

Rank: 6Rank: 6

积分
1165
发表于 2010-3-2 15:48:00 | 显示全部楼层

Re:求助一个pssm里面的SetViewport的问题

学习了
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-6-12 17:43

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表