Lighting models

Direct Lighting
Direct lighting is the simplest model, you have a light source and each vertex takes its shade multiplier (0-1) by calculating the distance and angle to the light source.

Point lights shine in all directions and follow Inverse Square theory for distance.

The Sun is a directional light source with parallel rays and is not affected by Inverse Square in the small distances used by GoldenEye.

A directional light is one that uses a source plane of a certain size that projects parallel rays along its length. These rays follow inverse square theory.

The angle at which a light ray hits a surface determines how bright the surface will be. A ray that hits a surface perpendicularly will light it fully, while a ray that hits a surface at an angle of greater than or equal too parallelism will have no effect on the surface.

Any surface behind another surface and a light source will be occluded from that light source and as such will have no light hitting it. It will be in shadow.


Ambient Occlude
Ambient Occlusion is the test for occlusion of the sky. Each vertex fires a hemisphere of test rays. Each ray returns a value of true or false which are then added together to provide a percentage. If the total number of False is 100% then the face can see all of the sky and is not occluded and so receives a multiplier of 0.5 for brightness. If the percentage of False is 0 then all rays were occluded and so the multiplier is 0 since no light from the sky can reach it.
With Ambient Occlusion the Direct Lighting multiplier is also multiplied by 0.5 so that if the case was a vertex could see the sky and be light directly by the sun it would receive 0.5+0.5 = 1.


Inter-Reflection
Inter-Reflection is divided into 2 types, Diffuse and Specular

Specular Inter-Reflection
The light that is reflected from a shiny surface. This light is projected along the reflection angle, that is, the opposite angle to that which hit the surface. So 450 to perpendicular would be reflected at -450 to perpendicular.
This light is subject to Inverse Square Theory but the multiplier is 1 at source, i.e. all the light hitting the shiny surface will be reflected to hit other faces.

Diffuse Inter-Reflection
The light that is reflected from a non-shiny surface. This light is projected in all directions of varying power and is subject to Inverse Square Theory.
Most of the light reflected is projected perpendicular to the surface with ever decreasing power as the angle increases to parallelism after which the power is 0.
Diffuse Inter-Reflection also contains a colour component of the source surface, i.e. a red surface will reflect red light.

As well as vertex colours Diffuse Inter-Reflection is relyant on Texture and will require 2 tables.
The first table records the 'roughness' of a texture, where the greater the roughness the less light is reflected, and the second table records the average colour contained within the texture.
This texture colour is multiplied by the vertex colour during inter-reflection calculations.

This allows a black texture to reflect no light and a red texture to reflect red light.

Without the texture colour multiplier, a face directly lit by a light would reflect bright light, even if the texture shouldnt reflect any or a different colour.



Order to lighting

First is Ambient Occlude check. If a cloudy day then you need only to finally check for Diffuse Inter-Reflection.

Next after Ambient is Direct Lighting. This lights to a greater degree all faces that can see the light. This step also includes shadow casting and Specular Inter-Reflection casting.

After all Lighting is done is the final Diffuse Inter-reflection check.
All verticies check for visibility of other lit faces by casting test rays. Each ray adds its value (colour& brighteness * Inverse Square Theory) to a copy of the source vertex.
After all verticies have checked, they then take on their new values