FBO - Render to Texture and Blending

导读:
  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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值