Hi,
I have 2 seperate shaders ((sin = sin.vert & sin.frag) and (cubeMap = cubeMap.vert & cubeMap.frag)) and am trying to link all 4 into to a program but I seem to be losing the uniform variables, i guess it must be something in the shader but i am not sure what. Both of the pairs of shaders work fine independently, but when I link them all in the same program the count of uniform variables is 0 (using gl.glGetProgramiv(programObject, GL.GL_ACTIVE_UNIFORMS, x,0);). There are no compiling or linking errors. Is there anything special i have to do in a shader when using multiple shaders like this.
I am guessing that uniforms from either shader should come up as uniforms available to the program, is that right?
sin.vert:
uniform float time;
void main(void) {
gl_FrontColor = gl_Color;
vec4 v = vec4(gl_Vertex);
v.z = v.z * sin(5.0*v.x + time*0.1);
gl_Position = gl_ModelViewProjectionMatrix * v;
}
sin.frag:
void main()
{
gl_FragColor = gl_Color;
}
cubeMap.vert:
uniform vec3 LightPos;
varying vec3 ReflectDir;
varying float LightIntensity;
void main()
{
gl_Position = ftransform();
vec3 normal = normalize(gl_NormalMatrix * gl_Normal);
vec4 pos = gl_ModelViewMatrix * gl_Vertex;
vec3 eyeDir = pos.xyz;
ReflectDir = reflect(eyeDir, normal);
LightIntensity = max(dot(normalize(LightPos - eyeDir), normal),0.0);
}
cubeMap.frag:
varying vec3 ReflectDir;
varying float LightIntensity;
uniform vec3 BaseColor;
uniform float MixRatio;
uniform samplerCube EnvMap;
void main() {
// Look up environment map value in cube map
vec3 envColor = vec3(textureCube(EnvMap, ReflectDir));
// Add lighting to base color and mix
vec3 base = LightIntensity * BaseColor;
envColor = mix(envColor, base, MixRatio);
gl_FragColor = vec4(envColor, 1.0);
}