glslang multitexturing
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
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.
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.
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.
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)
@fazekaim
when posting code can you please use the source or code tags, see the forum FAQ for details (top right icon)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement