Shadowing (5/7)




Description

Casting shadows in SOFA.

Key points

With SpotLight, it is possible to cast shadows simply in SOFA. All we have to do is to put the component OglShadowShader (Shaders in general will be seen later), preferably in the same Node as the LightManager, i.e. root node of the scene.

First, add a floor by adding a new OglModel to the Dragon node and setting the Path to the model to /Sofa/share/mesh/floor.obj. Set its position to (0 -7 0).

Add a new Spotlight to the Root node. Set its position to (0 60 0) and its direction to (0 -1 0.01).

Add a OglShadowShader component to the Root node.

Then, you just have to either type the CONTROL+'L' key combination, or set the parameter Enable Shadow in the scene to true in the LightManager.

The only remarkable parameter is shadowTextureSize. The higher this parameter is, the nicer the shadow will be. Be careful with this, because if it is too high it can slow down your computer or even freeze it. It can be considered that 4096 is the maximum reasonable value.

Note:

For now, shadows are rendered "hardly" (contours are raw). Don't forget that it uses GPU quite badly, so try to activate shadows only when necessary.


Next