• Advertisement
Sign in to follow this  

glslang multitexturing

This topic is 4894 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

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
Advertisement
just set the sampler to the texture unit number you want to use via the set uniform function (0 = texunit 0, 1 = texunit 1 etc) and then use them in the GLSL code.

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
Sign in to follow this  

  • Advertisement