导读:
I am working on GeForce 6800 GT and using Cg for shaders.
I am using a multi-pass rendering (render-to-texture) using FBO. In first compuatation pass, I render to Texture1 and in the second pass I want to use the values computed in the first pass (as a texture in the fragment shader) and render into a second texture (Texture2).
I switch between the textures, by simply attaching the texture to the FBObefore rendering (computing). I am using blendingwhile rendering (see below in the code) as my computation needs it.
Code:
//Enable Blending
glBlendFunc (GL_ONE, GL_ONE);
glEnable (GL_BLEND);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_TEXTURE_RECTANGLE_EXT,Texture1, 0);
Computation1() //Render into Texture1
//Read back texture 1
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
glReadPixels(0, 0, texSize, texSize,textureParameters.texFormat,GL_FLOAT,data);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_TEXTURE_RECTANGLE_EXT,Texture2, 0);
Computation2() //Texture Lookup using Texture 1, and render into Texture2
//Disable Blending
glDisable (GL_BLEND);
Rendering works fine (in the first pass) and the results I read back in between the two computation passes show correct results (even when the blendingis on), which means that the Computation1() is correctly done.
When I lookup this texture (Texture1 - rendered in Computation1()), in a fragment shader in the Computation2(), however, I get all zero values if the blendingis turned on. If the blendingis disabled, the texture can be read properly (and correctly) in the Computation2().
This leads me to believe that, if blendingis enabled, texture readback can
be a problem. Is this true or am I missing something ?
Thank you!
本文转自
http://www.gpgpu.org/forums/viewtopic.php?p=10989&sid=059c0a431529b00258e21a01f925daac
I am working on GeForce 6800 GT and using Cg for shaders.
I am using a multi-pass rendering (render-to-texture) using FBO. In first compuatation pass, I render to Texture1 and in the second pass I want to use the values computed in the first pass (as a texture in the fragment shader) and render into a second texture (Texture2).
I switch between the textures, by simply attaching the texture to the FBObefore rendering (computing). I am using blendingwhile rendering (see below in the code) as my computation needs it.
Code:
//Enable Blending
glBlendFunc (GL_ONE, GL_ONE);
glEnable (GL_BLEND);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_TEXTURE_RECTANGLE_EXT,Texture1, 0);
Computation1() //Render into Texture1
//Read back texture 1
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
glReadPixels(0, 0, texSize, texSize,textureParameters.texFormat,GL_FLOAT,data);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_TEXTURE_RECTANGLE_EXT,Texture2, 0);
Computation2() //Texture Lookup using Texture 1, and render into Texture2
//Disable Blending
glDisable (GL_BLEND);
Rendering works fine (in the first pass) and the results I read back in between the two computation passes show correct results (even when the blendingis on), which means that the Computation1() is correctly done.
When I lookup this texture (Texture1 - rendered in Computation1()), in a fragment shader in the Computation2(), however, I get all zero values if the blendingis turned on. If the blendingis disabled, the texture can be read properly (and correctly) in the Computation2().
This leads me to believe that, if blendingis enabled, texture readback can
be a problem. Is this true or am I missing something ?
Thank you!
本文转自
http://www.gpgpu.org/forums/viewtopic.php?p=10989&sid=059c0a431529b00258e21a01f925daac
本文探讨了在使用OpenGL和Cg着色器进行多通道渲染时遇到的问题,特别是当启用混合功能时,在第二个渲染通道中无法正确读取第一个通道渲染的纹理数据的现象。文章详细介绍了作者的调试过程及发现的问题。
603

被折叠的 条评论
为什么被折叠?



