Environment Light Creation

Environment lights are special lights that cover the entire sphere around a scene. Normally these are used with specialized texture maps called ‘Environment Maps’ (also HDRI or IBL maps).

In the Basic Scene tutorial, we create an environment light and then create a texture map with rprContextCreateImageFromFile(). Then the image is attached to the light with rprEnvironmentLightSetImage().

Note

Because environment lights cover the entire sphere around a scene, setting the location or scale of one has no effect, however setting the rotation is possible.

// Create an environment light
rpr_light light = nullptr;
rpr_image img = nullptr;
{
	CHECK(rprContextCreateEnvironmentLight(context, &light));

	const std::string pathImageFile = "../../Resources/Textures/envLightImage.exr";
	CHECK(rprContextCreateImageFromFile(context, pathImageFile.c_str(), &img));
	if (status == RPR_ERROR_IO_ERROR)
	{
		std::cout << "Error : " << pathImageFile << " not found.\n";
		return -1;
	}

	// Set an image for the light to take the radiance values   
	CHECK(rprEnvironmentLightSetImage(light, img));
     
	// Set IBL as a background for the scene
	CHECK(rprSceneAttachLight(scene, light));
}

An example of creating an environment light can be found in the Basic Scene demo.