GLSL Core Tutorial – Point Lights

When considering point lights, the main difference regarding directional lights is that now we have a position for the light instead of a direction. This implies that the light direction is not constant across all fragments/vertices as it was for direction lights. Besides that, everything remains just like for directional lights. In the figure below we have a triangle being lit by a directional light (left) and a point light (right).

The vertex shader now receives a light position instead of a light direction, and it must compute the light’s direction for each vertex. It is assumed that the light’s position is in camera space. Once we move the vertex position to the same space, the direction computation is straightforward:

light direction = light position – vertex position.

Before we can compute this vector we must apply the View Model matrix (m_viewModel in the shader) to the vertex position.