Posted November 12, 2024 by Layoff Games
In this post, I'll dive into the technical side of the colors in Starfire Skies, focusing on the colors of the stars. The firework system in Starfire Skies features a wide variety of effects, allowing for dynamic colors and patterns.
In real fireworks, the colors are created by using different chemical compounds that emit specific colors when heated to a plasma state. To reach this plasma state, pyrochemists combine oxidizers with fuels to sustain a reaction. Depending on the exact mixture of oxidizer, fuel, and colorant, a firework’s brightness and duration can be adjusted. Advanced techniques even layer these compounds to produce effects like color changes and strobes, where a firework might shift from red to blue or create a pulsing white light.
Creating these effects digitally might seem complex, but Godot provides a straightforward solution for controlling colors and their intensity: the GradientTexture1D. This feature allows us to define a one-dimensional array of RGBA colors, including HDR options for vivid intensity. We can then sample this gradient over time (from 0 to 1) to control the color transition for each firework.
In Starfire Skies, each "star" (the bright particles after a firework explosion) has a lifetime that begins when it explodes and ends when it fades out. This lifetime serves as a reference to sample the gradient, starting at 0 and ending at 1. We can even loop through the gradient multiple times to achieve strobe effects. Since alpha values are also part of the gradient, we can create fade-outs or strobes as the stars decay. For added variety, each star can begin at a random point within the gradient, producing explosions with a vibrant spectrum of colors that transition independently over time. (It’s worth noting that the gradient's start and end should match in color for smooth transitions.)
The trails of the fireworks are managed differently because they use a particle system, but they still rely on the same gradient texture to determine color shifts throughout their lifetime. This consistency keeps the stars and trails harmonized while allowing for varied effects.
This is a glimpse into how Starfire Skies generates colorful fireworks. Follow for more updates on the development of Starfire Skies! If you'd like less technical overviews, let me know!
In next week’s post, I’ll explore how card effects are created in Starfire Skies and the process behind designing them. Thanks for reading!