PDA

View Full Version : 128 bit color



maximian
03-08-2005, 08:21 AM
Okay, I really need to use this feature. I did a search on this forum, no response. I googled, a couple of different perms of these terms. Nothing but marketing papers and commercials. Is there an API in opengl, that will expose the functionality.

Do I just request a
128 bit color buffer, in my PIXELFORMATDESCRIPTOR.

I tried on my GFX 5600, and nada.

Thanks.

NitroGL
03-08-2005, 09:22 AM
Pbuffer only, frame buffers can't have higher precision yet. Also, you can only get a floating point pixel format with the ARB_pixel_format extension.

olmeca
05-03-2005, 12:57 PM
Hi,
I have setup now the floating point pbuffer ( thanks to java cool dude) and now I want to check the values with ( glReadPixels ). I draw a rectangle with glColor3f( 10.0, 0.0, 0.0 ), but the values I get from the Pbuffer are still clamped. What am I doing wrong?
thx, Benjamin

Matt Zamborsky
05-03-2005, 01:06 PM
to: maximian

On GF FX cards you must use NV_float_buffer in conjuction with ARB_texture_rectangle to get this kind of texture. Fortunately you can forget to use pbuffers and go to EXT_framebuffer_object which support these extensions too. For example use go to thread about OpenGL 2.0, NV forceware 75.90, and FBO(I dont remember the exatly name) and there is discused the problematic of framebuffer_object with floating color buffer.

to olmeca:
Are you using ATI_pixel_format_float ? Go to spec and read about GL_ARB_color_buffer_float, which may help you with clamping problems.

olmeca
05-03-2005, 01:18 PM
yes i know, i already initalized it that way (btw its an ATI card). But I want to know if there is a way, where I directly enter color values, outside the usual clamp range, and get them back be rereading the buffer (with glReadPixels or something equivalent ).

Java Cool Dude
05-03-2005, 08:11 PM
Neither floating-point nor signed integer values are clamped to the range [0,1] before updating the current color. However,color components are clamped to this range before they are interpolated or written into a color buffer.

Seems like you're gonna need a fragment program/shader to write your negative values into your PBuffer :)

olmeca
05-04-2005, 01:58 AM
Ok here is my little sample. Hopefully the Pbuffer things are self explaining.

this is the shader code:

void main(void){

gl_FragColor = vec4( 10.0, 10.0, 10.0, 1.0 );

}

this code writes the values (simple fragment shader):


void main(void){

gl_FragColor = vec4( 10.0, 10.0, 10.0, 1.0 );

}
void drawTest()
{

pBuffer[0]->useAsBuffer( WGL_BACK_LEFT_ARB );

glClearColor( 0.5, 0.5, 0.5, 0.0 );
glClear( GL_COLOR_BUFFER_BIT );

Shader *funcC = new Shader("func_lc");
funcC->install();
// draw things

glColor3f( 1.0, 0, 0 );
glBegin( GL_TRIANGLES );
{
glTexCoord2i( 0, 0 );
glVertex2f( -1.0f, -1.0f );

glTexCoord2i (1 , 0 );
glVertex2f( 1.0f, -1.0f );

glTexCoord2i ( 1, 1 );
glVertex2f( 1.0f, 1.0f );

}
glEnd();

funcC->uninstall();

pBuffer[0]->useAsTexture( WGL_BACK_LEFT_ARB );
renderSingleTexture();
pBuffer[0]->unbind( WGL_BACK_LEFT_ARB );

}

and this code reads the values back from the pbuffer (mbuffer is floating point array):




pBuffer[0]->useAsBuffer( WGL_BACK_LEFT_ARB );
glReadBuffer( GL_BACK );
glReadPixels( 0, 0, 512, 512, GL_LUMINANCE, GL_FLOAT, mbuffer );
pBuffer[0]->disable();

is this okay, or is it impossible to get the float values back that way? Its not that important to get the float values back, but I need to be sure, that the values stored in the pbuffer are unclamped floats.

olmeca
05-04-2005, 02:01 AM
sorry i somehow mixed the code tags up.

olmeca
05-04-2005, 02:05 AM
Hey. it works, here is the right way. It seems that i can't read Luminance values from rgb textures, or they get clamped. so here is the wrong way:

pBuffer[0]->useAsBuffer( WGL_BACK_LEFT_ARB );
glReadBuffer( WGL_BACK_LEFT_ARB );
glReadPixels( 0, 0, 512, 512, GL_LUMINANCE, GL_FLOAT, mbuffer );
pBuffer[0]->disable();and here is the right way:


pBuffer[0]->useAsBuffer( WGL_BACK_LEFT_ARB );
glReadBuffer( WGL_BACK_LEFT_ARB );
glReadPixels( 0, 0, 512, 512, GL_RGB, GL_FLOAT, mbuffer );
pBuffer[0]->disable();