   summing pixels (non-clamped)
  Hi,I am writing a program that needs to 'add' pixels to the ones already in the frame-buffer. I tried using the blending operations (GL_ONE,GL_ONE) but that causes a 0-1 clamping despite rendering to a floating-point texture.Theoretically, it should be possible to do this in a shader, but I couldnt find a way to read the value already in the framebuffer via a shader. I can only write to it.Any help would be appreciated.Kind regards,Sajid   
  If you are using vertex color to add the values, the color values would be clamped to [0,1] by default.You can turn it off easily by calling the following command.glClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, GL_FALSE);   ;  That doesnt work either, i.e, still clamps the results. I think the problem is that the blend occurrs in the fixed-functionality pipeline, which by default always clamps values.   ;  If you use shaders and render to a floating point texture using GL_ONE/GL_ONE it will be added without clamping through the entire range ( outside 0-1 ). Are you sure you are using a floating point texture?   ;  Indeed I am. Here is the code that creates the floating point render target:  // Setup our FBOglBindFramebuffer(GL_FRAMEBUFFER, FBO+level);// Create the render buffer for depthglBindRenderbuffer(GL_RENDERBUFFER, FBODepthBuffer+level);glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, newwidth, newheight );// Now setup a texture to render toglBindTexture(GL_TEXTURE_2D, FBOImage+level);glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F,  newwidth, newheight, 0, GL_RGBA, GL_FLOAT, /*tempFloatTexture*/NULL);glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);   // And attach it to the FBO so we can render to itglFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, FBOImage+level, 0);It clamps as soon as I do the blending operation (GL_ONE,GL_ONE). The way I check it is by rendering a quad onto the screen, and attaching the previous floating point texture to it, and reading the values. They are always between 0 and 1.Possibly a graphic-card bug?   ;  How exactly you read the values? You output them to the screen as an image? Simply asking since there's no other way to visualize a texture on the GPU. If you do so though then the output will be of course clamped to 0-1 but this is the visualization which is clamped not the original texture. Best way is to read back the texture right after rendering using glGet* into a float array with the same size. If this one then contains only 0-1 values then something is indeed wrong.   ;  RPTD,If I create a floating point texture, and assign it values beyond 0-1 (i tried 1.6 and -1.6) and attach it to a quad, render it, and try reading the values in a shader, the values are not clamped. I can, indeed, in the shader read back values beyond 1.0 or less than 0.0. Granted they 'look' totally white or totally black respectively, but using an 'if' statement, i can verify that I do indeed receive floating values in the texture.When I apply the blend, and set the render target to a floating point texture,  I expect it to add those values to the texture without clamping. I read the texture back again using exactly the same procedure, i.e, by applying it to a quad, rendering it, and trying to read the values via a shader. The values should not be clamped, no? But they still are. My 'hunch' is that since the 'blend' occurrs in fixed functionality, it will always clamp 0 to 1.Thanks for the suggestion about testing the texture values before rendering. I will try that, even though I have a feeling I will be dissapointed. Kind regards,Sajid   ;  If I try passing unclamped colours via glVertexm they get clamped, despite telling the glClampColor function not to. I guess the only way to really get full floating point addition is to use several floating point textures, and avoid adding via blend...   ;Quote:Original post by FugitiveIf I try passing unclamped colours via glVertexm they get clamped, despite telling the glClampColor function not to. I guess the only way to really get full floating point addition is to use several floating point textures, and avoid adding via blend...Nope, the blend function works perfectly with floating point screen buffer.  I have done that for quite a while already.  There must be something wrong in your program.   ;Quote:Original post by FugitiveWhen I apply the blend, and set the render target to a floating point texture, I expect it to add those values to the texture without clamping.What is the "those values" supposed to mean there?  What have you draw for your adding purpose exactly?  A textured quad?  A quad with color only?  Or... 3D model?[Edited by - ma_hty on June 8, 2009 11:45:03 AM]