Problem of GLSL Multitexturing

Started by
2 comments, last by tvsct456 11 years, 7 months ago
Hey guysbiggrin.png
Im working on a water effect demo these days, and there is a problem that the fragment shader cant load the normal texture for the water surface ( the reflection texture works fine) .
Im sure that both the vertex shader and fragment shader are correct because they work fine in the ShaderMaker. So I guess the problem comes from my C++ codes, and here are the codes:

_waterShader->Use();
glActiveTexture(GL_TEXTURE1);
glEnable(GL_TEXTURE_2D);
_ReflectionTex->Bind();
glUniform1i( glGetUniformLocation( _waterShader->GetHandler(),"reflectTex"),1);

glActiveTexture(GL_TEXTURE2);
glEnable(GL_TEXTURE_2D);
_WaterNorTex->Bind();
glUniform1i( glGetUniformLocation( _waterShader->GetHandler(),"bumpTex"),2);

// uniform values
...
// draw a plane
...

What's wrong with my codes? blink.png
sorry for my poor English
Thanks!
Advertisement
There is nothing much to say. You have many API calls hidden behind Use() and Bind() and we don't have the shader at hands.
Why do you think the normal map is not loading ? Maybe your lighting calculation is wrong ?

How about some error checking ?

Does
[source lang="cpp"]glGetUniformLocation( _waterShader->GetHandler(),"bumpTex")[/source]
actually resolve to a valid value ?
http://www.opengl.org/wiki/GLSL_:_common_mistakes#glGetUniformLocation
and
http://www.opengl.org/wiki/GLSL_:_common_mistakes#Enable_Or_Not_To_Enable
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

There is nothing much to say. You have many API calls hidden behind Use() and Bind() and we don't have the shader at hands.
Why do you think the normal map is not loading ? Maybe your lighting calculation is wrong ?

How about some error checking ?

Does
[source lang="cpp"]glGetUniformLocation( _waterShader->GetHandler(),"bumpTex")[/source]
actually resolve to a valid value ?


http://www.opengl.or...UniformLocation
and
http://www.opengl.or...r_Not_To_Enable


I found where the problem was...I used GL_RGBA instead of GL_RGB in glTexImage2D and everyting shew up..
Thank you

This topic is closed to new replies.

Advertisement