The Earth–Moon–Sun Dance
By Zihan Zhao→This Showcase enhances Assignment 6 with a complete real-time, procedural Earth–Moon–Sun system, integrating multiple shader modules and animation logic.
1. main.cpp – Animation, Camera, and Shader Integration
Real-time orbital mechanics for Earth and Moon “Follow Earth” camera with custom lookAt implementation Keyboard controls:
- A: toggle orbit animation
- L: locked camera mode
- H: reset
- Z: zoom
- R: reload shaders Passed real Sun position (sun_world_pos) into shaders for lighting Shader hot-reloading
2. planet.fs – Full Procedural Planet Renderer
Procedural Sun with animated convection (Perlin noise) Earth layers:
- oceans, coasts, land, mountains, deserts, snow, polar caps
- procedural clouds
- cloud shadowing
- Bump-mapped Moon terrain
- Fully procedural multi-octave starfield background
- Unified physically-inspired lighting model
3. model.glsl – Orbital Transform System
Transformation hierarchy:
- Sun
- Earth orbit
- Earth spin
- Moon orbit
- Moon tilt
- Moon scale
- Starfield sphere transform
- Tuned orbital parameters for realism
4. bump_height.glsl – Terrain / Height Modeling
Multi-layer Earth height: oceans → coasts → land → mountains → snow Procedural lunar crater approximation Height drives shading, cloud shadows, biome transitions
Acknowledgements
CSC317 Assignment 6 starter code libigl (icosahedron mesh utilities) GLFW (window / input) Eigen (math library) Ken Perlin (noise reference) GLAD (OpenGL loader)