OpenGL super 采样抗锯齿?

标签 opengl glx motif

在办公室,我们正在使用旧的 GLX/Motif 软件,该软件使用 OpenGL 的 AccumulationBuffer 来实现抗锯齿以保存图像。
我们的问题是 Apple 从其所有驱动程序中删除了 AccumulationBuffer(从 OS X 10.7.5 开始),并且一些 Linux 驱动程序(如 Intel HDxxxx)也不支持它。

然后我想更新软件的抗锯齿代码,使其与大多数实际操作系统和 GPU 兼容,同时保持生成的图像和以前一样漂亮(因为我们需要它们用于科学出版物)。

SuperSampling 似乎是最古老、质量最好的抗锯齿方法,但我找不到任何不使用 AccumulationBuffer 的 SSAA 示例。有没有一种不同的方式来使用 OpenGL/GLX 实现 SuperSampling ???

最佳答案

您可以使用 FBO 来实现最有可能与累积缓冲区一起使用的相同类型的抗锯齿。该过程几乎相同,除了您使用纹理/渲染缓冲区作为“累积缓冲区”。您可以为该过程使用两个 FBO,也可以更改单个渲染 FBO 的附加渲染目标。

在伪代码中,使用两个 FBO,流程大致如下所示:

create renderbuffer rbA
create fboA (will be used for accumulation)
bind fboA
attach rbA to fboA
clear

create texture texB
create fboB (will be used for rendering)
attach texB to fboB
(create and attach a renderbuffer for the depth buffer)

loop over jitter offsets
    bind fboB
    clear
    render scene, with jitter offset applied

    bind fboA
    bind texB for texturing
    set blend function GL_CONSTANT_ALPHA, GL_ONE
    set blend color 0.0, 0.0, 0.0, 1.0 / #passes
    enable blending
    render screen size quad with simple texture sampling shader
    disable blending
end loop

bind fboA as read_framebuffer
bind default framebuffer as draw framebuffer
blit framebuffer

完全 super 采样也是可能的。正如 Andon 在上面的评论中建议的那样,您创建了一个 FBO,其渲染目标是每个维度中窗口大小的倍数,最后对您的窗口进行缩小 blit。整个过程往往很慢并使用大量内存,即使只有 2 倍。

关于OpenGL super 采样抗锯齿?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22227871/

相关文章:

c - 更改文本字体时标签标题被剪切(Open Motif 2.3.1)

c++ - 在 OpenGL 中创建并实现元球皮肤系统

opengl - 如何在 OpenGL 中提供自定义插值技术来填充三角形

c - 找不到 glXCreateContextAttribsARB(在 OpenGL 4.2 驱动程序、GLX 1.4 上)

c++ - 如何杀死 XtAppMainLoop (Motif)?

c - MOTIF 编译错误/X11/intrinsic.h 丢失

c++ - OpenGL翻译glm右侧还是左侧?

C++ OpenGL 如何从四元数获取旋转 x,y,z

OpenGL代码未运行: OpenGL GLX extension not supported by display

c - glXSwapbuffers 似乎没有交换(?)