AI GENERATED

by touyou

PROMPT

祝福の花束が広がるあたたかい空間

DATE
2026/7/7
SOURCE
AI GENERATED
MODEL
gemini-2.5-flash
LIKES
0
VIEW SHADER CODE
vec2 hash22(vec2 p) {
    p = fract(p * vec2(5.3983, 5.4471));
    p += dot(p, p.yx + 19.19);
    return fract(vec2(p.x * p.y, p.x * p.x) * 95.4337);
}

float noise(vec2 p) {
    vec2 i = floor(p);
    vec2 f = fract(p);
    
    vec2 u = f * f * (3.0 - 2.0 * f);
    
    float a = dot(hash22(i + vec2(0.0, 0.0)), vec2(1.0, 0.0));
    float b = dot(hash22(i + vec2(1.0, 0.0)), vec2(1.0, 0.0));
    float c = dot(hash22(i + vec2(0.0, 1.0)), vec2(1.0, 0.0));
    float d = dot(hash22(i + vec2(1.0, 1.0)), vec2(1.0, 0.0));

    return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);
}

float fbm(vec2 p) {
    float f = 0.0;
    float amp = 0.5;
    float freq = 1.0;
    for (int i = 0; i < 5; i++) { // 5 octaves
        f += amp * noise(p * freq);
        freq *= 2.0;
        amp *= 0.5;
    }
    return f;
}

// Cosine palette function for rich, harmonious colors
vec3 palette(float t, vec3 a, vec3 b, vec3 c, vec3 d) {
    return a + b * cos(6.28318 * (c * t + d));
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
    vec2 uv = (fragCoord * 2.0 - iResolution.xy) / iResolution.y;
    vec2 p = uv;

    float time = iTime * 0.1; // Smooth, slow animation speed
    
    // Animate and zoom the noise field
    p += vec2(cos(time * 0.7), sin(time * 0.5)) * 0.1; // Subtle drift
    p *= 1.5; // Zoom in for detail

    // Domain warping for organic, flowing movement
    vec2 warp = vec2(fbm(p * 0.5 + time * 0.2), fbm(p * 0.5 + vec2(5.2, 1.3) + time * 0.25));
    warp *= 0.5; // Control warp strength
    p += warp;

    float noiseVal = fbm(p + time * 0.3); // Base noise value

    // Radial elements to evoke a "bouquet spreading"
    float r_uv = length(uv);
    float angle = atan(uv.y, uv.x);

    // Central glow / bloom effect
    float glow = 1.0 / (1.0 + 15.0 * r_uv * r_uv); // Stronger falloff for central light
    glow = pow(glow, 2.0); // Sharpen glow, make it more intense at the center

    // Petal-like or ray-like structure
    float numPetals = 8.0; // Number of distinct "petals" or rays
    float petalSpeed = 0.5; // Speed of petal rotation
    float petals = cos(angle * numPetals + time * petalSpeed) * 0.5 + 0.5;
    petals = pow(petals, 4.0); // Sharpen the petals significantly for definition
    petals *= smoothstep(0.0, 0.7, 1.0 - r_uv * 0.8); // Fade petals towards edges, making them more central

    // Combine all elements: organic noise, central glow, and radial petals
    // Emphasize glow and petals for the "bouquet of blessings" feel
    float finalVal = noiseVal * 0.3 + glow * 0.6 + petals * 0.7;
    
    // Warm, golden color palette
    vec3 col = palette(finalVal,
                       vec3(0.8, 0.5, 0.2), // Base color: rich burnt orange/sienna
                       vec3(0.2, 0.2, 0.2), // Amplitude for color variations
                       vec3(1.0, 0.8, 0.5), // Frequency/shift towards golden yellows and oranges
                       vec3(0.5, 0.3, 0.1)); // Phase offset

    // Enhance highlights and warmth, especially near the bright center
    col = mix(col, vec3(1.0, 0.9, 0.7), smoothstep(0.0, 0.15, finalVal)); // Brighter, creamy highlights
    col += glow * 1.0 * vec3(1.0, 0.8, 0.5); // Add a strong, golden central glow to the color

    // Subtle vignette to frame the composition
    float vignette = smoothstep(0.0, 1.0, 1.0 - length(uv) * 0.8);
    vignette = pow(vignette, 0.7); // Apply a soft vignette
    col *= vignette;

    fragColor = vec4(col, 1.0);
}

ZIP を展開して .playground を Xcode でダブルクリックし、Live View を表示して ▶ を押すとシェーダーがアニメーションします。Metal ソースは Resources/Shader.metal に独立ファイルとして入っているので、Xcode 上で直接編集できます。