6.2.2 Generating correct reflections with a local cubemap

A solution to this problem involves binding to the local geometry in the procedure to calculate the reflection.

This solution is described in GPU Gems: Programming Techniques, Tips, and Tricks for Real-time Graphics by Randima Fernando (Series Editor).
The following figure shows a local correction using a bounding sphere:
Figure 6-14 Local correction using a bounding sphere

A bounding sphere is used as a proxy volume that delimits the scene to be reflected. Instead of using the reflected vector R to fetch the texture from the cubemap a new vector R’ is used. To build this new vector you find the intersection point P in the bounding sphere of the ray from the local point V in the direction of the reflected vector R. Create a new vector R’ from the center of the cubemap C, where the cubemap was generated, to the intersection point P. Use this vector to fetch the texture from the cubemap.
float3 R = reflect(D, N);
Find intersection point P
Find vector R’ = CP
float4 col = texCUBE(_Cubemap, R’);
		
This approach produces good results in the surfaces of objects with a near spherical shape but reflections in plane reflective surfaces are deformed. Another drawback of this method is that the algorithm to calculate the intersection point with the bounding sphere solves a second degree equation and this is relatively complex.
In 2010 a developer proposed a better solution in a forum at http://www.gamedev.net. This approach replaces the previous bounding sphere by a box and solves the deformations and complexity problems of the previous method. For more information see: http://www.gamedev.net/topic/568829-box-projected-cubemap-environment-mapping/?&p=4637262.
The following figure shows a local correction using a bounding box:
Figure 6-15 Local correction using a bounding box

A more recent work in 2012 by Sebastien Lagarde uses this new approach to simulate more complex ambient specular lighting using several cubemaps and uses an algorithm to evaluate the contribution of each cubemap and efficiently blend on the GPU. See http://seblagarde.wordpress.com

Table 6-3 Differences between infinite and local cubemaps

Infinite Cubemaps Local Cubemaps
  • Mainly used outdoors to represent the lighting from a distant environment.
  • Cubemap position is not relevant.
  • Represents the lighting from a finite local environment.
  • Cubemap position is relevant.
  • The lighting from these cubemaps is right only at the location where the cubemap was created.
  • Local correction must be applied to adapt the intrinsic infinite nature of cubemaps to local environment.
The following figure shows the scene with correct reflections generated with local cubemaps.
Figure 6-16 Correct reflections

Non-ConfidentialPDF file icon PDF versionARM 100140_0201_00_en
Copyright © 2014, 2015 ARM. All rights reserved.