OpenGL: Objects are smooth if normally drawn, but edged when rendering to FBO
Asked Answered
C

1

9

I have a problem with different visual results when using a FBO compared to the default framebuffer:

I render my OpenGL scene into a framebuffer object, because I use this for color picking. The thing is that if I render the scene directly to the default framebuffer, the output on the screen is quite smooth, meaning the edges of my objects look a bit like if they were anti-aliased. When I render the scene into the FBO and afterwards use the output to texture a quad that spans the whole viewport, the objects have very hard edges where you can easily see every single colored pixel that belongs to the objects.

Good:

dtizcto7.png

Bad:

wy7hg754.png

At the moment I have no idea what the reason for this could be. I am not using some kind of anti-aliasing.

System:
Fedora 18 x64
Intel HD Graphics 4000 and Nvidia GT 740M (same result)

Edit1:

As stated by Damon and Steven Lu, there is probably some kind of anti-aliasing enabled by the system by default. I couldn't figure out so far how to disable this feature.
The thing is that I was just curious why this setting only had an effect on the default framebuffer and not the one handled by the FBO. To get anti-aliased edges for the FBO too, I will probably have to implement my own AA method.

Cromlech answered 13/5, 2013 at 13:5 Comment(9)
This looks perfectly normal. You have probably enabled MSAA in the grasphic card's control panel (some setting like "override application" or "force always on"), which is why the render-to-screen looks antialiased. Rendering to a FBO does not use multisampling, unless you explicitly tell OpenGL to do so by adding multisample attachments.Ingenuity
@Damon: Answers. Post answers, not comments.Toccaratoccata
What's wrong with posting a comment? If you're so certain his comment is accurate and answers the question completely, post it yourself.Meningitis
@Damon: Thx, I thought of that too, but I the Intel Graphics relies on Mesa and the Nvidia card brings its own OpenGL implementation as far as I know. The consequence would be that this should effect only one of them. Edit: Is there a way to check whether AA is enabled or not?Cromlech
It must then be some setting your program or environment sets that enables AA on the frame buffer.Gooseflesh
Also notice how the shade of the background and cube are different. Gamma correction/sRGB conversion issues?Gooseflesh
@Steven Lu: I fixed the shading issue. There was an error in my fragment shader which did one calculation twice.Cromlech
Are you still unable to isolate the reason why non-FBO rendering is anti-aliased? Check anything render target related, anything in the drivers.Gooseflesh
I was searching for a while but couldn't find something usefull. The Intel driver seems to have nothing to tweak at all and the Nvidia driver is a bit buggy because of my attempt to use Linux and Nvidia Optimus together. That the scene is anti-aliased as default is not that problematic. I just thought it would be nice to have the FBO anti-aliased too. I'm working on this now.Cromlech
R
8

Once you draw your scene into custom FBO the externally defined MSAA level doesn't apply anymore.You must configure your FBO to have Multi-sample texture or render buffer attachments setting number of sample levels along the way.Here is a reference.

Riana answered 14/5, 2013 at 13:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.