Shadows in real time

Xtreme3D

Lesson 13
Shadows in real time

Level: medium
Version of the Xtreme3D: 3.0.x
Author: Gecko

Xtreme3D supports several ways to render shadows. Firstly, the shade (and lighting in general) can be �������������� and "��������" in the texture - this technique is called the map light (Lightmapping). It allows you to get very beautiful and realistic result, but the resulting shade will be static. Accordingly, this technique is only applicable to the stationary objects - for example, the interiors and architecture. In addition, far not all formats of 3D models support the light maps, and not all of the 3D editors they can create.

Secondly, there is the object of the shadow plane (shadow plane). It all looks like a normal entity plane, except that the other objects can throw at him the shadows. The result is a very beautiful, but, unfortunately, the flat shadows of the applicable far not in all situations. For example, they are of little use if your game level consists of the platforms at different heights, or there is no ideal planes (for example, in the case of a realistic landscape). There are, however, a number of genres, where the shadow plane is justified is, for example, a wide variety of sports simulators (football, athletics, mini-golf, bowling, billiards, etc.), flat ������������, as well as some of the logical and casual games.

There are also two technology rendering shadow volumes - volume shadow and shadow mapping. The first is an object that defines the volume, inside of which points are in the shade. This method gives a very accurate shadows on any distance, but works quite slowly. More promising is the new technique, appeared in Xtreme3D 3.0 - shadow maps (shadow mapping). You can very quickly render soft shadows - but, the truth, at a limited distance from the camera.

We turn first to the shadow plane. Create it very simply:

ShadowTarget = DummycubeCreate(global.scene);
ShadowPlane = ShadowplaneCreate(20, 20, 10, 10, shadowTarget, light, c_black, 0.5, global.scene);

Now all I have to do is add those objects, which should drop shadow, in the descendants to The shadowTarget.

To work with the shadow volume slightly more difficult:

Sv = ShadowvolumeCreate(global.scene);
ShadowvolumeAddLight(sv, light);

Add the objects to be drop shadow, in the descendants of the sv. Those objects, which should drop shadow added as follows:

ShadowvolumeAddOccluder(sv, Obj);