I am trying to implement the shader described here in Godot.
Basically, alternating rows of pixels composing the screen texture are pulled in opposite directions, leaving black in their place.
My native resolution is 640x360 and I have an appropriate sample texture, encoding the effect.
My shader is:
uniform sampler2D transition_tex;
uniform float cutoff: hint_range(0,1);
vec4 transit = texture(transition_tex, SCREEN_UV);
vec2 direction = normalize( vec2((transit.r - 0.5) * 2.0, 0.0) );
// when r = 0, direction = (-1, 0)
// when r = 255, direction = (1, 0)
vec4 color = texture(SCREEN_TEXTURE, SCREEN_UV + (cutoff * direction));
if (transit.b < cutoff)
COLOR = vec4(0.0,0.0,0.0,1.0);
COLOR = color;
I have this shader applied to a
ColorRect which sits in a
CanvasLayer that I use for my screen transitions. I animate the
cutoff from 0 to 1 to achieve the effect.
I notice that when I am in fullscreen mode, the effect almost works perfectly, except that on each set of pulled rows, the rows alternate in groups of five, lighter and darker, creating horizontal bands of lighter and darker rows. (I can't screenshot this since Godot won't record screenshots in fullscreen mode.)
When I am not in fullscreen mode, the effect does not work. My game window simply blurs into a brownish color before the pixel rows are pulled apart.
So my question is:
How can I get this shader to work in both fullscreen and windowed mode?