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, I had some problems with the OpenGL Shader Builder. I couldn’t figure out 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;
}