I am using a simple form of Phong Shading Model where the scene is lit by a directional light shining in the direction -y, with monochromatic light of intensity 1. The viewpoint is infinitely far away, looking along the direction given by the vector (-1, 0, -1).
In this case, the shading equation is given by
I = k_d*L(N dot L)+k_s*L(R dot V)^n_s
where L
is the Directional Light source, kd
, ks
both are 0.5
and n_s = 50
In this case, how can I compute the R
vector?
I am confused because for computing finite vectors we need finite coordinates. In case of the Directional Light, it's infinitely far away in the -y direction.
Reflect vector can be calculated by using reflect
function from GLSL.
vec3 toEye = normalize(vec3(0.0) - vVaryingPos);
vec3 lightRef = normalize(reflect(-light, normal));
float spec = pow(dot(lightRef, toEye), 64.0f);
specularColor = vec3(1.0)*max(spec, 0.0);
calculations are done in eye space... so the eyePos is in vec3(0.0)