Page 1 of 1

Fractal ISF Shader

Posted: Tue May 06, 2025 7:51 pm
by SelfDrivingCarp
Put together a really simple ISF shader to do this fractal thing. The background of each frame is two rotated copies of the previous frame with the input image overlayed on top with basic alpha blending.

https://youtu.be/O5pmEglsJjU

Re: Fractal ISF Shader

Posted: Wed May 07, 2025 4:40 am
by Terry Payman
Really cool!
Are you willing to share your ISF?

Re: Fractal ISF Shader

Posted: Fri May 09, 2025 3:50 am
by SelfDrivingCarp

Code: Select all

/*{
	"DESCRIPTION": "Fill the bockground with recursive copies of inputImage",
	"CREDIT": "@SelfDrivingCarp",
	"ISFVSN": "2",
	"CATEGORIES": [
		"Effect"
	],
	"INPUTS": [
		{
			"NAME": "inputImage",
			"TYPE": "image"
		}
	],
	"PASSES": [
		{
			"TARGET":"lastOutput",
            		"PERSISTENT": true
		},
		{
			"DESCRIPTION": "output"
		}
	]
	
}*/

vec4 baseImage(vec2 p) {
    // read this pixel from inputImage
    vec4 col = IMG_NORM_PIXEL(inputImage, p);
    
    // grab th color that would go under it. If it's on the left side, we'll
    // from lastOutput rotated and scaled one way, on the right, the other way
    vec2 underCoord;
    if (p.x < 0.5) {
        underCoord.x = p.y;
        underCoord.y = p.x*2.0;
    } else {
        underCoord.x = 1.0-p.y;
        underCoord.y = (1.0-p.x)*2.0;
    }
    
    // grab the underneath pixel from lastOutput. Add some transparency
    vec4 under = IMG_NORM_PIXEL(lastOutput, underCoord);
    under.a *= 0.9;
    
    // combine the input color with the under color according to the alpha
    // channel of the input color. For the resulting alpha channel, use the
    // higher alpha value of input and under color
    col.rgb = (col.rgb * col.a) + (under.rgb * (1.0-col.a));
    col.a = max(col.a,under.a);
    return col;
}


void main()	{
	vec4		inputPixelColor;
	
	if (PASSINDEX == 0) {
            // Our first pass composites the new input with the previous frame,
            // writing the output to the persistent lastOutput buffer
	    inputPixelColor = baseImage(isf_FragNormCoord.xy);
	} else {
            // Our second pass copies from the persistent buffer to our output
	    inputPixelColor = IMG_NORM_PIXEL(lastOutput, isf_FragNormCoord.xy);
	}
	
	gl_FragColor = inputPixelColor;
}
There's really not much to it. There's probably more efficient ways to do this and I'd like to add in a delay effect to the frames but that will be for another time.

This won't do anything interesting without alpha transparency in the input.

Re: Fractal ISF Shader

Posted: Fri May 09, 2025 5:15 pm
by Sadler
Lots of fun with different content - thank you for sharing!
Screenshot 2025-05-09 181316.jpg
Screenshot 2025-05-09 181316.jpg (203.7 KiB) Viewed 10566 times