Sign in to follow this  
666_1337

glslang multitexturing

Recommended Posts

hi. how do I specify which texture unit ( TEXTURE0_ARB, TEXTURE1_ARB, ... ) to use during glsl process? if i simply define a texture sampler by "uniform sampler2D s;" the first texture unit is used. how can i reference to another texture unit? thanks in advance

Share this post


Link to post
Share on other sites
Hello!

in the fragment shader you have to define sampler2D-s like this:
uniform sampler2D basetexture;
uniform sampler2D bumptexture;

From the opengl code:
gl.glUseProgramObjectARB( normalShaderObj );
int baseTexture = gl.glGetUniformLocationARB( normalShaderObj, "basetexture".getBytes() );
gl.glUniform1iARB( baseTexture, 0 ); // 0 is GL.GL_TEXTURE0_ARB
int bumpTexture = gl.glGetUniformLocationARB( normalShaderObj, "bumptexture".getBytes() );
gl.glUniform1iARB( bumpTexture, 1 ); // 1 is GL.GL_TEXTURE1_ARB

Hopefully, this might help.

Share this post


Link to post
Share on other sites
note: the above code is C#, so some of that stuff isnt required when dealing with C++

@fazekaim
when posting code can you please use the source or code tags, see the forum FAQ for details (top right icon)

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