Jump to content

  • Log In with Google      Sign In   
  • Create Account


Problem of GLSL Multitexturing


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 50CoL   Members   -  Reputation: 118

Like
0Likes
Like

Posted 03 September 2012 - 09:06 PM

Hey guysPosted Image
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? Posted Image
sorry for my poor English
Thanks!

Edited by 50CoL, 03 September 2012 - 09:08 PM.


Sponsor:

#2 Ashaman73   Crossbones+   -  Reputation: 6701

Like
0Likes
Like

Posted 03 September 2012 - 11:11 PM

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 ?

#3 V-man   Members   -  Reputation: 797

Like
0Likes
Like

Posted 04 September 2012 - 08:32 PM

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);

#4 50CoL   Members   -  Reputation: 118

Like
0Likes
Like

Posted 04 September 2012 - 09:13 PM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS