Building a geometry - part 3 - Adding lights

This tutorial will explain how to setup the lights contained in a geometry.

In the "Building a geometry - part 1 - Loading a source scene" tutorial, we saw that when we load a geometry, the lights contained in the original scene graph are imported.

The ART::IAssetManager::LoadGeometrySource method automatically builds ART::ILight objects and set them in the geometry. We can get them: ART::IGeometry::GetLightsCount and ART::IGeometry::GetLight.

// Getting the lights and parameterize them.
ART::IGeometry* igeometry = g_geometry->As< ART::IGeometry >();
int count = igeometry->GetLightsCount();

RED::Object* light;
ART::ILight* ilight;

for( int i = 0; i < count; ++i )
  light = igeometry->GetLight( i );
  ilight = light->As< ART::ILight >();

  // Lights are deactivated by default.
  RC_TEST( ilight->SetActive( true ) );

  // Setting the baking mode corresponding to the GI cache content.
  if( i == 0 )
    ilight->SetBaking( ART::LB_FULL );
  else if( i == 1 )
    ilight->SetBaking( ART::LB_INDIRECT );
    ilight->SetBaking( ART::LB_NONE );

  // Other parameters can be overridden here. 
  // If not, the parameters are those from the original file.

The ART::ILight interface contain several accessors to setup the multiple light parameters (you can go to the ART::ILight documentation for a complete listing of the methods):

By default, all the lights are deactivated. We must enable them if we want to see something.

The light baking mode must be set accordingly to the GI cache content. If a light has been baked (full or indirect only), ART::ILight::SetBaking must be called with the corresponding values. Baked lights can't be moved in the scene once precalculated. However they can be activated and deactivated. Dynamic lights (ART::LB_NONE) can be moved and are updated every frame (position, orientation, shadows, etc.). Currently, only spot and point lights can be dynamic. All other RED lights must be baked.

The shadowing can be only be activated on the dynamic spot lights using shadow maps. There are several options:

The REDart lights support IES profiles. The IES data are loaded with the geometry lights if they are in the original file or they can be added later using ART::IAssetManager::LoadIESFile and ART::ILight::SetIESData.

IES light in the house (only indirect is baked to keep the clear IES profile)