Skip to content

About

3D Render Engine with GLFW, GLAD, GLEW & glm

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

Render-Engine

3D Render Engine with GLFW, GLAD, GLEW & glm

Startup laboratories

The app opens at a main menu. Choose Planetorium for either Solar System - 1:1 scale or the Gargantua system. Choose Quantum Simulation for 38 selectable examples: infinite-well states and superpositions, harmonic-oscillator states, coherent and squeezed states, free packets, 3D hydrogen orbitals, spin states, Bell states, and numerical tunneling/scattering experiments.

F10 returns to the main menu and pauses playback. F2 toggles orbital trajectories, F3 toggles information, F4 browses all star systems, and Shift+F4 browses only the current system's planets and other bodies. Home shows the overview. Select a body in the right-hand list and press G, double-click it, or click Go to selection. T follows its position; Shift+R toggles following both its position and rotation. Both astronomical scenes use physical AU distances, double-precision camera coordinates and camera-relative rendering. Gargantua uses 100 million solar masses; Miller has Earth's radius. Its 6.12 AU orbit is a stable Schwarzschild approximation, not the film's near-horizon Kerr orbit.

The solar preset includes the Sun, eight planets, Pluto, Ceres, Vesta, Eris, a representative Halley orbit, seven moons, and 4,096 representative main-belt/Kuiper-belt markers. Planet positions use fixed J2000 Keplerian elements; surfaces are procedural illustrations. This is not a current-date ephemeris or a complete survey catalogue. Solar-system time can advance by seconds, minutes, hours, days, 30-day months, or Julian years per real second. Quantum examples use separate dimensionless time rates of 0.1x to 4x; Ctrl+R restarts the selected state. Their 3D view occupies the upper 80% of the workspace, with a small graph below. Home frames the state. Hydrogen clouds sample the true 3D orbital probability; 1D states use illustrative transverse thickness.

See the detailed changes and reasons for every changed component, equations, sources, accuracy boundaries, and validation instructions.

Controls

  • Mouse wheel changes flight speed gradually by 15% per notch; fractional wheel input is preserved. Scroll down to slow down. Physical flight speeds display in m/s, km/s or AU/s.
  • Space or Play / Pause starts and pauses playback. The application starts paused. The disk, ocean waves, planet rotation, and orbits share the playback clock.
  • < / > (comma / period) or the Time slower / Time faster buttons select one second, one minute, or one hour of simulated time per real second (1×, 60×, 3600×). The title shows local observer time and world playback time as HH:MM:SS.
  • Black hole / Model switches the legacy scenes and resets the view.
  • Miller flyby moves close to the ocean planet and follows its orbital translation. You can fly around it while following.
  • Spacecraft moves close to the ring-shaped spacecraft and follows it. Boost / B starts its prograde booster manually. Ctrl+R restores its initial orbit and fuel at the current playback time.
  • Home view or Home returns to a scene overview and exits planet-follow mode.
  • Right mouse button toggles mouse-look capture. Hold Shift + right mouse button and move the mouse forward or backward to zoom; press the middle mouse button to reset the zoom. Esc releases the cursor for the clickable Windows controls. Changing window focus also releases it.
  • WASD moves forward, backward, and sideways. Q / E rolls the free-flight camera left/right; R / F moves up/down along its local up axis. Left Shift gives a temporary 5× speed boost. Grounded cameras retain their gravity-aligned upright orientation; use L to lift off before rolling.
  • [ / ] or Slower / Faster halves or doubles flight speed. The title shows the selected speed. Camera speed operates independently of playback time.
  • F1 switches between wireframe and shaded rendering.
  • N / New terrain is retained for the legacy scene; its black-hole planets now use ocean-only surfaces. Regular generated systems retain unique seeded terrain.
  • L / Land / lift off places the free camera above the selected/nearest solid planet's terrain or sea surface, or releases it back into flight. The physical observer envelope uses Hubble's 13.2 m length and 4.2 m diameter, with conservative 6.6 m center clearance. Movement and mouse-look remain available. The surface rotates and orbits under the observer. Miller flyby approaches near the day/night boundary; a wide lens helps show the giant black-hole shadow from the surface.
  • Left-click with the cursor released selects a planet, star, spacecraft, or black hole. Its name appears in the title. G / Go to selection jumps close to its current position. Free-cam remains active after arrival.
  • H / Gravity toggles the observer's plunge, including while world playback is paused. The selected time rate accelerates observer time. Mouse-look remains available; gravity owns translation. The other agents' horizon/interior visualization is retained, with an inner rendering cutoff. This hybrid Newtonian/clock model is not a full relativistic infall solution. Home resets the view.
  • F6 / Photon view toggles illustrative photon packets. Gold packets originate in the accretion disk, cyan packets originate at the spacecraft, and a green point marks a detector fixed at the camera position when enabled. Fly sideways to inspect the streams. Toggle off and on to reposition the detector. Packet motion pauses with playback.

The title distinguishes World playback time from Local observer time. The local clock applies approximate gravitational and velocity time-dilation factors. Light age reports how far into the spacecraft's simulated past the received image looks.

The legacy model-viewer cube rotates with playback. Dropped OBJ and FBX models keep their original transforms and open the model viewer.

WindowManager::GetSimulationTime() returns elapsed playback time in seconds as a double. A simulation scene can use this value to animate its state or pass it to a shader. A numerical solver can use it as the target time for fixed-size integration steps.

Black-hole scene

The scene contains a Gargantua-inspired black hole, a procedural accretion disk, five orbiting stars, three terrain planets including a Miller-inspired world, a ring-shaped spacecraft, and a background star field. Each stellar and planetary orbit has its own semi-major axis, eccentricity, inclination, and phase. Smaller orbits have shorter periods, and bodies move faster near periapsis according to Keplerian motion. These paths are analytic solutions of the central-gravity equations. NASA's explanation of orbital motion

The GPU integrates Schwarzschild photon paths to render the disk's bent secondary images and the capture shadow. It evaluates gravitational and orbital Doppler frequency shifts at disk intersections, including the bent ray's emission direction. Shifted blackbody temperatures control emitted colors and brightness. Disk material approaching the observer becomes brighter and bluer, while receding material becomes dimmer and redder. Schwarzschild photon acceleration equations, NASA's disk visualization

Model assumptions

  • The spacecraft advances double-precision position and velocity through gravity and prograde thrust with adaptive kick-drift-kick substeps. Its controller starts an inbound burn around 8.63 AU. The former scaled experiment's thrust and fuel duration are converted to the new physical time/length units; this is fictional high-performance propulsion, not a calibrated spacecraft engine. The ring diameter is approximately 50 m. Exhaust reflects the booster state, and the trail stores sampled simulated positions. The title reports coasting, boosting, capture, or positive-energy escape. Gravity bends the trajectory, and thrust supplies the additional orbital energy.
  • Spacecraft attitude guidance keeps the ring axis radial, with a constant spin rate. Its exhaust follows the opposite direction to prograde thrust. Full rigid-body torque and attitude dynamics remain future work.
  • The central object uses the non-spinning Schwarzschild model. The Gargantua name describes the visual inspiration. Kerr spin and frame dragging remain future work.
  • Orbital motion uses independent Newtonian test-particle ellipses around a fixed central mass. Gargantua has 100 million solar masses, a 1.974 AU Schwarzschild horizon, and an Earth-radius Miller analogue at 3.1 horizon radii. Other planet/star properties remain synthetic. AU and physical seconds replace the original demonstration units.
  • The local clock records elapsed playback time. The observer clock estimates local proper time. The film's extreme time-dilation ratio and near-horizon orbit require Kerr spin, which remains unimplemented.
  • The camera samples the local static observer frame at its position. Flight speed controls navigation. Velocity-dependent observer aberration and Doppler effects apply to disk rays. The light integrator also remaps the complete source scene, including galaxy images, using a static sky cube for directions outside the camera image. Finite-body warping is a depth-aware screen-space approximation.
  • Photon integration has a finite step budget. The orbiting bodies and background stars use rasterization, and compositing their depth against the lensed disk is approximate.
  • Ocean waves, foam, and reflections use procedural visual approximations. Film-scale tidal waves and ocean fluid dynamics remain future work.
  • Emission uses a three-wavelength Planck-spectrum display approximation. Catalogue star temperatures and luminosities match their generated metadata. Exposure is adjustable; HDR and pure exposure are available. Lens-dependent source glare is an illustrative optical model, not measured flare calibration.

CPU and GPU work

The GPU handles photon integration, disk appearance, redshift, Doppler effects, spectral colors, ocean displacement, foam, lighting, and rasterization. The CPU handles eight analytic orbital positions and velocities, spacecraft force integration and fuel, the playback clock, camera movement, and draw submission. V-sync limits unnecessary rendering between display refreshes.

The Performance menu offers a one-click Cooler mode (30 FPS / 50% black-hole resolution), plus 30/60/120 FPS and 50/75/100% choices. Defaults are 60 FPS and 75% resolution. Menu, unfocused and unchanged paused views cap at 30 FPS. Paused stationary views reuse the last rendered scene instead of tracing light again. Inactive star systems stay dormant; catalogue stars are uploaded once. Orbit curves and position queries are cached, belt markers refresh at a maximum 300 simulated seconds between samples, and sub-pixel bodies/atmospheres are culled. These approximations target lower rendering load; no hardware-temperature reduction has been measured.

Vision / Lens contains Off, Subtle and Standard flare settings. Flares come from a tiny GPU bright-source extraction pass and analytic glare/diffraction. The old mirrored-image ghosts are removed. Three galaxy appearances use the original spiral and a new barred-spiral/elliptical atlas; see asset provenance and generation prompts.

Stellar activity

Stars now have GPU-rendered prominence arcades, flowing plasma strands, bright active regions, dark spots, moving granulation, and limb darkening. This works on the Sun, generated system hosts, and resolved stars in Gargantua's scene. Stellar activity in the top menu has On, Off, and Trigger eruption on visible stars. Trigger also enables activity in the active scene. To inspect the Sun, use Shift+F4, select the Sun, and press G.

Space pauses/resumes the stellar effects with the rest of the simulation. > increases the time rate; 60x or 3600x makes the minute/hour-scale evolution easier to see. The inspection eruption starts immediately and fades over several simulated minutes. Reduce exposure for surface detail. Distant stars skip prominence geometry, and unchanged paused scenes retain the existing render cache.

These are deterministic procedural plasma visuals with an enhanced emission-line-inspired palette. They do not solve magnetohydrodynamics, predict stellar activity, or apply radiation/CME forces to nearby objects. Temperature changes their appearance using a visual heuristic. See the implementation changes and reasons.

Change log and reasons

The entries below record earlier implementation stages. Current behavior is described above; later replacements and their reasons are recorded in the current detailed log.

  • src/BlackHole.cpp owns scene shaders, geometry, bodies, GPU light tracing, and rendering so simulation-specific graphics stay together. It generates shared sphere geometry, spacecraft ring geometry, and a deterministic background star field to avoid external asset dependencies. A full-screen shader traces light into the disk and horizon so the disk produces bent images. The ocean shader adds rotating swells, foam, and highlights so the planet can be inspected up close. The spacecraft controller, finite fuel, adaptive stepping, bounded trajectory buffer, and engine exhaust expose the result of force integration. Reset and manual boost allow the initial experiment to be repeated or altered. Metallic shading, spokes, and modules make the ring craft recognizable at close range.
  • src/BlackHole.h declares scene initialization, updates, rendering, cleanup, and position queries. The camera uses the queries to follow the planet or spacecraft. It stores spacecraft state, fuel, and trajectory samples between frames.
  • src/OrbitalMechanics.cpp contains the shared equations for mean motion, Kepler's equation, orbit orientation, analytic position and velocity, particle gravity and thrust integration, gravitational frequency ratios, and the GLSL relativity functions. Keeping these equations together lets the scene call them without embedding the physics throughout its rendering code. Analytic stellar orbits avoid accumulated integration drift during accelerated playback. The spacecraft integrates forces so booster commands change its subsequent trajectory. Input checks reject invalid ellipses, observer positions, and particle inputs.
  • src/OrbitalMechanics.h declares the orbital parameters and equation interfaces. Scene distances use scaled units and orbital angles use radians.
  • src/WindowManager.h adds scene ownership, scene selection, planet and spacecraft following, mouse capture, flight speed, time-rate selection, title refresh timing, and graphics cleanup declarations. These values persist between GLFW callbacks and frames.
  • src/WindowManager.cpp initializes and renders the black-hole scene, adds native clickable Windows controls and keyboard equivalents, and routes successful model drops back to the model viewer. Mouse capture becomes explicit so the controls can be clicked. Vertical movement and adjustable speed support close inspection and travel. Camera motion remains usable while paused. Home and scene switching reset the view, and the flyby follows orbital translation. The title displays the local clock, playback multiplier, and flight speed. Playback starts paused so Space visibly starts animation. Observer movement stays outside the horizon for the static-observer redshift equations. Graphics cleanup releases scene buffers and shaders while the OpenGL context is available. Windows headers load before engine headers to avoid SDK symbol conflicts. V-sync reduces redundant GPU frames.
  • src/main.cpp calls graphics cleanup before GLFW termination so GPU resources are released with a live context.
  • Render-Engine.vcxproj includes the new source and header files so Visual Studio builds the scene and equations.
  • README.md documents the controls, physics assumptions, CPU/GPU responsibilities, and reasons for the changes.

The spacecraft controls in src/WindowManager.cpp add close following, manual boost, reset, and a live flight-status title so the physical flyby can be inspected and repeated. The spacecraft view initially places the black hole behind the craft, matching the reference's viewing arrangement.

The shared sphere mesh in src/BlackHole.cpp uses higher tessellation to resolve the ocean displacement during close inspection. Its spacecraft attitude basis keeps the ring visible during the close flyby, and translucent blue-white exhaust makes the engine state visible.

  • src/PlanetTerrain.cpp and src/PlanetTerrain.h add seeded 3D value noise, five-octave fBm, and a ridge contribution for Musgrave-style terrain. Shared vertex and fragment functions keep the displaced surface and its shading consistent. Elevation controls beaches, vegetation, rock, snow, and ocean-depth colors. CPU counterparts evaluate the same surface for camera collision. Sampling normalized 3D coordinates avoids a texture seam at longitude wrapping. These are procedural terrain approximations, with finite mesh resolution and a small camera clearance above the surface. Musgrave fractal noise
  • src/Atmosphere.cpp and src/Atmosphere.h add GPU integration through an exponential atmosphere. Wavelength-dependent extinction and a Rayleigh-like phase function produce a blue limb, atmospheric haze, and attenuation of stars from the surface. Planet shadowing changes illumination between day and night. A copied scene texture allows atmospheric transmittance to affect the rendered space background. This uses a single-scattering approximation, illustrative density, a point light at the disk center, and spherical ground clipping. Clouds, weather, multiple scattering, and precise foreground-depth compositing remain future work. Atmospheric scattering geometry
  • src/BlackHole.cpp and src/BlackHole.h add two planets, per-planet terrain seeds, and an atmosphere on all three planets. A deterministic catalogue contains 1,600 local stars and 5,400 stars across three spiral groups. These finite, scaled star distributions have selectable positions and render as spheres nearby. Their galactic motion and mutual gravity remain unmodeled. Target queries supply current positions and names for selection and travel. Landing queries identify the nearest planet and its rotating surface.
  • src/BlackHole.cpp and src/BlackHole.h also retain spacecraft position, velocity, and booster history. The displayed craft is sampled at an emission time whose estimated arrival matches the observation time. Historical engine state drives the visible exhaust. Navigation targets its current state. The trajectory line is a simulation guide showing its physical path. History samples become farther apart as the mission ages to limit storage growth.
  • src/OrbitalMechanics.cpp and src/OrbitalMechanics.h add observer clock-rate estimates and direct-path light-travel delay with a first-order Shapiro term. The camera's velocity adds Doppler shifts and aberration to disk rays. Spacecraft light delay uses recorded Newtonian motion and a direct-path approximation. Strong-field multiple-image arrival times, complete relativistic body dynamics, and Kerr spin remain unimplemented. The model produces modest clock differences at these orbital radii. The film's years-to-hours ratio requires additional relativistic modeling. Black-hole clock rates
  • src/WindowManager.cpp and src/WindowManager.h add terrain regeneration, landing constraints, free-cam gravity, mouse picking, G travel, separate local/world clocks, and a light-age readout. Surface mouse-look uses the local up direction. Near clipping changes during landing to show nearby ground. Far clipping expands during space flight to include the generated star groups. Reset and flyby controls clear gravity and landing constraints. Pointing at a destination changes selection while the simulation continues.
  • src/BlackHole.cpp and src/BlackHole.h add a bounded GPU point buffer for 128 photon markers and a detector marker. Packets use straight illustrative paths and playback time scaled by estimated travel duration. This debug view samples the disk and craft. The disk image itself continues to use the separate Schwarzschild ray integrator.
  • Render-Engine.vcxproj registers the terrain and atmosphere source/header files so the normal Visual Studio build includes both features.

About

3D Render Engine with GLFW, GLAD, GLEW & glm

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages