Contents
What does a skybox do in OpenGL?
A skybox is a technique that makes the scene looks bigger and more impressive by wrapping the viewer with a texture that goes around the camera 360 degrees. The texture is often a combination between the sky and a terrain type such as mountains, skyscapers, etc.
Can a cube map be used to render a skybox?
Using a cube map texture will allow our vertices to double as texture coordinates. Will will also use the OpenGL Mathematics library and the keyboard and joystick handler from my previous posts to update the rotation on the skybox. Below is a screen capture and video rendering of the result. A frame captured from our skybox rendering.
How to create a texture for a skybox?
An example skybox texture. The code to load our images into a cube map texture looks something like what follows. We can pass each of our six images to the overloaded setupCubeMap function. This will generate a cube map texture, set some parameters, and specify the texture images.
How to create a cube map in OpenGL?
We’ll use GLSL to implement a couple simple shaders. We will create an OpenGL program object to which we will bind our vertex and fragment shaders. A Vertex Buffer Object will be used to store our cube vertices and another to store the indices for the faces.
What kind of texture does a skybox have?
The texture is often a combination between the sky and a terrain type such as mountains, skyscapers, etc. As the player explores his surroundings he keeps seeing a part of the skybox hovering above the real models and filling up all those empty pixels. Here’s an example of a skybox from the game Half-Life:
How to use the Cubemap texture in OpenGL?
(ogldev_cubemap_texture.h:28) This class wraps the OpenGL implementation of the cubemap texture and provides a simple interface to load and use the cubemap. The constructor takes a directory and six filenames of image files that contain the cubemap faces.
What do you call a texture in OpenGL?
OpenGL calls such a texture a Cubemap . In order to sample from the cubemap we will use a 3D texture coordinate instead of the 2D coordinate that we have been using thus far.