在办公室,我们正在使用旧的 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
完全超级采样也是可能的。正如上面评论中的 Andon 所建议的那样,您创建一个 FBO,其渲染目标是每个维度中窗口大小的倍数,最后对窗口进行缩小规模的位块传送。整个过程往往很慢并且使用大量内存,即使只有 2 倍。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)