Rainy Window Effect in Davinci Resolve Fusion

This creates a cool Rainy Window effect with fog in Davinci Resolve/Fusion.

To create this effect you first need to ensure you have the latest version of my experimental Shader Toy Tool.

Download the file: here

In Windows it’s easiest to right click, save as and download and save the file to:

C:\ProgramData\Blackmagic Design\DaVinci Resolve\Fusion\Fuses

On a Mac you should find the Fuses folder under:

Library\Application Support\Blackmagic Design\DaVinci Resolve\Fusion\Fuses

After downloading the file and saving it in the folder, you will need to restart Davinci Resolve if you already have it open. Otherwise it won’t show.

Now you have that, you need the following code. Either save it as a txt file or copy and paste it into the box in the tool:

// Rainy Window Shader for Resolve Fusion
// Based on this awesome tutorial for Unity https://www.youtube.com/watch?v=EBrAdahFtuo

float N21(vec2 p) {
	p = fract(vec2(123.34,345.45)*p);
	p += dot(p, p + 34.345);
	return fract(p.x*p.y);
}

vec3 Layer(vec2 uv, float t) {
	float size = p_Float1;
	vec2 aspect = vec2(iResolution.x/iResolution.y,1);
	uv = uv * size * aspect;
	uv.y += mod(iTime * .25,7200);
	vec2 gv = fract(uv) -0.5;
	vec2 id = floor(uv);
	float n = N21(id);
	t += n*6.2831;
	float w = uv.y * 10;
	float x = (n-.5) *.8; 
	x += (.2-abs(x))  * sin(3*w)*pow(sin(w),3)*.15;
	float y = -sin(t+sin(t+sin(t)*.5))*.45;
	y -=(gv.x-x)*(gv.x-x);
	vec2 droppos = (gv-vec2(x,y))/aspect;
	float drop = smoothstep(.05, .03, length(droppos));
	vec2 trailpos = (gv-vec2(x, t * .25))/aspect;
	trailpos.y = (fract(trailpos.y * 8)-.5)/8;
	float trail = smoothstep(.02, .01, length(trailpos));
	float fogtrail = smoothstep(-.05,.05,droppos.y);
	fogtrail *= smoothstep(.5,y,gv.y);
	trail *= fogtrail;
	fogtrail *= smoothstep(.05,.04,abs(droppos.x));
	vec2 offs = drop * droppos + trail * trailpos;
	return vec3(offs, fogtrail);
}

void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
	float distortion = p_Float2;
	float t = iTime;
	vec3 col = 0;
	vec2 uv;
	uv.x = fragCoord.x/iResolution.x;
	uv.y = fragCoord.y/iResolution.y;

	vec3 drops = Layer(uv,t);	
	drops += Layer(uv*1.23+7.54,t);
	drops += Layer(uv*1.35+1.54,t);
	drops += Layer(uv*1.57-7.54,t);

	float fogtrail = drops.z;

	vec4 clear;
	vec4 blurred;
	clear = texture(iChannel0,vec2(fragCoord/iResolution)+drops.xy * distortion);
	blurred = texture(iChannel1,vec2(fragCoord/iResolution)+drops.xy * distortion);	

	fogtrail = fogtrail * 1;
	fragColor = mix(blurred,clear,fogtrail);

}

Leave a Reply