Radeon ProRender

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 this 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 perfectly reasonable.

// Create env light.
	rpr_light light;
	{
		CHECK(rprContextCreateEnvironmentLight(context, &light));

		rpr_image img;
		const std::string pathImageFile = "../../Resources/Textures/Apartment.hdr";
		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 from
		CHECK(rprEnvironmentLightSetImage(light, img));
		//CHECK(rprEnvironmentLightSetIntensityScale(light, 10.0f));

		// Set IBL as a background for the scene.
		CHECK(rprSceneAttachLight(scene, light));
	}