Using Accumulation Buffer

I’d like to use the accumulation buffer in my OpenGL implamentation, but somehow it is messing up my rendered image when I try to initialize the accumulation buffer.

Previously, the attributes I pass to aglChoosePixelFormat() were AGL_RGBA,AGL_DOUBLEBUFFER,AGL_DEPTH_SIZE,1,AGL_NONE. With this configuration my rendered image looks fine. But when I use AGL_RGBA,AGL_DOUBLEBUFFER,AGL_DEPTH_SIZE,1,AGL_ACCUM_RED_SIZE,8,AGL_ACCUM_GREEN_SIZE,8,AGL_ACCUM_BLUE_SIZE,8,AGL_ACCUM_ALPHA_SIZE,8,AGL_NONE my rendered image appears very blue like it’s ignoring one or more of the color componenets.

Am I doing something wrong? What’s the problem? Thanks for any help.

Jason

By looking at my memory in debug mode, I notice that OpenGL is writing a value of ‘FF’ (or 255) in the last component of each pixel, which is my blue component (this is why my rendered image seems bluer). My theory is that OpenGL thinks the last component of each pixel is the alpha component and for some reason when I enable the accumulation buffer, it renders a 255 for that component for every pixel instead of rendering what it normally does if I don’t have an accumulation buffer enabled (which is what I want). I need to use the accumulation buffer with a pixel format that won’t set any of the components to a specific value of ‘FF’ (or any specific value for that matter).

Does this mean that there is no RGBA pixel format that can be used if an accumulation buffer is enabled, and it’s using an RGB pixel format? Any ideas or suggestions?

GL_RGBA means a 32 bits value of 0x11223344 will have r=11,g=22,b=33 and a=44
if you want to use the ‘traditional’ ordering for 32 bits pixels on the mac, you need to use GL_ARGB

Originally posted by Michel:
GL_RGBA means a 32 bits value of 0x11223344 will have r=11,g=22,b=33 and a=44
if you want to use the ‘traditional’ ordering for 32 bits pixels on the mac, you need to use GL_ARGB

Unfortunately there is no GL_ARGB (at least to my knowledge). Regardless, like I said, the problem isn’t the ordering of components (I’ve been able to use AGL_RGBA and GL_RGBA mode thoughout my program so far because it appears to only make a difference when I do something like glClearColor() the alpha component is first rather then the red component), it is the fact that the last color component was being assigned a constant ‘FF’ value. The fix to this problem was to add AGL_ALPHA_SIZE,8 to my aglChoosePixelFormat attributes because for some reason it must not be implied when a accumulation buffer is used. The next problem is that whatever pixel format this is choosing is extremely slow compared to the one it was using that didn’t have an accumulation buffer. Thank you for your reply Michel.

Are you sure it isnt just that you havent asked for enough accumulation buffer? What you may be perceiving as increased blueness could just be a result of many successive steps of quantization and loss of precision. Make sure you get an accumulation buffer with at leats 16 bits of precision - rather weirdly I had to ask for AGL_ACCUM_RED_SIZE, 64 before I got an accumulation buffer with 16 bits per component, once I had that the effects I was seeing (including increased blueness due to quantization) just disappeared.

Originally posted by Phil Atkin:
Are you sure it isnt just that you havent asked for enough accumulation buffer? What you may be perceiving as increased blueness could just be a result of many successive steps of quantization and loss of precision. Make sure you get an accumulation buffer with at leats 16 bits of precision - rather weirdly I had to ask for AGL_ACCUM_RED_SIZE, 64 before I got an accumulation buffer with 16 bits per component, once I had that the effects I was seeing (including increased blueness due to quantization) just disappeared.

Yes I’m sure the blueness was occuring because the blue component was being set to ‘FF’ for every pixel. When I declared AGL_ALPHA_SIZE,8 and AGL_ACCUM_ALPHA_SIZE,8 my blue component was no longer set to ‘FF’ (keep in mind the OpenGL alpha component is actually my blue component).

Now that the colors looks correct, I have another problem. I’m seeing color banding throughout my rendered image, and I believe it is happening because I my accumulation buffer needs to be larger than 8. For example, if I have an image that is white on the left and gradient to black on the right in my read buffer, and I call glAccum(GL_ACCUM,0.25) four times, then glAccum(GL_RETURN,1.0) the image that is returned is not a smooth gradient from white to black like the orginal image. Instead it is a gradient that is banded into sections. This is with a read buffer and accumulation buffer with 8 bits per component. I have a feeling my accumulation buffer needs to be 32 bits per component for the final image to look exactly like the original image. Is my thinking correct?

You will only need 16 bits per component - that would allow accumulation of up to 256 images with all images weighted identically. Trying to get a deep accumulation buffer proved difficult - I couldnt work out how to control the depth of the accumulation buffer in GLUT - you can ask GLUT for an accumulation buffer, it’s not clear how of even if you can ask it for a specific depth of accumulation buffer - so I have had to move my app to AGL in order to do it.

Originally posted by Phil Atkin:
You will only need 16 bits per component - that would allow accumulation of up to 256 images with all images weighted identically. Trying to get a deep accumulation buffer proved difficult - I couldnt work out how to control the depth of the accumulation buffer in GLUT - you can ask GLUT for an accumulation buffer, it’s not clear how of even if you can ask it for a specific depth of accumulation buffer - so I have had to move my app to AGL in order to do it.

I initialized my accumulation buffer component sizes from 8 to 16, and it eliminated the banding problem. Thanks for the info.

My implementation texture maps an image onto an object. The next problem I’m seeing is what seems to be the object’s wireframe bleeding through to the texture maped surface. For example, if I render a texture mapped image onto a sphere, I can see a yellow highlight on the sphere’s texture map where the wireframe of the sphere is located. This only happens when I’m using the accumulation buffer for jittering. Any ideas?

Originally posted by jason_shaffer:
[b] I initialized my accumulation buffer component sizes from 8 to 16, and it eliminated the banding problem. Thanks for the info.

My implementation texture maps an image onto an object. The next problem I’m seeing is what seems to be the object’s wireframe bleeding through to the texture maped surface. For example, if I render a texture mapped image onto a sphere, I can see a yellow highlight on the sphere’s texture map where the wireframe of the sphere is located. This only happens when I’m using the accumulation buffer for jittering. Any ideas?[/b]

Update: The problem with the wireframe bleeding through to the texture map was solved by getting rid of the opengl nicest hints and line/polygon smooth calls (which is ok now that I’m doing scene antialiasing with jittering and the accumulation buffer).

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.