I am rendering a scene to FBO as my render target whose size is 8 times the size of the orignal screen in OpenGL. Now i wan to downsample the texture generated by FBO to the size of the screen so as to achieve spatial anti aliasing. How do i achieve the down sampling ? Please provide implementation details.
Note : If there is a better way of doing anti aliasing in FBOs please mention that too. I am trying to remove the aliasing in the image attached below.
-
2\$\begingroup\$ I feel sorry for your GPU \$\endgroup\$– hiddensunset4Nov 16, 2011 at 2:34
-
\$\begingroup\$ How are you drawing the grid? \$\endgroup\$– Nicol BolasNov 16, 2011 at 8:27
-
\$\begingroup\$ @NicolBolas a texture for 1X1 sqaure block and then I am mapping it all over the grid. \$\endgroup\$– snapeNov 16, 2011 at 8:34
1 Answer
Since your render target is exactly 8 times the size of the screen, I'd just use glGenerateMipmap
, after setting glTexParameteri(..., GL_TEXTURE_MAX_LEVEL, 3);
. Then, just blit or whatever from mipmap level 3, and you're done.
But really, you're wasting a lot of performance by not using multisampling+aniso. Supersampling won't give you much that you won't get with multisampling and anisotropic filtering, and your rendering will be that much faster for it.
-
\$\begingroup\$ You could also replace blitting with simply drawing a textured sprite that covers the screen area exactly, that also works for non power of 2 scaling. \$\endgroup\$ Nov 16, 2011 at 11:14