======================
Skyboxes and Cube Maps
======================

A skybox is a method for creating the illusion of distant three-dimensional surroundings in your scene. Images are applied as textures to each of the six faces of a cube with the viewer placed in the middle of the cube or skybox. As the viewer moves around the scene, the skybox images remain stationary so that they seem infinitely distant like the horizon in a seascape.

.. csv-table::

	.. image:: images/skybox_cube_faces.jpg, .. image:: images/skybox_example_faces.jpg

*This figure shows how textures map onto a skybox.*
  
Before we create a skybox in HOOPS, we need to create with ``Define_Texture``. In the call to ``Define_Texture``, we pass six image image "sources" to essentially create a cube map. The sources are applied to the cube map in the following sequence: negative Z-plane, positive Z-plane, negative X-plane, positive X-plane, negative Y-plane, and positive Y-plane. Additionally, we can also set the "camera" option which tells HOOPS which segment contains the camera information for the skybox. Once you have defined the texture for your skybox, call ``Set_Color`` under a driver instance using the "windows" option to set the skybox texture. HOOPS will recognize the window backdrop as a texture with six sources and create a skybox from it.

.. tabs::

	.. group-tab:: C++
	
		.. literalinclude:: ../../../../demo/common/sanity/0700_docs_0021.cpp
		   :start-after: //! [materials9]
		   :end-before: //! [materials9]
		   
.. image:: images/056b_ApacheCubemap.png

*A helicopter flying by a mountain range created using a skybox and a cube environment map derived from the same texture source.*

You can also use the cube map texture as an environment map on faceted geometry as seen in the sample code below:


.. tabs::

	.. group-tab:: C++
	
		.. literalinclude:: ../../../../demo/common/sanity/0700_docs_0021.cpp
		   :start-after: //! [materials10]
		   :end-before: //! [materials10]
