Untitled

 avatar
unknown
plain_text
a year ago
1.8 kB
11
Indexable
void mainImage'( out float4 fragColor, in float2 fragCoord : SV_Position )'
{
    //get coords and direction
    float2 uv = fragCoord.xy / iResolution.xy - float2(0.5, 0.5);
    uv.y *= iResolution.y / iResolution.x;
    float3 dir = float3(uv * zoom, 1.0);
    float time = iTime * speed + 0.25;

    //mouse rotation
    float a1 = 0.5 + iMouse.x / iResolution.x * 2.0;
    float a2 = 0.8 + iMouse.y / iResolution.y * 2.0;
    float2x2 rot1 = float2x2(cos(a1), sin(a1), -sin(a1), cos(a1));
    float2x2 rot2 = float2x2(cos(a2), sin(a2), -sin(a2), cos(a2));
    dir.xz *= rot1;
    dir.xy *= rot2;
    float3 from = float3(1.0, 0.5, 0.5);
    from += float3(time * 2.0, time, -2.0);
    from.xz *= rot1;
    from.xy *= rot2;

    //volumetric rendering
    float s = 0.1;
    float fade = 1.0;
    float3 v = float3(0.0, 0.0, 0.0);
    for (int r = 0; r < volsteps; r++) {
        float3 p = from + s * dir * 0.5;
        p = abs(float3(tile) - fmod(p, float3(tile * 2.0))); // tiling fold
        float pa, a = pa = 0.0;
        for (int i = 0; i < iterations; i++) {
            p = abs(p) / dot(p, p) - formuparam; // the magic formula
            a += abs(length(p) - pa); // absolute sum of average change
            pa = length(p);
        }
        float dm = max(0.0, darkmatter - a * a * 0.001); //dark matter
        a *= a * a; // add contrast
        if (r > 6) fade *= 1.0 - dm; // dark matter, don't render near
        //v += float3(dm, dm * 0.5, 0.0);
        v += fade;
        v += float3(s, s * s, s * s * s * s) * a * brightness * fade; // coloring based on distance
        fade *= distfading; // distance fading
        s += stepsize;
    }
    v = lerp(float3(length(v)), v, saturation); //color adjust
    fragColor = float4(v * 0.01, 1.0);   
}
Editor is loading...
Leave a Comment