After the variable is transformed to clip-space, we perform the perspective divide step by dividing its xyz components with its w component. That wraps up our lighting implementation for now. You could also sample a flashlight texture to stop the light from looking so circular and flat. The heart of the problem is using the fragment shader to do that many texture lookup operations in a loop. Although in this explanation we have used our analytic daylight model, in fact, any image source may be used.
nest...