重新立体化后对整个场景进行抗锯齿处理
我在编译 openGl 代码时遇到了问题。问题是我想实现全场景抗锯齿,但我不知道如何实现。我从 Nvidia 控制面板打开了强制抗锯齿功能,这才是我真正想要获得的效果。我现在用 GL_POLYGON_SMOOTH 来做。显然这样既不高效也不美观。以下是问题
1)我应该使用多重采样吗? 2)openGl 在管道中的哪个位置混合颜色以实现抗锯齿? 3)除了 GL_*_SMOOTH 和多重采样之外,还存在哪些替代方案?
I ran into an issue while compiling an openGl code. The thing is that i want to achieve full scene anti-aliasing and i don't know how. I turned on force-antialiasing from the Nvidia control-panel and that was what i really meant to gain. I do it now with GL_POLYGON_SMOOTH. Obviously it is not efficient and good-looking. Here are the questions
1) Should i use multi sampling?
2) Where in the pipeline does openGl blend the colors for antialiasing?
3) What alternatives do exist besides GL_*_SMOOTH and multisampling?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
GL_POLYGON_SMOOTH 不是执行全屏 AA (FSAA) 的方法。
不确定在这种情况下“效率不高”是什么意思,但它肯定不好看,因为它倾向于混合在网格中间(在三角形边缘)。
现在,关于 FSAA 和您的问题:
glBlendFunc
等)。但在实践中,这并不是硬件中发生的情况。通常,您只写入样本缓冲区(并且硬件通常会尝试压缩数据),当需要使用它时,GL 实现将在使用发生之前立即解析完整的缓冲区。如果您实际上直接使用示例缓冲区,这也会有所帮助(那么根本不需要解析)。GL_POLYGON_SMOOTH is not a method to do Full-screen AA (FSAA).
Not sure what you mean by "not efficient" in this context, but it certainly is not good looking, because of its tendency to blend in the middle of meshes (at the triangle edges).
Now, with respect to FSAA and your questions:
glBlendFunc
et al.). In practice, this is not what happens in hardware though. Typically, you write only to the sample buffer (and the hardware usually tries to compress the data), and when comes the time to use it, the GL implementation will resolve the full buffer at once, before the usage happens. This also helps if you actually use the sample buffer directly (no need to resolve at all, then).我在这里写了一篇关于此的文章:在 OpenGL 中获得平滑的大点< /a>
在创建 OpenGL 上下文之前、选择像素格式或视觉效果时,您必须指定 WGL_SAMPLE_BUFFERS 和 WGL_SAMPLES(或 XOrg/GLX 的 GLX 前缀)。
在 Windows 上,如果您想要具有扩展特征的像素格式,请确保使用
wglChoosePixelFormatARB()
,而不是来自 GDI/GDI+ 的ChoosePixelFormat()
。必须使用 ICD 驱动程序中的 wglGetProcAddress 查询 wglChoosePixelFormatARB,因此您需要事先创建一个虚拟 OpenGL 上下文。即使 OpenGL 上下文被破坏,WGL 函数指针仍然有效。WGL_SAMPLE_BUFFERS 是一个布尔值(1 或 0),用于切换多重采样。 WGL_SAMPLES 是您想要的缓冲区数量。通常为 2,4 或 8。
I wrote a post about this here: Getting smooth, big points in OpenGL
You have to specify WGL_SAMPLE_BUFFERS and WGL_SAMPLES (or GLX prefix for XOrg/GLX) before creating your OpenGL context, when selecting a pixel format or visual.
On Windows, make sure that you use
wglChoosePixelFormatARB()
if you want a pixel format with extended traits, NOTChoosePixelFormat()
from GDI/GDI+. wglChoosePixelFormatARB has to be queried with wglGetProcAddress from the ICD driver, so you need to create a dummy OpenGL context beforehand. WGL function pointers are valid even after the OpenGL context is destroyed.WGL_SAMPLE_BUFFERS is a boolean (1 or 0) that toggles multisampling. WGL_SAMPLES is the number of buffers you want. Typically 2,4 or 8.