Original Post
Hello everyone, I'm having a little problem with using the same shader in Rendermonkey and an OpenGL application but getting different results. This is a simple cubemap reflection, and I don't really know, what I could have done wrong. Here is my vertex shader code:
varying vec3 ReflectDir;
varying float LightIntensity;
uniform vec3 LightPos;
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);
}
And here the pixel shader:
uniform vec3 BaseColor;
uniform float MixRatio;
uniform samplerCube EnvMap;
varying vec3 ReflectDir;
varying float LightIntensity;
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);
}
This is my renderloop in my GL application:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glColor3f(1.0f,1.0f,1.0f);
SetCamera();
EnvMapper->Activate();
TexManager.BindCubeMap(CubeMapID);
glEnable(GL_TEXTURE_CUBE_MAP_EXT);
//EnvMap
glUniform1iARB(glGetUniformLocationARB(EnvMapper->Program(),"EnvMap"),0);
//Color
glUniform3fARB(glGetUniformLocationARB(EnvMapper->Program(),"BaseColor"),0.4f,1.0f,1.0f);
//MixRatio
glUniform1fARB(glGetUniformLocationARB(EnvMapper->Program(),"MixRatio"),0.0f);
//LightPos
glUniform3fARB(glGetUniformLocationARB(EnvMapper->Program(),"LightPos"),-7.0f,10.0f,15.0f);
for(int i=0;i<m_ObjectBuffer[0].iFaceCount*3;i+=3)
{
glBegin(GL_TRIANGLES);
glVertex3f(va.x ,va.y ,va.z);
glVertex3f(va[i+1].x ,va[i+1].y ,va[i+1].z);
glVertex3f(va[i+2].x ,va[i+2].y ,va[i+2].z);
glEnd();
}
glDisable(GL_TEXTURE_CUBE_MAP_EXT);
EnvMapper->Deactivate();
Can anyone help? Thanks for any response in advance Greets Chris [Edited by - Hydrael on August 12, 2006 9:22:03 AM]