// SPDX-FileCopyrightText: 2025-2026 lmblender contributors // SPDX-License-Identifier: MIT // Saturn and its main rings to scale, in units of the equatorial radius // (60,268 km). The planet is oblate (polar/equatorial = 0.902). Ring edges: // C ring 1.239-1.527, B ring 1.527-1.951, Cassini Division 1.951-2.027 (the gap // cleared by the 2:1 resonance with Mimas), A ring 2.027-2.269 with the Encke // gap at 2.214. The rings are drawn 0.002 thick; the real ones are ~10 m. // We look from 16 degrees above the ring plane; the Sun is 17 degrees above it // on the left, so the planet throws its shadow across the rings behind it. // Writes images/saturn-rings.png. out = ARGV.len() > 0 ? ARGV[0] : "build/saturn-rings.dslb"; mkdir("images"); mkdir("build"); if (!file_exists("build")) { mkdir("build"); } if (!file_exists("build/rendered")) { mkdir("build/rendered"); } p = _lmcode_ cli="lmblender" install="github:lmctl-ai/lmblender@v0.3.6"; let planet = scene.uv_sphere(1.0, 128, 96, true); planet.scale(1.0, 1.0, 0.902); planet.set_material(scene.noise_material(0.84, 0.70, 0.49, 0.74, 0.60, 0.40, 1.2, 0.7)); for (k in range(0, 4)) { let r_in = 1.239; let r_out = 1.527; let g = 0.28; if (k == 1) { r_in = 1.527; r_out = 1.951; g = 0.85; } if (k == 2) { r_in = 2.027; r_out = 2.202; g = 0.62; } if (k == 3) { r_in = 2.226; r_out = 2.269; g = 0.62; } let mid = (r_in + r_out) * 0.5; let half = (r_out - r_in) * 0.5; let path = ""; for (i in range(0, 361)) { let a = float(i) * 3.14159265 / 180.0; if (i > 0) { path = path + ";"; } path = path + str(mid * cos(a)) + "," + str(mid * sin(a)) + ",0.0"; } let profile = str(-half) + ",-0.002;" + str(half) + ",-0.002;" + str(half) + ",0.002;" + str(-half) + ",0.002"; let ring = scene.loft(path, profile, false); ring.set_material(scene.material(g, g * 0.93, g * 0.8, 0.0, 0.85, 0.0, 0.0, 0.0, 0.0, 0.0)); } scene.world_color(0.0, 0.0, 0.0, 0.0); scene.sun_light(0.86, 0.42, -0.29, 1.0, 0.96, 0.9, 4.5, 0.5); scene.camera_look_at(-1.6, -9.0, 2.6, 0.0, 0.0, -0.1, 25.0); scene.render_settings(8, 3, true); scene.render_png("images/saturn-rings.png", 32, 900, 560); end _lmcode_ savedsl(p, out); argv = dsl_cli(p); push(argv, "--lmcode"); push(argv, out); r = system(argv, 240000); if (r.code != 0) { println(trim(r.stdout)); println(trim(r.stderr)); } assert(r.code == 0); println("wrote images/saturn-rings.png"); run = system ${dsl_cli(p)} --lmcode ${out}; if (run.code != 0) { println(str(run.stderr)); lm_exit(run.code); }