normalizelightDir
NormalizelightDir is a term used in computer graphics to refer to the directional vector from a surface point to a light source that has been normalized to unit length. In many shading models, the light direction is assumed to be a unit vector, which simplifies computations for diffuse and specular lighting and ensures consistent lighting intensity regardless of distance.
Purpose and usage: By normalizing the light direction, the dot product with the surface normal yields correct,
Typical usage in a shader: For a positional light, compute the vector from the fragment to the
lightDir = normalize(lightPos - fragPos)
diffuse = max(dot(normalize(normal), normalizelightDir), 0.0)
For a directional light, the normalized light direction is often provided directly or computed as the normalized
Notes and considerations: It is important to use vectors in the same coordinate space (world space, view
See also: normalize, dot product, Lambertian reflectance, Blinn-Phong, Phong reflection model, shading.