Jump to content
Eternal Lands Official Forums
Sign in to follow this  
JoshuaMckee

problems with glsl

Recommended Posts

Has anyone used glsl before? I have looked at tutorials and I'm to a point where I have the bump mapping code almost working, but there is one problem. I have this line at the beginning of the fragment shader, ...

 

uniform sampler2D rock,rockNormal;

 

I know that I am enabling both the rock and the rock normal textures correctly, but when I do the lookup into the rockNormal texture, (which is the texture rockNormal.rgb), its the same as the rock texture and it isn't the normal map texture. Is there something extra that I have to do to specify that I want the rock texture to be the first texture map and the rockNormal be the second texture map, and not have them both be the same one?

 

In cg it would have looked something more like this

 

uniform sampler2D rock : TEXUNIT0, // The whole rock texture map

uniform sampler2D rockNormal : TEXUNIT1, // The whole normal map

 

Does my question make sense?

 

Josh

Share this post


Link to post
Share on other sites

You need to set the value of the samplers(and all the uniforms you use) from within the program. Assuming you have bind the rock texture into TEXTURE0 and the normal into TEXTURE1:

 

int uniform_rock_loc=glGetUniformLocationARB(program_object_handle,"rock");

glUniform1iARB(uniform_rock_loc,0);//Set rock=0(TEXTURE0)

 

int uniform_rockNormal_loc=glGetUniformLocationARB(program_object_handle,"rockNormal");

glUniform1iARB(uniform_rockNormal_loc,1);//Set rockNormal=1(TEXTURE1)

Share this post


Link to post
Share on other sites

You need to set the value of the samplers(and all the uniforms you use) from within the program. Assuming you have bind the rock texture into TEXTURE0 and the normal into TEXTURE1:

 

int uniform_rock_loc=glGetUniformLocationARB(program_object_handle,"rock");

glUniform1iARB(uniform_rock_loc,0);//Set rock=0(TEXTURE0)

 

int uniform_rockNormal_loc=glGetUniformLocationARB(program_object_handle,"rockNormal");

glUniform1iARB(uniform_rockNormal_loc,1);//Set rockNormal=1(TEXTURE1)

 

ok that fixed that problem. Now I'm having some other terrible problem. I'm not sure whats wrong, it was like it was working one minute and then the next it wasn't and I didn't save a backup copy. I don't know if I'm going to be able to finish it. I'll keep trying though I guess.

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×