# Implementing Many-Lights Rendering with IES-Based Lights
## 4 Method
### Enhancing Reflective Shadow Maps with IES Data  
We have extended the Reflective Shadow Maps technique [8], which we have presented in Section 2, in two ways. First of all, we have extended the original technique in order to also consider point lights. The main approach remains the same: the rendering is based on deferred rendering, saving the same data (depth, position, normal, and flux) in different G-buffers. However, to manage the omnidirectional emission of a point light, we use cube maps instead of standard 2D textures. Cube maps are generated performing six different rendering steps, pointing the light sources in the front, back, up, down, left, and right directions. This way, we have a panoramic determination of what is \"seen\" by the light in every direction [3]. In OpenGL, the process of rendering to each face of the cube map can be completed in a single render pass using an ad hoc geometry shader [38]. Figure 5a-c show examples of the content of the cube maps version of the data required by the RSM technique. Figure 3: Some rendering results of the _modified Cornell box_ using the proposed method. The scene presents a light source (described by the IES file in Listing 1 and Figure 2), moving from left to right. The photometric solid is rendered in wireframe. The results show the effect of the non-uniform emission of the light source (particularly evident on the ceiling in the image in the center) and the color bleeding effects provided by the Many-Lights approach, in particular on the solid on the left in all the frames and on the _Stanford Lucy_ model in the right image. Standard point lights emit light in a uniform way in every direction (i.e., the volume of emission is perfectly spherical). With IES data, we want to \"weight\" the emission in each direction given the value provided by the photometric solid. In order to obtain such an effect, we can create an IES _light mask_ starting from the photometric solid. In practice, we convert the value of the IES data, currently stored in the polygon mesh of the photometric solid, into a cube map whose values will represent how and how much light should be emitted from the light source towards each direction. The photometric solid is positioned where the point light is placed, and oriented accordingly. Computing the associated light mask is completed through projecting its faces to the cube map. We can re-use the first part of the G-buffers creation step because the vertices of the polygon solid mesh need to be processed in the same way. As a consequence, we apply the same vertex and geometry shaders applied for the other cube maps of the RSM technique. However, in order to achieve the desired result, we apply a fragment shader that saves the IES light mask information using a _false colors_ approach. We present in Listing 2 an excerpt of the GLSL code relative to the final fragment color computation. Figure 4: A render using the _Crytek Sponza_ scene. The subfigures are (**a**) the scene rendered only with direct lighting using the IES light mask; (**b**) the scene illuminated only by indirect lighting (a 4\(\times\) multiplication factor has been applied to make the component more visible); (**c**) the final render of the scene using the proposed method; (**d**) the final render with debug visualization of the photometric solid. The scene uses the light source described by the IES file in Listing 1 and Figure 2.  
Thus, the generated texture stores the following data:  
* _Red_ color channel: we store the length of the vector that goes from the position of the light to the processed fragment, i.e., the luminous intensity emitted from the light source in that direction. * _Green_ color channel: distance_to_furthest_ies_vertex is the original maximum distance between the origin and a vertex of the photometric solid. Dividing the distance of the fragment from the light by this value, we compute an intensity modifier based on the maximum intensity that the light source can emit in candelas.