Floating in the Atmosphere

Makenna Johnstone - CPE 471 - Winter 2017 - Zoe Wood

Project Description

I have always been intrigued with the phases of the moon and their effect on the earth. This project places viewers inside of a space-like scene with mountain ranges, alpines lakes and an orbiting moon. As the user travels around the world, they will be able to notice the changes in lighting on the scene as the moon changes position. Both the moon and the water are animated using mathematical equations with respect to time.

initial view of scene


Triplanar Texture Mapping

Triplanar texture mapping is used on the mountains to make them appear more realistic. Terrain with varying heights and steep cliffs that do not use triplanar texture mapping will often appear stretched and unrealistic. This technique produces realistic texture by rendering the texture 3 times in 3 different directions: x, y, and z axes. These renderings are all blended together allowing a fragment to contain different ratios of texture from each axis.

triplanar texture mapped mountains

Texture Mapping

Both the moon and the water are texure mapped. Because my texture for the moon was extremely large, I had to use the stb_image API instead of the tiny_obj_loader.h to load it. Stb image only required one line of code to load the image from the file.

texture mapped moon

texture mapped water

Blinn-Phong Lighting

In this scene, the moon serves as a directional light. As it changes position, the light on the scene is calculated using the Blinn-Phong shading equation. As you can see in the gif below, the scene is most lit when the moon is at the peak of its orbit. As it travels along the elliptical path the scene gradually darkens.

lighting effects


Movement in this scene is related to time. The moon orbits around the scene using the parametric equation for an ellipse. Each of the texture coordinates mapped to the water has a sin function applied to it, making its movement appear more realistic.


The surrounding area in this scene is rendered using a cubemap, which is basically a texture that contains 6 individual 2D textures to form each side of the cube. See Resources below for the source of the cubemap that I used.

User Interaction

The user is able to move around in the world using the following controls:

  • W: Move forward
  • S: Move backward
  • A: Move right
  • D: Move left
  • X: Start and stop the moon

  • Cursor down: Look up
  • Cursor up: Look down
  • Cursor left: Look left
  • Cursor right: Look right