Sign in to follow this  

glslang multitexturing

Recommended Posts

666_1337    122
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
fazekaim    118

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

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