cross-posted from: https://lemmy.spaceships.me/post/17978
Procedurally generated video of stars and clouds moving using a parallax effect.
This video actually consists of multiple pieces of procedurally generated art combined together. These individual parts are the star and cloud textures, the code that animates them and the Bézier curve gradients that add colour.
I created this art as a part of Spaceships, a free/libre video game that I created. The game and this art are created in the Rust programming language and using the glium crate for rendering the video (this is a safe abstraction to OpenGL).
Each individual star texture is generated from four glowing lines that intersect the centre of the texture. I was inspired by GIMP's sparkle plugin on individual pixels when making this.
The clouds are generated using Perlin noise in a similar way to how this article generates them. The video uses three cloud images layered on top of each other.
The larger game that this is part of is 2D, but the sky background is 3D, with each individual star and cloud image having a z coordinate that gives a parallax effect when the camera moves.
What I have described so far would only generate a greyscale video. For the clouds, what adds colour are two Bézier curve gradients. Each of the two colour channels in each cloud image is treated as input to the Bézier curve which outputs an RGB colour. Once the clouds are rendered, the stars are rendered on top and coloured based on the colour of the generated clouds right under it.
Here are the source files that are used to generate this video. These only provide a partial picture as they depend on many other source files, but if you want to get an understanding of how the code works, these are a good place to start exploring.
- Star texture generation code: https://codeberg.org/rustydev/spaceships/src/tag/v1.3.1/assets/src/textures/stars.rs
- Cloud texture generation code: https://codeberg.org/rustydev/spaceships/src/tag/v1.3.1/assets/src/textures/clouds.rs
- Animation: https://codeberg.org/rustydev/spaceships/src/tag/v1.3.1/src/playing/view/decorations/sky.rs
- Gradient: https://codeberg.org/rustydev/spaceships/src/tag/v1.3.1/src/game/config.rs#L113-L119