Vizard 7 » Tutorials & Examples » Appearance & texturing » Environment mapping » Tutorial: Environmental mapping
7.7

Tutorial: Environmental mapping

This tutorial will show you how to load environment maps and then automatically apply these to an object to create the illusion that the object is shiny and reflecting the environment around it.

This content is discussed in more detail in the reference section.

Loading environment maps

If you have trouble getting the code in this tutorial to work, you can find the complete example script envMap in the \tutorials\appearance directory.

 

After creating the empty script add the following initial code to it:

import viz
import vizact

viz.setMultiSample(4)
viz.fov(60)
viz.go()

viz.clearcolor(viz.SKYBLUE)

This will launch Vizard and set the background clear color to a nice sky blue.

 

Next, let's add the environment map. An environment map is made up of 6 textures. Each texture represents one side of a cube. This cube represents the surrounding environment of an object. This example will load the following 6 textures:

sky_posx.png
sky_negx.png
sky_posy.png
sky_negy.png
sky_posz.png
sky_negz.png

Vizard has a shortcut for loading environment maps. So go ahead and add the following line of code to your script:

env = viz.addEnvironmentMap('sky.jpg')

This creates an environment map texture. The second argument is the base name of the 6 textures. Vizard will automatically add the '_posx', '_negx', etc.  We can now apply the environment to the logo as if it were any other texture.

 

For additional examples, check out:

nodes

Loading environment maps

Applying environment maps