OpenGL SuperSampling Anti-Aliasing?

安稳与你 提交于 2019-12-05 09:42:29

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.

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

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!