Skip to main content
GameDev.net gamedev.net
🔒 Locked

Problem of GLSL Multitexturing

Started by tvsct456 Sep 4, 2012 at 3:06 AM 2 replies 2.3k views
Original Post
tvsct456
tvsct456
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!
Ashaman73
Ashaman73
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 ?
V-man
V-man
http://www.opengl.org/wiki/GLSL_:_common_mistakes#glGetUniformLocation
and
http://www.opengl.org/wiki/GLSL_:_common_mistakes#Enable_Or_Not_To_Enable
tvsct456
tvsct456

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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.