Sign in to follow this  
irreversible

Render-to-texture different from render-to-framebuffer

Recommended Posts

irreversible    2860
I have my regular GUI code looking the way I expect it to. However, due to certain optimization requirements, I'm now trying to double buffer portions of my GL-drawn window controls. This has brought up an unexpected surprise - there are minor differences between the double buffered and the directly drawn graphics.

Attached are two images - the first one is the direct draw result and the second one is unscaled FBO output blitted into the frame buffer (a matching quad drawn in ortho mode). Images are captured via PrintScreen, not copied from the GPU. I've blown them up 400% (no interpolation) to accentuate the minuscule changes - notably the corners of the rects are visibly different, even at 100%.

The FBO target has filter mode set to GL_NEAREST for both min and max, it's a 32 bit non-float RGBA image (same as the frame buffer) and mipmaps are disabled.

It's hard to post code unless I know where to look as everything's neck-deep in a larger framework.

I'm probably missing something really obvious here so if anyone can point it out, that'd be awesome [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

Note - the one-pixel vertical blur on the right of the rects in the first image is due to a 0.1 subpixel shift to emulate slight antialiasing. Looks better at 100%.

[attachment=11216:gui1.png][attachment=11217:gui2.png]
[attachment=11220:gsl3.png]
Edit: added the third screenshot of a GL_LINEAR/GL_LINEAR target. Edited by irreversible

Share this post


Link to post
Share on other sites
Kaptein    2224
well, nearest doesn't interpolate any values
so, thats why its different.. the old image obviously had bilinear (cheap) interpolation [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img]
write quintic interpolation in your frag shader! or not, depending onwhat you need
lots of funky curves to make the pixels smooth.. but since its a pixel game, maybe not

please not that bilinear only looks like crap when you zoom in lots, like walking up to a mesh in a (any) first-person game Edited by Kaptein

Share this post


Link to post
Share on other sites
Kaptein    2224
ok clearly you have a megazoomed image, so no bilinear
but subpixel shift, i dont understand, you CANT get mixed colors with nearest unless you do it by hand in shaders
and make sure the screensize is at least an even number...

Share this post


Link to post
Share on other sites
Hodgman    51223
[quote name='irreversible' timestamp='1347395844' post='4979047']The FBO target has filter mode set to GL_NEAREST for both min and max[/quote]Is this regarding the step where you blit the FBO to the screen, or the step where you render your GUI into the FBO?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this