PDA

View Full Version : Poor rendering quality with FBOs



Luhtor
12-11-2007, 04:12 PM
I'm currently trying to use FBOs in a project using wxWidget. All works fine, but the rendering quality is very poor on my video card (X700 mobility) whereas I didn't see any problems when I tested the same program on two nvidia cards: GF6200 and GF7900.

This screen shows the results I have when I draw the datas contained in a FBO with wxWidget (in a wxBitmap).

The screen (http://img239.imageshack.us/my.php?image=forumscreeneq7.png)

Does anybody have an idea to explain this ?

Thx.

ZbuffeR
12-11-2007, 04:36 PM
Is that 256 color indexed mode ??
How do you setup your texture ? Do you request a precise color depth, such as 8 bit per color channel (best) ? If you let if to the default, you can have surprises like this.

Note the "GL_RGB8" instead of the deprecated GL_RGB :
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 512, 512, 0,
GL_RGB, GL_INT, NULL);

Luhtor
12-11-2007, 04:56 PM
I'm using RGBA color.

It's not a texture, it's a renderBuffer in which I just drawn a GL_QUAD with two colors (white and blue).
The gradient is computed automatically (by opengl) by interpolating the two colors. It's just 4 vertices rendered in 2D mode.

The depth buffer is desactivated with GL_DISABLE(GL_DEPTH_TEST);

The screen is what I got when I read the datas contained in the renderBuffer with:
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
glReadPixels(0, 0, m_width, m_height, GL_RGBA, GL_UNSIGNED_BYTE, m_pBuffer);

ZbuffeR
12-11-2007, 06:58 PM
And what about your OpenGL context setup ? which pixelformat do you request ?

V-man
12-11-2007, 09:29 PM
I would check the ATI control panel settings to see if there is anything that might cause this. If the catalyst control center is not installed, you might want to try to install that huge thing.
Can you post the code for your FBO setup?

-NiCo-
12-12-2007, 03:12 AM
I'm guessing your implementation uses 8-bit or 12-bit color buffers. In OpenGL dithering is enabled by default, so it will have a significant impact on performance for lower-end machines. Try disabling GL_DITHER.

PS. You may want to check where exactly the dithering is being applied (opengl/widget) by writing out your m_pBuffer data to an image on disk.

Cheers,
Nico

Luhtor
12-12-2007, 03:57 AM
I have no access to the source code right now. I'll post some code as soon as possible.

V-man: "If the catalyst control center is not installed, you might want to try to install that huge thing."
=> This software doesnt work fine on my labtop. I won't any more install that. I just did the minimal installation.

Nico: "PS. You may want to check where exactly the dithering is being applied (opengl/widget) by writing out your m_pBuffer data to an image on disk."
=> Exactly, in fact, the screen concerning my rendering (x700) is a picture saved to the disk directly from "m_pBuffer" since I wanted to be sure that this problem is not caused by wxWidget.

Trenki
12-12-2007, 04:27 AM
This looks very much like either your desktop is not 32 bit or your OpenGL context or you created Renderbuffer or RenderTexture have not 32 bit color. If you use a texture to render to you have to be sure to set GL_RGBA8 as internal format. If you are using a renderbuffer you would also have to make sure its internal format is GL_RGBA8. Also make sure your context is 32bits.

And maybe even though you request with this format some ATI driver settings might still give you some lower precision texture/renderbuffer. You could test this by explicitly querying the size of each component.


[ www.trenki.net (http://www.trenki.net) | vector_math (3d math library) (http://www.trenki.net/content/view/16/36/) | software renderer (http://www.trenki.net/content/view/18/38/) ]

Luhtor
12-12-2007, 06:21 AM
Here is the code used to create the FBOs:


// Creation of the FBO
glGenFramebuffersEXT(1, &m_GLframeBufferId);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_GLframeBufferId);

// Creation of the render buffer
glGenRenderbuffersEXT(1, &m_GLrenderBufferId);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_GLrenderBufferId);

// Render buffer attachment
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, m_GLrenderBufferId);

// Unbind
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

Next, when I know the size of the render buffer, I create it.


glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_GLframeBufferId);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_GLrenderBufferId);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA, _width, _height);

ASSERT(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_ EXT) == GL_FRAMEBUFFER_COMPLETE_EXT);

glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);

glViewport( 0, 0, _width, _height);

Next, I draw into the render buffer:


glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glDisable(GL_DITHER);
glClearColor(1.0f, 0.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);

// Dessin du fond
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0f, 1.0f, 0.0f, 1.0f);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glBegin(GL_QUADS);
glColor3f(0.949f, 0.953f, 0.957f);
glVertex2f(1.0f, 0.0f);
glVertex2f(0.0f, 0.0f);
glColor3f(0.735f, 0.888f, 0.972f);
glVertex2f(0.0f, 1.0f);
glVertex2f(1.0f, 1.0f);
glEnd();

And finally, I read the datas:


glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
glReadPixels(0, 0, m_width, m_height, GL_RGBA, GL_UNSIGNED_BYTE, m_pBuffer);

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);


As mentioned, I disable the GL_DITHER, and I obtain something better, but...
New screen (http://img68.imageshack.us/my.php?image=newscreenfoumhe4.png)

As specified on the screen, my desktop use 32bits colors.

Jan
12-12-2007, 07:13 AM
Which driver have you installed? I have a laptop with ATI and drivers up to Catalyst 7.9 work fine (using DHModTool to get it to install, at all). Using Catalyst 7.10 my computer goes crazy.

Jan.

ZbuffeR
12-12-2007, 07:14 AM
And your OpenGL context that you use with wxwidget ? How do you set it up ?

Mazy
12-12-2007, 07:20 AM
try with :

glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA8, _width, _height);

-NiCo-
12-12-2007, 08:22 AM
Like ZbuffeR already pointed out, how are you setting up your OpenGL context (glut/glfw/...)? Could be that the problem is there...

Nico

Luhtor
12-12-2007, 11:36 AM
I tried what Mazy suggested and it works well now.

Concerning GL_RGBA and GL_RGBA8, I found this note:

If you are willing to sacrifice some performance for improved visual quality, be sure to request GL_RGB8 or GL_RGBA8 internalformats. Otherwise you leave this decision in the hands of the person writing the driver, whose priorities may not match your own.

Thanks to all of you.

Jan: The last time I installed Catalyst, it worked for few months, after which I could any more access to the ati drivers options.