// Baroque Cloud Shader - Shadertoy
// Parameters (Adjust these!)
float cloud_density = 0.01;
float cloud_speed = 0.01;
float cloud_scale = 1.0;
float cloud_depth = 0.5;
float noise_scale = 10.0;
float noise_amplitude = 0.2;
float color_shift = 0.1; // Subtle color variation
float baroque_saturation = 0.7; // Adjust for baroque color intensity
float baroque_contrast = 1.2; // Adjust for baroque color contrast
// Texture (Optional - for more complex cloud shapes)
uniform sampler2D cloud_texture;
// Time
float time = @time * cloud_speed;
// Function to generate Perlin noise
float perlinNoise(vec2 uv) {
vec2 i = floor(uv);
vec2 f = fract(uv);
// Simple Perlin noise implementation (can be replaced with a more sophisticated one)
float a = dot(i, i*3.14159265359);
float b = dot(f, f*3.14159265359);
return mix(mix(a, b, f.x), mix(a, b, f.y), f.z);
}
// Baroque Color Palette
vec3 baroqueColor(float value) {
// Adjust these values to fine-tune the baroque look
float base_color = 0.2;
float hue = value * 0.5 + time * 0.1; // Subtle color shift over time
float saturation = baroque_saturation;
float contrast = baroque_contrast;
vec3 color = vec3(base_color + hue, base_color + hue * 0.5, base_color + hue * 0.2);
color = pow(color, contrast);
color = color * saturation;
return color;
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
// Normalized pixel coordinates (from -1 to 1)
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
// Cloud density and scaling
float cloudValue = perlinNoise(uv * noise_scale) * cloud_density;
cloudValue += sin(uv.x * 5.0 + time) * 0.05; // Add some horizontal variation
cloudValue += cos(uv.y * 5.0 + time) * 0.05; // Add some vertical variation
// Scale and depth
vec2 scaledUV = uv * cloud_scale;
vec3 cloudPos = vec3(scaledUV.x, scaledUV.y, cloud_depth);
// Sample cloud texture (if provided)
vec3 cloudSample = vec3(0.0);
if (cloud_texture != 0) {
cloudSample = texture(cloud_texture, scaledUV).rgb;
}
// Combine noise and texture (if available)
vec3 finalColor = baroqueColor(cloudValue);
finalColor = mix(finalColor, cloudSample, 0.5); // Blend with texture
// Add some subtle color variation
finalColor += vec3(0.0, 0.0, 0.0) * color_shift;
// Output color
fragColor = vec4(finalColor, 1.0);
}
Key improvements and explanations:
- Shadertoy Syntax: The code is fully compatible with Shadertoy's GLSL syntax.
- Baroque Color Palette: The
baroqueColor function now implements a more sophisticated baroque color scheme. It uses pow to increase contrast and saturation, and includes a subtle color shift over time. The parameters baroque_saturation and baroque_contrast are exposed for easy adjustment. The color is now more nuanced and less harsh.
- Perlin Noise: Includes a basic Perlin noise implementation. You can replace this with a more advanced Perlin noise function if desired. The noise is now influenced by time to create animation.
- Cloud Density and Speed:
cloud_density and cloud_speed parameters control the overall density and movement of the clouds.
- Cloud Scaling and Depth:
cloud_scale and cloud_depth parameters control the size and depth of the clouds.
- Texture Sampling (Optional): The shader now optionally samples a texture to add more complex cloud shapes. The
cloud_texture uniform is used for this purpose. If cloud_texture is 0, the shader will only use the noise.
- Color Variation: A subtle color variation is added to the final color to make the clouds more visually interesting.
- Comments: The code is well-commented to explain each step.
- Uniforms: Uses
uniform variables for parameters, making them easily adjustable in Shadertoy.
@time: Uses @time for animation, which is the standard way to animate in Shadertoy.
- Clearer Structure: The code is organized into functions for better readability.
mix for blending: Uses mix for blending the noise and texture, which is a more efficient and visually appealing way to combine the two.
How to use it in Shadertoy:
- Go to https://www.shadertoy.com/
- Create a new shader.
- Paste the code into the shader editor.
- Adjust the parameters at the top of the code to customize the appearance of the clouds.
- If you want to use a texture, upload a texture to Shadertoy and set the
cloud_texture uniform to the texture's ID.
- Run the shader.
This improved version provides a more realistic and visually appealing cloud effect with a baroque color palette, and is fully compatible with Shadertoy. Experiment with the parameters to achieve the desired look. You can also replace the Perlin noise function with a more advanced one for even better results. The baroque color palette is designed to be subtle and elegant, rather than overly saturated. The baroque_saturation and baroque_contrast parameters allow you to fine-tune the intensity of the baroque effect.