Sign in to follow this  

Problem of GLSL Multitexturing

This topic is 1960 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys[img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img]
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? [img]http://public.gamedev.net//public/style_emoticons/default/blink.png[/img]
sorry for my poor English
Thanks! Edited by 50CoL

Share this post


Link to post
Share on other sites
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 ?

Share this post


Link to post
Share on other sites
http://www.opengl.org/wiki/GLSL_:_common_mistakes#glGetUniformLocation
and
http://www.opengl.org/wiki/GLSL_:_common_mistakes#Enable_Or_Not_To_Enable

Share this post


Link to post
Share on other sites
[quote name='Ashaman73' timestamp='1346735516' post='4976311']
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 ?
[/quote]
[quote name='V-man' timestamp='1346812325' post='4976660']
[url="http://www.opengl.org/wiki/GLSL_:_common_mistakes#glGetUniformLocation"]http://www.opengl.or...UniformLocation[/url]
and
[url="http://www.opengl.org/wiki/GLSL_:_common_mistakes#Enable_Or_Not_To_Enable"]http://www.opengl.or...r_Not_To_Enable[/url]
[/quote]

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

Share this post


Link to post
Share on other sites
Sign in to follow this