I think variables naming is confusing you.
From what I'm reading (assuming you're in camera space and without handedness knowledge)
vec3 lookat = vec3(0, 0, 1);
float reflection = max(0, dot(reflect(position, normal), lookat));
lookat
is a directional light and position
is the actual lookat
.
Make sure normal
(it's probably already normalized) and position
(the lookat
) are normalized.
A less confusing code would be:
vec3 light_direction = vec3(0, 0, 1);
vec3 lookat = normalize(position-vec3(0,0,0));
float reflection = max(0, dot(reflect(light_direction, normal), -lookat));
Without normalizing position
, reflection
will be biased. The bias would be strong when position
is far from the camera vec3(0,0,0)
Note how lookat
is not a constant; it changes for each and every position. lookat = vec3(0,0,1)
is looking toward a single position in view space.