-
Click on one of the displayed pictures below to change the environment and
skydome map.
-
The diffuse slider determines the amount of diffuse reflection from the deepest mipmap
level which only consists of 6 texels, one for each cubemap side.
-
The specular slider determines the amount of specular reflection.
-
The roughness value determines which mipmap level is used to render the surface
reflections. A value of 0 correlates to a specular surface and the first mipmap
level is used. A value of 1 correlates to a rough surface and the last (deepest)
mipmap level is used.
-
The shader uses a 'refract' function rather than a 'reflect' function if the
'Use Refraction' checkbox is checked.
-
If 'Use Refraction' is checked, the index of refraction of the material can be
changed by the corresponding slider. Common values are 1.33 for water,
1.45 - 2.14 for glass and 2.42 for diamond.
-
The exposure slider determines the exposure of the scene.
(W / Mouse wheel) | Zoom in |
(S / Mouse wheel) | Zoom out |
Drag with
pressed
left Mousebutton | Rotate view |
(1) | Monkey (Exported from Blender) |
(2) | Torus knot (Exported from Autodesk 3DsMax) |
(3) | Sphere |
(4) | Utah Teapot (Exported from Autodesk 3DsMax) |
Environment mapping is a technique to approximate the reflections on surfaces by using textures.
These textures are often cube or spherical maps providing a 360-degree view of the
environment (see figures below).
This learning module utilizes cubemaps in which the environment is projected onto the six square
faces of a cube resulting in six square image textures. The same cubemap is used twice: First,
to create the reflection on the 3D object and second to display the skydome which is a projection of
the cubemap onto a very large sphere simulating the environment.
The enviroment cubemap is passed to the fragment shader where a reflection vector $R$ is computed out of the view direction $V$ and the surface normal $N$. OpenGL offers a function to lookup the corresponding texel to the reflection vector in the cubemap:
To quickly approximate the behavior of rough materials and reflections, the environment map needs to be blurred in some way. This learning module utilizes a technique presented by McGuire et al. [1] which can be quickly evaluated in a fragment shader and which does not need any pre-build assets. The method computes the proper mipmap levels according to the given roughness value by using the following formula:
$ l = \log_2(w \cdot \sqrt{3.0}) - 0.5 \cdot \log_2(\rho + 1) $
$ l: $ mipmap level, $ \rho: $ roughness, $ w: $ texture width
Note, that there are other, more sophisticated, methods for example
spherical harmonics environment mapping and Monte Carlo sampling.
[1] Morgan McGuire, Daniel Evangelakos, James Wilcox, Sam Donow and Michael Mara. 2013. Plausible Blinn-Phong Reflection of Standard Cube MIP-Maps. Technical Report, Williams College Department of Computer Science.