top of page
Writer's picturesith

OPENGL SOLAR SYSTEM

Updated: Nov 18, 2018


The OpenGL Solar System was a university project I created for Real-time Graphics and Rendering assessment. The rendering framework was given to us and our task was to create and interesting project by editing the framework as required and to use/ write our custom Vertex and Fragment Shader code.


VIDEO


EXTERNAL RESOURCES USED

  • 3D Models - 1 Poly Sphere, 1 Poly Sphere with a ring (for Saturn), 1 Poly Sphere with inverted normals for the Skybox/ Sky Sphere. All models were created in Maya by myself.

  • Textures – All textures used in the project are from www.solarsystemscope.com. All textures are free to use.

I have modified some of the textures in Photoshop to better fit the UVs on the 3D models I am using in the project.


SHADERS

THE SUN AND THE SKYBOX –

When I started the project, I was quite eager to make the final result I create look convincing. The biggest challenge of them all came to my attention when I created the Sun. Everything looked good except for the fact that it didn’t glow. I looked into my options and thought of implementing HDR and Bloom rendering features but unfortunately I didn’t not have much time to spare. Instead implementing advance rendering features in the limited time, I thought of going for a rather quick workaround which looks quite convincing. I implemented specular shading to my Skybox and made it render in the middle of the screen BEHIND the Sun mesh. Since the Skybox is larger than the Sun and the normal are inverted, its appears to behave like a glow around the Sun.



I have layered a number of subtle effects to the Skybox such as glowing stars to make it look lively.

The Sun shader is the most compelx shader in the project in my opinion. There are procedural techniques implemented in both the Vertex and the Fragment shader.

The vertex shader procedurally deforms the Suns vertices to make it look like a boiling ball of fire. The Sun fragment shader complements the vertex shader effects by procedurally adding texture and patterns with a base texture panning on top of it.


Code block (Refresh the page if the code block is not visible)

 

EARTH –

The shader used for Earth is the second most complex one in the project.

The vertex shader orbits Earth around the sun while making it spin in its own axis. Since this behaviour is common to all planets, I have used similar vertex code to transform all planets in the program.

The fragment shader for Earth has got lots of interesting things going on. I have used three separate textures to achieve the below effect. A Day-time texture, a Night-time texture and a Clouds texture. The textures Day-time and Night-time are blended based on the lighting on the surface. The Clouds texture pans across the surface of the planet. The opacity of the clouds texture varies based on the shading on the planet (Clouds opacity is higher on the lit side compared to the unlit side).


I have implemented spotlight type lighting system similar to what I learned from Unit workshops to shade the planets. The difference between the Spotlight system we learned during the workshops and my custom code is that I have implemented smooth falloff. It is controlled by the ‘Attenuation’ property.

I have also added Atmospheric lighting to the lit side of the planet to add a little bit of variance to colour. It behaves similar to a 3- colour gradient which scales based on ‘Attenuation’ and paints based on masks (0-1 black and white values) generated using lighting calculations.


Code block (Refresh the page if the code block is not visible)

 

THE MOON –

The vertex shader used for the Moon orbits the Moon mesh around the Earth and therefore the code required for its behaviour is different from the standard vertex shader behaviour of all planets. The vertex shader of the moon has the same code and property values of the vertex shader of Earth and the final transformation of Earth is used to transform the Moon.

The fragment shader used for the Moon is similar to the ones used for all planets except for Earth. It has got the same Spotlight lighting system as the Earth excluding Atmospheric lighting.



Code block (Refresh the page if the code block is not visible)

 

819 views0 comments

Recent Posts

See All

Comments


bottom of page