User Tools

Site Tools


Image Based Shading


Image Based Shading is an illumination technique that uses environment maps instead of light sources to calculate the lighting in the scene. This is an efficient way to simulate a complex lighting environment without any calculations for the illumination model but just a lookup in a diffuse and specular environment maps.


An imaged based shader is implemented like sphere mapping or cube mapping without the lighting model calculation part. The main difference is in the fragment shader where you look up a reflection color in the diffuse and specular environment maps in order to add a diffuse and specular lighting to the shading.


  • Look up a diffuse color in the diffuse environment map.
  • Look up a specular color in the specular environment map.
  • Determine the diffuse lighting by combining the base vertex color and the diffuse color. For nicer lighting effects you may define a diffuse uniform parameter to control in what ratio base and diffuse color are going to be mixed.
  • Determine the final color by combining the specular lighting and the diffuse lighting. You may add a specular uniform parameter to control in what ratio diffuse and specular color are going to be mixed.

You use a light probe image to create an environment texture as for the sphere mapping. Diffuse and specular maps can then be obtained from the environment texture by applying a convolution filter such as a Gaussian filter.


  • For the image based shading use a more simple approach to calculate the texture coordinates for the lookup in the environment map. You use the view-space normal only.

Sample Output

Examples rendered with image based shader using diffuse and specular textures and Phong Shading.



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

students/image-based-shading.txt · Last modified: 2012/01/13 21:51 (external edit)