Sign in to follow this  
Renaissanz

Texture combiner within an FBO (solved)

Recommended Posts

Hi guys, I'm trying to use multitexturing/combiners within an FBO. I need to interpolate between a pre-render texture copy and a post-render texture copy. Here's some psuedo code for how I obtain the two textures and multitexture: loop from 0 to 19 bind fbo 0 bind rbo 0 bind texture 0 if loop is 0 generate blank texture glTexImage2D else glCopyTexImage2D render geometry bind texture 1 glCopyTexImage2D bind fbo 0 to 0 render said geometry bind fbo 1 bind rbo 1 multitexture/combine onto geometry readback loop Here's the actual code for how I do the multitexturing in FBO 1:
glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, m_uiBeforeTexture);
//==========================================================
glActiveTexture(GL_TEXTURE1);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, m_uiAfterTexture);
//==========================================================
GLfloat constAlpha[] = {0.0f, 0.0f, 0.0f, (19.0f - (GLfloat)i) / 19.0f};
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constAlpha);

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE);

glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_TEXTURE);
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);

glTexEnvf(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PREVIOUS);
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);

glTexEnvf(GL_TEXTURE_ENV, GL_SRC2_RGB, GL_CONSTANT);
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA);
//==========================================================

float aspect = (GLfloat)viewportWidth/(GLfloat)viewportHeight;

glBegin(GL_QUADS);

    glNormal3f(0., 0., 1.);

    glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 0.0f);
    glMultiTexCoord2f(GL_TEXTURE1, 0.0f, 0.0f);
    glVertex3f(-1*aspect, -1., 0.0);

    glMultiTexCoord2f(GL_TEXTURE0, 1.0f, 0.0f);
    glMultiTexCoord2f(GL_TEXTURE1, 1.0f, 0.0f);
    glVertex3f( 1*aspect, -1., 0.0);

    glMultiTexCoord2f(GL_TEXTURE0, 1.0f, 1.0f);
    glMultiTexCoord2f(GL_TEXTURE1, 1.0f, 1.0f);
    glVertex3f( 1*aspect,  1., 0.0);

    glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 1.0f);
    glMultiTexCoord2f(GL_TEXTURE1, 0.0f, 1.0f);
    glVertex3f(-1*aspect,  1., 0.0);

glEnd();


When I read back and dump it to a file, I get black. I've tested the dump to file function successfully, so I'm sure it's not that. Anybody know if what I'm trying to do is even possible? Thanks in advance [Edited by - Renaissanz on July 23, 2006 5:24:39 PM]

Share this post


Link to post
Share on other sites
Well, I guess I answered my own question. NO, it does not appear to be possible to to use texture combiners within an FBO. I had all of my TexEnv stuff set up correctly, but when I render the quad within the FBO, the readback was blank. However, when I rendered the combiner onto a quad within the main frame buffer, the combiner worked, and I got a an interpolated texture a quad. Lesson learned.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this