void rotateY (inout vec4 vert, float rads);
uniform float YRot;
varying float Diffuse;
void main() {
vec3 vnormal = normalize(gl_NormalMatrix * gl_Normal);
Diffuse = max(dot(vnormal, gl_LightSource[0].position.xyz), 0.0);
rotateY (gl_Vertex, YRot);
gl_Position = ftransform();
}
void rotateY (inout vec4 vert, float rads) {
vec4 old = vert;
mat2 rotY = mat2(cos(rads), -sin(rads), sin(rads), cos(rads));
vert.xz = old.xz * rotY;
}
So the problem is that the light on the object rotated with this appears to move with the object rather than remaining fixed in world space.
What can I do?
GLSL and object vs. world space
I just started trying to learn GLSL and I have a problem when rotating an object with lighting enabled. This is the vertex shader, which passes on a "diffuse" light value for the fragement shader:
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement