From b7461cef995b6f6fe6704049563c398dda3271f1 Mon Sep 17 00:00:00 2001 From: Tibo De Peuter Date: Fri, 13 Dec 2024 21:50:35 +0100 Subject: [PATCH] docs(7): Add section descriptions --- src/7_planet.fs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/7_planet.fs b/src/7_planet.fs index e065603..4681e40 100644 --- a/src/7_planet.fs +++ b/src/7_planet.fs @@ -59,7 +59,7 @@ void main() normal = normalize(normal); /* * * * * * * - * Color * + * Color-pre * * * * * * * */ float sun_specular_exponent = 1000.0; vec3 ka = vec3(0.1, 0.1, 0.1); @@ -69,7 +69,12 @@ void main() float bump = bump_height(is_moon, normalize(sphere_fs_in)); if (!is_moon) { - if (bump < 0.0) { /* Water */ + /* * * * * * * + * Planet * + * * * * * * */ + + /* Water */ + if (bump < 0.0) { kd = vec3(0.2, 0.35, 0.8); sun_specular_exponent = 4000.0; @@ -84,7 +89,9 @@ void main() normal = normal_dir + normal*wave; normal = normalize(normal); - } else { /* Land */ + } + /* Land */ + else { ks = vec3(0.0, 0.0, 0.0); kd = vec3(0.2, 0.8, 0.3); @@ -102,6 +109,7 @@ void main() kd *= terrain_color; } + /* Clouds */ // Generate clouds, by creating cloud clusters and then filling those clusters with clouds. vec3 cloud_rotation = vec3(animation_seconds * cloud_speed, 0.0, animation_seconds * cloud_speed); @@ -124,6 +132,7 @@ void main() // Modify the normals to make the clouds look fluffy normal = mix(normal, normal_dir, cloud); + /* Color */ color = blinn_phong(ka, kd, ks, sun_specular_exponent, normal, view_dir, light_dir); /* Twinking lights */ @@ -154,10 +163,15 @@ void main() color = clamp(color, 0.0, 1.0); } } else { + /* * * * * * * + * Moon * + * * * * * * */ + kd = vec3(0.2, 0.2, 0.2); sun_specular_exponent = 500.0; ks = vec3(0.1, 0.1, 0.1); + /* Charcoal color */ float charcoal = perlin_noise(sphere_fs_in.xyz * 2.3); charcoal = pow(charcoal, 0.3); charcoal = 1.1 * smoothstep(0.1, 0.9, charcoal); @@ -168,9 +182,10 @@ void main() // Smoothen the bumped normal normal = mix(normal, normal_dir, 1 - charcoal); + /* Color */ color = blinn_phong(ka, kd, ks, sun_specular_exponent, normal, view_dir, light_dir); - /* Add charcoal glow */ + /* Charcoal glow */ color = mix(color, kd, 1.0 - charcoal); float glow_intensity = perlin_noise(vec3(0.25 * animation_seconds)); glow_intensity = pow(glow_intensity, 0.3);