多视图视锥体裁剪
函数 gluPerspective() 可用于设置近 Z 轴和远 Z 轴剪裁平面。
我想绘制一个在某个远 Z 平面剪裁的场景, 并在该 Z 平面之外绘制另一个场景。 是否可以每帧进行两次剪辑?
The function gluPerspective() can be used to set near Z and far Z clipping planes.
I want to draw a scene clipped at a certain far Z plane,
and draw another scene beyond this Z plane.
Is it possible to do this clipping twice per frame?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您没有理由不能这样做。
只需设置第一个透视图,绘制第一个场景,然后设置第二个透视图并绘制第二个场景,所有这些都在同一帧的绘图内。
这通常称为多通道渲染。
There's no reason you shouldn't be able to do this.
Simply setup the first perspective, draw the first scene and then setup the second perspective and draw the seconds scene, all within the drawing of the same frame.
This is generally referred to as multi-pass rendering.
您可能需要先绘制最远的场景,然后在绘制最近的场景之前执行
glClear(GL_DEPTH_BUFFER_BIT);
。You might need to do a draw the farthest scene first and do a
glClear(GL_DEPTH_BUFFER_BIT);
before you draw the nearest scene.一种可能性是为场景分配不同的深度范围。 一些伪代码是:
您必须设置投影矩阵才能对近/远场景执行正确的剪辑。
需要分配深度范围以防止深度缓冲区“合并”两个渲染。
A possibility is to assign different depth ranges for the scenes. Some pseudo code would be :
You have to setup your projection matrices to perform the proper clipping for the near / far scenes.
The depth ranges assignment is needed to prevent the depth buffer to 'merge' both renderings.