damma
06-09-2008, 03:47 PM
I have a texture attached to a framebuffer object, say to color attachment #0.
glActiveTextureARB( GL_TEXTURE2_ARB );
glBindTexture(GL_TEXTURE_RECTANGLE_NV, textureid[0]);
glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, GL_FLOAT_RGBA32_NV, W, H, 0, GL_RGBA, GL_FLOAT, NULL);
gpuSortFbo = new FramebufferObject ();
gpuSortFbo->Bind();
gpuSortFbo->AttachTexture(GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_NV, textureid[0]);
gpuSortFbo->IsValid();
FramebufferObject::Disable();
One of my shaders puts the particle positions(x,y,z,w) into textureid[0]. Now I need to calculate for each position, the distance from the eye. But the distance calculated is a single value as opposed to the x,y,z,w of the particle position. Currently what I am doing is that I write the same value (distance calculated) for the x,y,z,w into another texture.
Is there a way I can reduce these 4 values to a single value on the gpu itself ?
glActiveTextureARB( GL_TEXTURE2_ARB );
glBindTexture(GL_TEXTURE_RECTANGLE_NV, textureid[0]);
glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, GL_FLOAT_RGBA32_NV, W, H, 0, GL_RGBA, GL_FLOAT, NULL);
gpuSortFbo = new FramebufferObject ();
gpuSortFbo->Bind();
gpuSortFbo->AttachTexture(GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_NV, textureid[0]);
gpuSortFbo->IsValid();
FramebufferObject::Disable();
One of my shaders puts the particle positions(x,y,z,w) into textureid[0]. Now I need to calculate for each position, the distance from the eye. But the distance calculated is a single value as opposed to the x,y,z,w of the particle position. Currently what I am doing is that I write the same value (distance calculated) for the x,y,z,w into another texture.
Is there a way I can reduce these 4 values to a single value on the gpu itself ?