Below is a GLSL shader written in Shadertoy syntax that creates a realistic, animated, growing cloud effect with a baroque-inspired color palette. Baroque art often features dramatic contrasts, rich golds, deep blues, and warm reds, so I've incorporated those tones into the cloud rendering. The shader uses 3D noise for cloud generation, animation for growth, and lighting to enhance realism.
To use this in Shadertoy, simply paste the code into the editor on shadertoy.com and hit "Compile." You can tweak parameters like CLOUD_SCALE, CLOUD_SPEED, and the color palette to customize the effect.
// Realistic Growing Cloud Effect with Baroque Color Palette
// Shadertoy GLSL
// Noise functions
float hash(vec3 p) {
p = fract(p * 0.3183099 + 0.1);
p *= 17.0;
return fract(p.x * p.y * p.z * (p.x + p.y + p.z));
}
float noise(vec3 x) {
vec3 i = floor(x);
vec3 f = fract(x);
f = f * f * (3.0 - 2.0 * f);
return mix(mix(mix(hash(i + vec3(0, 0, 0)), hash(i + vec3(1, 0, 0)), f.x),
mix(hash(i + vec3(0, 1, 0)), hash(i + vec3(1, 1, 0)), f.x), f.y),
mix(mix(hash(i + vec3(0, 0, 1)), hash(i + vec3(1, 0, 1)), f.x),
mix(hash(i + vec3(0, 1, 1)), hash(i + vec3(1, 1, 1)), f.x), f.y), f.z);
}
float fbm(vec3 x) {
float v = 0.0;
float a = 0.5;
vec3 shift = vec3(100);
for (int i = 0; i < 6; ++i) {
v += a * noise(x);
x = x * 2.0 + shift;
a *= 0.5;
}
return v;
}
// Cloud parameters
#define CLOUD_SCALE 0.2
#define CLOUD_SPEED 0.1
#define CLOUD_HEIGHT 0.5
#define CLOUD_DENSITY 0.4
// Baroque color palette
vec3 baroqueSky(vec2 uv) {
// Deep blue to gold gradient for the sky
vec3 deepBlue = vec3(0.05, 0.1, 0.3);
vec3 gold = vec3(0.8, 0.6, 0.2);
return mix(deepBlue, gold, uv.y * 0.5 + 0.5);
}
vec3 baroqueCloud(vec3 col, float density) {
// Warm golds, reds, and hints of deep blue for clouds
vec3 baseCloud = vec3(0.9, 0.7, 0.3); // Gold
vec3 highlight = vec3(1.0, 0.9, 0.7); // Bright gold
vec3 shadow = vec3(0.3, 0.1, 0.1); // Deep red
vec3 mixCol = mix(shadow, baseCloud, density);
return mix(mixCol, highlight, smoothstep(0.4, 0.8, density));
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = fragCoord / iResolution.xy;
vec2 p = uv * 2.0 - 1.0;
p.x *= iResolution.x / iResolution.y;
// Background sky with baroque gradient
vec3 col = baroqueSky(uv);
// Raymarching setup
vec3 ro = vec3(0.0, 0.0, -3.0); // Ray origin
vec3 rd = normalize(vec3(p, 1.0)); // Ray direction
// Cloud animation and growth
float time = iTime * CLOUD_SPEED;
float growth = smoothstep(0.0, 10.0, iTime); // Clouds grow over time
// Cloud volume
float t = 0.0;
float density = 0.0;
for (int i = 0; i < 64; i++) {
vec3 pos = ro + rd * t;
float cloudHeight = CLOUD_HEIGHT * growth;
if (pos.y > cloudHeight) break; // Exit if above cloud layer
// Sample cloud density using FBM noise
float n = fbm(pos * CLOUD_SCALE + vec3(0.0, time, time * 0.5));
float cloud = smoothstep(CLOUD_DENSITY, 1.0, n) * growth;
density += cloud * 0.1; // Accumulate density
t += 0.1;
}
// Lighting
if (density > 0.0) {
vec3 lightDir = normalize(vec3(1.0, 0.5, -0.5));
vec3 cloudPos = ro + rd * t;
float light = max(0.0, fbm(cloudPos * CLOUD_SCALE + lightDir * 0.1) - fbm(cloudPos * CLOUD_SCALE)) * 5.0;
density = clamp(density + light, 0.0, 1.0);
// Apply baroque cloud colors
vec3 cloudCol = baroqueCloud(col, density);
col = mix(col, cloudCol, density);
}
// Final color with some post-processing
col = pow(col, vec3(0.8)); // Gamma correction for richer colors
col = mix(col, vec3(0.9, 0.8, 0.6), 0.1); // Slight warm tint for baroque feel
fragColor = vec4(col, 1.0);
}
Explanation of the Shader:
-
Noise Functions:
- The shader uses a 3D hash function and Perlin noise (
noise) to generate smooth, organic cloud shapes.
- The
fbm (Fractional Brownian Motion) function layers multiple octaves of noise to create detailed, turbulent cloud structures.
-
Cloud Animation and Growth:
- The
time variable animates the clouds by offsetting the noise over time, creating a sense of movement.
- The
growth variable uses smoothstep to make the clouds gradually appear and grow over the first 10 seconds.
-
Baroque Color Palette:
- The sky transitions from deep blue (
vec3(0.05, 0.1, 0.3)) to warm gold (vec3(0.8, 0.6, 0.2)), evoking the dramatic skies of baroque paintings.
- Clouds are colored with a mix of gold (
vec3(0.9, 0.7, 0.3)), bright highlights (vec3(1.0, 0.9, 0.7)), and deep red shadows (vec3(0.3, 0.1, 0.1)), inspired by the opulence and contrast of baroque art.
-
Raymarching:
- The shader uses raymarching to sample the cloud volume. It steps through the scene, accumulating density based on the noise function.
- The
CLOUD_DENSITY parameter controls how thick or wispy the clouds appear.
-
Lighting:
- A simple lighting model is implemented using the difference in noise values along a light direction, creating soft highlights and shadows on the clouds.
- The lighting enhances the realism and depth of the cloud effect.
-
Post-Processing:
- Gamma correction (
pow) is applied to enhance the richness of the colors.
- A slight warm tint is added to the final image to reinforce the baroque aesthetic.
Customization Tips:
- Cloud Density: Adjust
CLOUD_DENSITY to make clouds thicker (lower value) or wispier (higher value).
- Animation Speed: Change
CLOUD_SPEED to make the clouds move faster or slower.
- Color Palette: Modify the colors in
baroqueSky and baroqueCloud to experiment with different baroque-inspired tones.
- Cloud Scale: Tweak
CLOUD_SCALE to make the clouds larger or smaller in detail.
This shader should give you a visually striking, animated cloud effect with a luxurious baroque flair, perfect for artistic or atmospheric visualizations!