Hi all,
I’m using cubemaps for an upcoming project (dome projection) and am having issues getting uniform lighting while dynamically creating each of the faces of the cubemap. In short, the bright and dark areas of my objects do not match up from face to face in the cubemap.
Rather than post my code in its current state, to illustrate the problem I used the ‘DynamicCubeMapping’ sample and changed ‘mSatelliteBatch’ to use a simple glsl shader which calculates lighting (as opposed to the stockShader().color() that the example uses). When that shader is bound to the satellites, the lighting of the objects fails to be uniform between each of the faces of the cube . - Difficult to see, but circled in red is the inconsistency - the bottom portion of the image shows it a bit more obviously from my project :
my frag shader:
`#version 150
uniform vec3 lightPos;
in vec3 vertPosition;
in vec3 vertNormal;
in vec2 vertTexCoord0;
in vec4 diffuse;
out vec4 oColor;
void main()
{
vec3 n = normalize(vertNormal);
vec3 l = normalize(lightPos-vertPosition.xyz);
float phong = max(dot(n,l),0.0);
oColor.rgb = vec3(diffuse*((phong)));
oColor.a = 1.0;
}
and my vert:
#version 150
uniform mat4 ciModelViewProjection;
uniform mat3 ciNormalMatrix;
in vec4 ciPosition;
in vec3 ciNormal;
in vec2 ciTexCoord0;
in vec4 ciColor;
out vec3 vertPosition;
out vec3 vertNormal;
out vec2 vertTexCoord0;
out vec4 diffuse;
out highp vec3 NormalWorldSpace;
void main()
{
vertPosition = ciPosition.xyz;
vertNormal = ciNormalMatrix * ciNormal;
vertTexCoord0 = ciTexCoord0;
diffuse = ciColor;
gl_Position = ciModelViewProjection * ciPosition;
NormalWorldSpace = vec3(ciPosition);
}
As I said, aside from the shader binding, the rest of the code is unchanged from the dynamicCubeMapping sample. Any suggestions as to what I’m missing?
thanks,
Brandon