Building a geometry - part 3 - Adding lightsnew

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 RPL::IAssetManager::LoadGeometrySource method automatically builds RPL::ILight objects and set them in the geometry. We can get them: RPL::IGeometry::GetLightsCount and RPL::IGeometry::GetLight.

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

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

for( int i = 0; i < count; ++i )
{
  light = igeometry->GetLight( i );
  ilight = light->As< RPL::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( RPL::LB_FULL );
  }
  else if( i == 1 )
  {
    ilight->SetBaking( RPL::LB_INDIRECT );
  }
  else
  {
    ilight->SetBaking( RPL::LB_NONE );
  }

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

The RPL::ILight interface contain several accessors to setup the multiple light parameters (you can go to the RPL::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), RPL::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 (RPL::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 RPL::IAssetManager::LoadIESFile and RPL::ILight::SetIESData.

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