I have been trying to use Mac OS X’s developer tools lately. While XCode works like a dream and the setup of OpenSceneGraph takes literally 30 seconds (compared to failing to get it to install after 2.5 hours trying on Windows), the OpenGL Shader Builder has been causing me problems. I read the entire documentation file, all two pages. No-where does it explain how to access textures as sampler uniforms in your shaders. In fact, I had a hard time finding anyone else on the internet with the same problem.
So I kept experimenting for almost a day before I finally found someone with the same problem. Turns out, you have to use uniform references labeled “texture0″, “texture1″, and so on.
Then, you have to go to the Symbols screen and change the “x” value to correspond to the number value labeling the texture. So, “texture0″ needs x-value 0, and “texture6″ needs x-value 6.
Then, your fragment shader would look like this:
uniform sampler2D texture0;
void main()
{
vec4 color = texture2D(texture0, gl_TexCoord[0].st);
gl_FragColor = color;
}
![]()
At least the icon is pretty. ;)
April 13, 2009 | 10:41 PM
Categories: Design, Graphics, How To, Programming, Software

Hi, thanks for the tips!
I’m new to shaders, I’m facing the same problem and this is the only ressource I found!
But it does not seem to work for me :( even with a very basic example :
——————————————————————————————————–
/* [FRAGMENT] */
uniform sampler2D texture0;
uniform sampler2D texture1;
void main() {
vec4 t0color = texture2D(texture0, gl_TexCoord[0].st);
vec4 t1color = texture2D(texture1, gl_TexCoord[0].st);
gl_FragColor = t0color;
}
——————————————————————————————————–
Even if i witch the last assignement with t1color, the shader builder keeps rendering the texture of the 1st slot.. Do you have any idea why ? (I’m using opengl shader builder 2.1)
Thanks!!
@kikko
Your shader appears to be correct. It follows the exact same format as mine (and my older projects). This means some other setting is probably wrong (unless of course the program is glitching, restarting might help). Make sure you follow the advice about how to set the Symbols tab.