OpenGL

This project consists on the implementation of one or more light caster in order to generate shadow below the models and rendered objects.

To accomplish this goal, modern OpenGL version 4.4 was used, in addition to the libraries:

Also, GLSL was used to perform the calculations of the vertices and fragments in  the video card (GPU), in order to relieve the processor (CPU) from complex calculation and stress. 

In addition, the models or the light casters should be able to move in the scene to create a dynamic effect of the shadow on the floor and other objects.

Simulation Theory

Performing shadows in real time on the computer is quite difficult, because there is no algorithm developed yet. However, there are several approaches to perform this task, such as: 

The principle of Shadow mapping is to render the scene from the point of view of the light caster, so all surfaces and objects that can be seen from the perspective of the light source should be considered as illuminated while surfaces that cannot be seen should be considered as shadow. This can be determinate using the depth buffer.

A transformation matrix is used in order to translate the rendering process from the point of view of the camera to the point of view of light caster, then these new values are saved in a separated texture. 

Thus Shadow Mapping requires 2 steps, the first is to render the depth map and the second is to render the normal scene using the calculated depth map to determine the shaded fragments.

Results

Example of 3 Spitfire models with shadow superposition due to the implementation of several shadow casters over the plane.

Shadows are darker in the place where they superpose meanwhile they are lighter where there is no superposition.

The shadows quality is strongly related to the resolution of the buffer, the following images show the effect of a poor choice of buffer size.

Buffer: 800x800

Buffer: 7000x7000

Conclusions

In conclusion, shadows bring realism to any scene, however shadows decrease performance of the application severely because for each new light source a new renderization scene must be performed.

Although perfect shadows cannot be obtained since there are no algorithms capable of doing them in real time, using the Shadow Mapping approach, good results can be achieve considering an adequate buffer resolution.