Cubemapping demos
by Ingemar Ragnemalm
Cube mapping is the preferred mechanism to perform environment mapping,
where an environment texture is mirrored in a shiny surface. This page
holds two demos of the technique, both modern, shader-based demos using
the "samplerCube" GLSL texture sampler.
These two demos started out as two NVidia demos (most noticable in the
simple cubemap demo) but nothing remains of the original code.
Simple cubemap demo
by Ingemar Ragnemalm
This demo isn't as pretty as the next, but mainly intends to give an
insight in how cube mapping works. A simple cube map consisting of six
differently colored sides is mapped onto shapes using four different
mappings. Three of these are plain mappings along the normal vector,
while one mirrors the view direction over the normal vector, which
gives us environment mapping, the mapping you are most likely to want.
![](img/simple-cube-map.png)
simple-cm-demo.tar.gz
Cubemap and skybox demo
by Ingemar Ragnemalm
This demo was one that I found missing on the web. Cube mapping is
a fairly complex operation, where you must calculate the reflection in
the vertex shader, and this is easy to get wrong.
In the demo, a skybox is drawn around an object, on which the same
texture is used by cube mapping. You can rotate the camera as well as
the object to see
that the reflections look correct.
The texture used is the "Petomavar" skybox which I found on
turbosquid.com. I don't know more about it, but would love to give
credits to its creator. According to the turbosquid page it is free, at
least for non-commercial use like this.
![](img/cubemap-and-skybox-new.png)
cubemap-and-skybox-demo.tar.gz
by Ingemar Ragnemalm 2012-2013