the.bay.news

Sun Glow Particles Retired

programming.dev
Sun Glow Particles Retired
Project: Hadean chronicles. Particle-based glow system retired. Shader-based flares and sunspots now in production, fully verified visually. ## First Obstacle: The Edge-On Mesh The Sun’s CPU particle system rendered as a tiny red speck instead of a soft corona. After ruling out data issues, configuration problems, and surface artifacts, the real culprit revealed itself via a diagnostic force-opaque test. The glow quad mesh was facing edge-on to the camera, rendering to near-zero width under the fixed top-down perspective. Once this geometry issue was diagnosed, other mechanical problems became clear. The death-alpha on the color ramp had been commented out—particles just popped rather than fading. Outward radial acceleration was an entire hemisphere pointed inward, creating a frozen shell instead of a breathing corona. ## The Pivot: Swap Particles for Shaders CPU particles bring hidden costs: per-element simulation, alpha sorting, lifetime checks, and overdraw stacking. For a feature meant to complement a shader-driven surface, the limitations outweighed the benefits. The final decision: add flares and sunspots directly into the fragment shader. Eliminates draw calls, removes CPU simulation, and lifts the performance and visual ceiling. ## Shader Suite: Intrinsic Sun Effects The new sun sphere shader introduces two independent organic effects: - Flare Overlay — bright patches sampled from value noise and masked in via additive blending with soft fwidth() edges. Controls handle frequency, threshold, and intensity. - Sunspot Darkening — dark patches applied as shadows on the surface. To avoid visual clashes with flares, a separate noise sample uses different scale and a fixed phase offset, applied as a multiplicative dimmer after all additive light contributions. Both effects share a 2-hash, 3-octave value-noise utility—cheap, localized, and flickering in real time. ## Visual Duels: Tuning by Screenshot Several subtle regressions emerged with each adjustment, each caught and corrected through visual verification: - After decoupling flare frequency from texture tiling, the result looked fractured along hash-lattice edges. Switched to separate spherical UV sampling to fix aliasing. - With wavelength-limited scale, large regions of the disc interpolated into giant blocky polygons. Increased scale and added a third finer noise octave for smoother, smaller patches. - Early mixing caused sunspots to be invisible, hidden by additive core and rim passes that ignored the darkening mask. Moved the pass after all additive contributions. - Sunspot coverage was too heavy, producing oversized, blurry blotches. Tightened threshold and raised scale for sparse, smaller, crisper spots. ## Outcome The particle system code remains in place but dormant, with the glow emission call commented out. A planned hybrid (shader + dedicated arc sprites) was discussed but not adopted. The shader implementation now delivers a living, breathing corona without expensive particle infrastructure.

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.