24 lines
903 B
Text
24 lines
903 B
Text
|
|
shader_type canvas_item;
|
||
|
|
|
||
|
|
// Retro "dissolve" / "fizzle fade" transition.
|
||
|
|
// Every screen pixel (or block of pixels) gets a fixed random number from 0 to 1.
|
||
|
|
// As progress goes 0 -> 1, any pixel whose number is below progress is hidden,
|
||
|
|
// letting the new scene underneath show through. Same pixel = same number every
|
||
|
|
// frame, so it looks random but always finishes cleanly.
|
||
|
|
|
||
|
|
uniform float progress : hint_range(0.0, 1.0) = 0.0;
|
||
|
|
// Size of each flipping block, in game pixels. 1 = single pixels, 4-8 = chunky.
|
||
|
|
uniform float cell_size = 1.0;
|
||
|
|
// If above 0, progress snaps to this many steps for a jerky old-hardware feel.
|
||
|
|
uniform float steps = 0.0;
|
||
|
|
|
||
|
|
float hash(vec2 p) {
|
||
|
|
return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453);
|
||
|
|
}
|
||
|
|
|
||
|
|
void fragment() {
|
||
|
|
vec2 cell = floor(FRAGCOORD.xy / cell_size);
|
||
|
|
float p = steps > 0.0 ? floor(progress * steps) / steps : progress;
|
||
|
|
if (hash(cell) < p) discard;
|
||
|
|
}
|