重新立体化后对整个场景进行抗锯齿处理

发布于 2024-09-13 06:32:53 字数 224 浏览 3 评论 0原文

我在编译 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 技术交流群。

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

发布评论

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

评论(2

转角预定愛 2024-09-20 06:32:53

GL_POLYGON_SMOOTH 不是执行全屏 AA (FSAA) 的方法。

不确定在这种情况下“效率不高”是什么意思,但它肯定不好看,因为它倾向于混合在网格中间(在三角形边缘)。

现在,关于 FSAA 和您的问题:

  1. 多重采样(又名 MSAA)是当今进行 FSAA 的标准方法。通常的替代方案是超级采样 (SSAA),即以更高分辨率进行渲染,并在最后进行下采样。它要贵得多。
  2. 该规范表示,从逻辑上讲,GL 保留一个样本缓冲区(4 倍像素缓冲区大小,对于 4xMSAA)和一个像素缓冲区(总共 5 倍内存),并且在每个样本写入样本缓冲区时更新像素缓冲区,其中包含样本缓冲区中当前 4 个样本的解析值(顺便说一句,这不称为混合。混合是在写入样本缓冲区时发生的情况,由glBlendFunc 等)。但在实践中,这并不是硬件中发生的情况。通常,您只写入样本缓冲区(并且硬件通常会尝试压缩数据),当需要使用它时,GL 实现将在使用发生之前立即解析完整的缓冲区。如果您实际上直接使用示例缓冲区,这也会有所帮助(那么根本不需要解析)。
  3. 我介绍了 SSAA 及其成本。最新的技术称为形态抗锯齿 (MLAA),目前正在积极研究中。这个想法是对完全渲染的图像进行后处理,并对看起来尖锐的边缘进行抗锯齿。最重要的是,它不是由 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:

  1. Multisampling (aka MSAA) is the standard way today to do FSAA. The usual alternative is super-sampling (SSAA), that consists in rendering at a higher resolution, and downsample at the end. It's much more expensive.
  2. The specification says that logically, the GL keeps a sample buffer (4x the size of the pixel buffer, for 4xMSAA), and a pixel buffer (for a total of 5x the memory), and on each sample write to the sample buffer, updates the pixel buffer with the resolved value from the current 4 samples in the sample buffer (It's not called blending, by the way. Blending is what happens at the time of the write into the sample buffer, controlled by 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).
  3. I covered SSAA and its cost. The latest technique is called Morphological anti-aliasing (MLAA), and is actively being researched. The idea is to do a post-processing pass on the fully rendered image, and anti-alias what looks like sharp edges. Bottom line is, it's not implemented by the GL itself, you have to code it as a post-processing pass. I include it for reference, but it can cost quite a lot.
惟欲睡 2024-09-20 06:32:53

我在这里写了一篇关于此的文章:在 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, NOT ChoosePixelFormat() 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.

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