OpenGL SuperSampling抗锯齿? [英] OpenGL SuperSampling Anti-Aliasing?

查看:219
本文介绍了OpenGL SuperSampling抗锯齿?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

At office we're working with an old GLX/Motif software that uses OpenGL's AccumulationBuffer to implement anti-aliasing for saving images. Our problem is that Apple removed the AccumulationBuffer from all of its drivers (starting from OS X 10.7.5), and some Linux drivers like Intel HDxxxx don't support it neither.

然后,我想更新该软件的抗锯齿代码,以使其与大多数实际的OS和GPU兼容,但要使生成的图像像以前一样美丽(因为我们需要科学出版物才能使用它们).

Then I would like to update the anti-aliasing code of the software for making it compatible with most actual OSs and GPUs, but keeping the generated images as beautiful as they were before (because we need them for scientific publications).

SuperSampling似乎是最古老,质量最好的抗锯齿方法,但是我找不到不使用AccumulationBuffer的SSAA的任何示例.有没有其他方法可以在OpenGL/GLX中实现SuperSampling?

SuperSampling seems to be the oldest and the best quality anti-aliasing method, but I can't find any example of SSAA that doesn't use AccumulationBuffer. Is there a different way to implement SuperSampling with OpenGL/GLX ???

推荐答案

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

You can use FBOs to implement the same kind of anti-aliasing that you most likely used with accumulation buffers. The process is almost the same, except that you use a texture/renderbuffer as your "accumulation buffer". You can either use two FBOs for the process, or change the attached render target of a single render FBO.

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

In pseudo-code, using two FBOs, the flow looks roughly like this:

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倍.

Full super-sampling is also possible. As Andon in the comment above suggested, you create an FBO with a render target that is a multiple of your window size in each dimension, and in the end do a down-scaling blit to your window. The whole thing tends to be slow and use a lot of memory, even with just a factor of 2.

这篇关于OpenGL SuperSampling抗锯齿?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆