Noble Studios is developing a 2.5 game called Luna. As taken directly from our development webpage, "Play as a magical moon girl who journeys to the Earth searching for a little boy in hopes of finally finding friendship...but all is not right, as someone plots to make sure you will never return home." Currently Luna is a prototype and it features no shaders, only textures and no good lighting. See the example image below.
Our main character Luna with minimal lights. |
Ambient
An ambient light is a non-directional light that determines the amount of lighting in a scene. In Luna, the game changes from broad daylight to night over the course of the levels. Knowing how our game progresses, we can alter the ambient light in order to achieve certain levels of light or dark between the stages.
In code, we can achieve this with a simple formula
Ambient = K * AmbientIllumination where k is a float value between 0 and 1.
Diffuse
Diffuse lighting is a method to apply shading to an object. While the ambient light applies lighting to an entire scene, a diffuse light will ensure a proper shade of that object. The image below demonstrates this.
- The illuminance on a surface illuminated by a light falling on it perpendicularly from a point source is proportional to the inverse square of the distance between the surface and the source.
- If the rays meet on a surface at an angle, then the illuminance is proportional to the cosine of the angle with the normal.
- The luminous intensity of light decreases exponentially with the distance it travels through an asorbing medium
// Compute the diffuse term
float3 L = normalize(lightPosition - P);
float diffuseLight = max(dot(N, L), 0);
float3 diffuse = Kd
* lightColor * diffuseLight;
In our game, we can use this to apply realistic environment and character shading. Players will be able to determine the curvature of objects and the intensity of the lights. This is important because it adds a sense of realism to the characters, and it simply makes things more defined.
Specular lighting is the bright spot of light that appears on shiny objects such as metal or water when illuminated. This is important in 3D graphics because it suggests the shape of an object and its position according to the light sources of the scene.
The image below is a good example of specular, diffuse, and ambient lighting. The brightest section of the water is the specular highlight. Along the edges of the highlights the light begins to diffuse. At the far right, it becomes darker because less light is reflecting off that surface. The ambient light is the sun, that provides light to the entire scene.
In our game, we can use specular highlights to show the brightest part of an object. This is useful because we can define an object not only will diffuse lighting, but add additional realism with specular highlights.
Using the following code, we can create a specular light
// Compute the specular term
float3 V = normalize(eyePosition - P);
float3 H = normalize(L
+ V);
float specularLight = pow(max(dot(N,
H), 0), shininess);
In conclusion
By using these three different types of lighting, we'll be able to achieve character and environment lighting that suits our games and its needs. In later posts, I will be describing more ways we will be able to improve our current prototype!
No comments:
Post a Comment