I am trying to create a custom light shader and trying to do many different things over time. Some of the solutions I found work better, others worse. For this question, I am using the solution that has worked best so far.
My problem is that if I move the βcameraβ around, the light positions seem to be moving too. This solution has a very small but noticeable movement in it, and the position of the light seems to be higher where it should be.
The default OpenGL lighting (without any shaders) works fine (stable light positions), but I need a shader for multitexturing, and I plan to use parts of it for lighting effects after it works.
Vertex source:
varying vec3 vlp, vn; void main(void) { gl_Position = ftransform(); vn = normalize(gl_NormalMatrix * -gl_Normal); vlp = normalize(vec3(gl_LightSource[0].position.xyz) - vec3(gl_ModelViewMatrix * -gl_Vertex)); gl_TexCoord[0] = gl_MultiTexCoord0; }
Source of fragment:
uniform sampler2D baseTexture; uniform sampler2D teamTexture; uniform vec4 teamColor; varying vec3 vlp, vn; void main(void) { vec4 newColor = texture2D(teamTexture, vec2(gl_TexCoord[0])); newColor = newColor * teamColor; float teamBlend = newColor.a;
What am I doing wrong?
Cobra_fast
source share