Planet
Overview
This was a project I worked on for 1 month in December 2021.
For this project, I was given the task of creating the surface of an alien planet in Unity, implementing as many graphical features as possible in the process.
Below is a short video showing off the final product.
Mesh Creation
One of the optional extensions to this project which was outlined in the specification was to make a surface which extends as far as the planet can see. In order to achieve this aim, I decided to make the entire planet a single sphere. This would allow the surface to continue as far as the eye could see in a relatively short distance.
I generated the sphere by initially generating an icosahedron. I then subdivided each of the faces into small triangles. After this, I project each of the vertices to a unit sphere and then scale the object to its appropriate size. I chose this method for generating a sphere as it gave a more even distribution of vertices over the sphere than a cubic sphere and I was able to easily keep track of vertices to stitch them together to form a mesh, something which would have been far more challenging if I had decided to use a Fibonacci spiral to initially distribute the vertices.
After scaling the icosphere, layers of Simplex noise were applied to the vertices to create a low ocean bead, with a slightly higher low land and then increasingly jagged mountains placed on top of the land.
All spherical bodies in the world use the same mesh generation code, this includes the land and ocean of the planet as well as the sun and stars further in the distance. Though the sun and stars are much smaller spheres than the planet.
Texturing
For this project, I wrote a shader to texture the surface of the spheres. This shader applies various textures to the surface of the sphere where the displacement of the vertex from the centre of the sphere is the variable that controls which regions of the planet are covered in which texture. Using this method, sand is applied below the ocean and at the edge of the water, grass textures are applied to the lowlands, rocky textures are applied for most of the mountains and then snowy textures are placed at the peaks with some interpolation between textures being used to smoothly transition between zones. The shader uses tri-planar mapping to minimize the stretched look of textures on mountainsides.
Objects
Throughout the world are static objects which have been placed to add to the feel of the planet. These obejcts reopresent trees and geysers. The geyer's randomly erupt and release a particle effect periodically.
Lighting
The entire scene is primarily lit by a large point light positioned in the sun. As the sun orbits the earth for the simulation, this causes part of the planet's surface to be light while the other part is dark creating a day-and-night cycle. This effect is enhanced by the colour of the skybox being interpolated between a light blue when the sun is closest to the camera and a dark blue when the camera is furthest from the sun. In addition to this, stars are also turned on when the sun is at a certain distance from the camera. These stars are also icospheres and are distributed around the planet using a Fibonacci spiral. They appear to move across the sky throughout the night due to the planet rotating on its axis at all times like a real planet.