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;
}

OpenGL Shader Builder Icon

At least the icon is pretty. ;)