User Tools

Site Tools


Sphere Mapping


Sphere Mapping is an environment mapping, or reflection mapping technique, that simulates environment reflections on an object's surface, using a texture map.

The texture map contains an image (light probe) of the surrounding environment reflected on a perfect mirror ball and captured, using an orthographic projection.
Such an image could also be generated during the rendering using a fish eye camera model.

An example of a light probe image and a scene using this image as environment map.


For each pixel on the surface the reflected direction from the object to the environment (the reflection vector) is used to look up a reflection color in the environment map.
This color is then added to the final shading.

For more information about environment mapping techniques you can also read the Wikipedia articles about Reflection Mapping and Sphere Mapping.


The idea of the sphere mapping shader is to produce two color values for each pixel, the diffuse lighting color and the reflection color, and to combine these into the final shading color.


  • Calculate the reflection vector and diffuse lighting (Lambert illumination model) for each vertex (Gouraud shading) or for each fragment (Phong shading). The following formula is used for the reflection vector calculation. N is the unit surface normal, V is the unit view vector, and R is the reflection vector.

  • Calculate the texture coordinates for the lookup using the reflection vector.

  • Look up the reflection color in the environment texture.
  • Finally combine the reflection color and the diffuse lighting color into the final shading color.


  • Define a uniform variable, in order to control in what ratio the diffuse lighting and the reflection colors are mixed.
  • Make sure that the V and N vectors are normalized.
  • The ECG framework already has a method implementation for calculating the reflection vector (Vec3.reflect()).

Sample Output

Suzanne-hires.dae rendered with sphere mapping shader using Phong shading and the grace_probe.png texture.


grace_probe.png light probe



Randi J. Rost, OpenGL Shading Language, Second Edition, Addison Wesley Professional, 2006

Wikipedia, Reflection Mapping, Sphere Mapping

Udo Bischof , Environment Mapping, BTU-Cottbus, 2006

Light Probe Image Gallery

Real-Time Computation of Dynamic Irradiance Environment Maps(GPU Gems)

students/sphere-mapping.txt · Last modified: 2014/09/30 13:48 (external edit)