OpenGL 抗锯齿和背景四边形

发布于 2024-08-12 10:53:24 字数 751 浏览 2 评论 0原文

我正在 3D 场景后面绘制背景,其按预期工作(代码如下)。我还使用累积缓冲区对场景进行抗锯齿处理(红皮书第 10 章)。

...通过抖动和绘制图像的代码循环几次(例如,n)(抖动是将图像移动到稍微不同的位置),使用

glAccum(GL_ACCUM, 1.0/n)

累积数据,最后调用< /em>

glAccum(GL_RETURN, 1.0)

但是,我不想对背景进行反锯齿。问题在于,使用 GL_RETURN 调用 glAccum 会复制(覆盖)颜色缓冲区中的值(而不是使用深度测试和混合函数等)来屏蔽写入颜色缓冲区的值。

如何在对 3D 场景进行抗锯齿之前或之后绘制背景,以便背景看起来就像在没有抗锯齿的情况下绘制 3D 场景时一样?


 // Draw the background.

 glMatrixMode GL.GL_PROJECTION
 glLoadIdentity

 glMatrixMode GL.GL_MODELVIEW
 glLoadIdentity

 glPolygonMode GL_FRONT_AND_BACK, GL_FILL

 glDisable glcDepthTest

   glBegin bmQuads

     // Call glColor and glVertex here.

   glEnd

 glEnable glcDepthTest

I'm drawing a background behind my 3D scene which works as expected (code below). I'm also anti-aliasing the scene using the accumulation buffer (chapter 10 of the red book).

...loop several times (say, n) through code that jitters and draws the image (jittering is moving the image to a slightly different position), accumulating the data with

glAccum(GL_ACCUM, 1.0/n)

and finally calling

glAccum(GL_RETURN, 1.0)

However, I do not want to anti-alias the background. The problem is that calling glAccum with GL_RETURN copies (overwrites) the values in the color buffer (rather than using the depth test and blend functions, etc) to mask the values being written to the color buffer.

How can I draw the background before or after anti-aliasing the 3D scene so that the background looks just like it does when I draw the 3D scene without anti-aliasing?


 // Draw the background.

 glMatrixMode GL.GL_PROJECTION
 glLoadIdentity

 glMatrixMode GL.GL_MODELVIEW
 glLoadIdentity

 glPolygonMode GL_FRONT_AND_BACK, GL_FILL

 glDisable glcDepthTest

   glBegin bmQuads

     // Call glColor and glVertex here.

   glEnd

 glEnable glcDepthTest

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

儭儭莪哋寶赑 2024-08-19 10:53:24

如果您只是追求外观,而不是寻求渲染加速,请不要抖动背景。您的循环将绘制背景,应用抖动,然后绘制前景。由于背景永远不会移动,因此累积的背景将会出现锯齿。

If you're just after the appearance, and not looking for a rendering acceleration, don't jitter the background. Your loop would draw the background, apply the jitter, then draw the foreground. Since the background never moves, the accumulated background would be aliased.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文