Skip to content

Instantly share code, notes, and snippets.

@Doprez
Created May 27, 2025 02:36
Show Gist options
  • Save Doprez/5146ff97b67eb42c1d42f9b717b9d4cd to your computer and use it in GitHub Desktop.
Save Doprez/5146ff97b67eb42c1d42f9b717b9d4cd to your computer and use it in GitHub Desktop.

Revisions

  1. Doprez created this gist May 27, 2025.
    101 changes: 101 additions & 0 deletions HazePortal.sdsl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,101 @@
    //https://www.shadertoy.com/view/sttSzf

    shader HazePortal : ComputeColor, Texturing
    {

    compose ComputeColor portalColor;

    override float4 Compute()
    {
    float2 uv = streams.TexCoord.xy;

    float noise = smoothNoise(uv * 9.0) * 0.5;
    uv += noise;

    float2 movingUv = uv;
    movingUv.y = Global.Time * 0.07;
    movingUv += noise;


    float cells1 = cellularNoise(movingUv, 3.0);
    cells1 = pow(cells1, 6.0) * 0.5;

    float cells2 = cellularNoise(movingUv, 6.0);
    cells2 = pow(cells2, 5.0) * 0.1;

    float cells = cells1 + cells2;

    //float borders = border(1.05 - uv) + border(uv);

    float4 blue = portalColor.Compute();

    float4 color = blue * cells; //blue * (borders + cells);
    color += blue * 0.1;

    return float4(color.x, color.y, color.z, color.w);
    }

    float2 random(float2 st)
    {
    float x = frac(sin(dot(st.xy,float2(3.,72.233)))*43758.5453123);
    float y = frac(x * 77.0);
    return float2(x,y);
    }

    float smoothNoise(float2 uv)
    {

    float2 repeatedUv = smoothstep(0.0, 1.0, frac(uv));

    float2 tileCoords = floor(uv);

    float x1 = random(tileCoords).x;
    float x2 = random(tileCoords + float2(1.0, 0.0)).x;

    float xValues = lerp(x1, x2, repeatedUv.x);

    float y1 = random(tileCoords + float2(0 ,1)).x;
    float y2 = random(tileCoords + float2(1, 1)).x;

    float yValues = lerp(y1, y2, repeatedUv.x);

    return lerp(xValues, yValues, repeatedUv.y);
    }

    float cellularNoise(float2 uv, float size)
    {
    float2 repeatedUv = frac(uv * size);
    float2 uvCoords = floor((uv * size));

    float2 pointArea = float2(0.5, 0.5);

    float dist = 1.0;
    float currentDistance = 0.0;

    for(float i = -1.0; i <= 1.0; i++) {
    for(float j = -1.0; j <= 1.0; j++) {
    float2 neighborTile = float2(i,j);

    pointArea = random(neighborTile + uvCoords);

    pointArea += sin(Global.Time * 1.5 * pointArea) * 0.3;

    currentDistance = distance(pointArea + neighborTile, repeatedUv);

    dist = min(dist, currentDistance);
    }
    }

    return dist;
    }

    float border(float2 uv)
    {
    float col = 0.02 / uv.x;

    col += 0.02 / uv.y;
    col = smoothstep(0.1, 1.0, col);

    return col * .4;
    }
    };