Sign in to follow this  
ade-the-heat

FIXED ! urgent! simple shader multi text problem

Recommended Posts

I've got to do this by lunchtime (uk time) ! I can't get the second texture parameter to be read at all. Can anyone see what is wrong at all ? The shader is so simple it's untrue:
uniform samplerRect in0;
uniform samplerRect in1;
void main (void)
{
vec4  outTex0 = vec4(textureRect(in0, gl_TexCoord[0].st));
vec4  outTex1 = vec4(textureRect(in1, gl_TexCoord[1].st));
gl_FragData[0] = outTex0;
gl_FragData[1] = outTex1;
}



the texture written to by gl_FragData[1] always has the data from outTex0 (read from 'in0' texture). I've swapped textures over, used new textures etc and still I can't get the output outTex1 to have anything but outTex0. I also tried the below
 
In this case the data output is as expected, 1.2 in the first tex and 2.3 in the second tex.
gl_FragData[0] = vec4(1.2);
gl_FragData[1] = vec4(2.3);



So it must be the the multi tex call but it looks ok to me
For one texture input I use:
 glBegin(GL_QUADS);
    glTexCoord2f(xoffset, yoffset);
    glVertex2i(0, 0);

    glTexCoord2f(width, yoffset);
    glVertex2i((GLuint)width, 0);

    glTexCoord2f(width, height);
    glVertex2i((GLuint)width, (GLuint)height);

    glTexCoord2f(xoffset, height);
    glVertex2i(0, (GLuint)height);

 glEnd();

for two tex's I use:
  glActiveTexture(GL_TEXTURE0);
  glBindTexture(target,tex0);

  glActiveTexture(GL_TEXTURE1);
  glBindTexture(target,tex1);

glBegin(GL_QUADS);
    fglMultiTexCoord2f(GL_TEXTURE0, xoffset, yoffset);
    fglMultiTexCoord2f(GL_TEXTURE1, xoffset, yoffset);
    glVertex2i(0, 0);

    fglMultiTexCoord2f(GL_TEXTURE0, width, yoffset);
    fglMultiTexCoord2f(GL_TEXTURE1, width, yoffset);
    glVertex2i((GLuint)width, 0);

    fglMultiTexCoord2f(GL_TEXTURE0, width, height);
    fglMultiTexCoord2f(GL_TEXTURE1, width, height);
    glVertex2i((GLuint)width, (GLuint)height);

    fglMultiTexCoord2f(GL_TEXTURE0, xoffset, height);
    fglMultiTexCoord2f(GL_TEXTURE1, xoffset, height);
    glVertex2i(0, (GLuint)height);

    glEnd();




THE FIX WAS: GLint location = fglGetUniformLocation(m_shaders[shaderHandle].program, parameterName); fglUniform1i(location, tex); tex wants 0,1,2,3, and NOT the texture id [Edited by - ade-the-heat on May 25, 2007 5:24:09 AM]

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