Animated TV-Static Border Shader

A simple shader which adds animated dark static borders to the edge of the screen.

Perfect for a horror game or TV screen effect.

To put it into your game, simply place it onto a ColorRect that covers the screen.


There are a few constants that can be customized in this script. If you want to change them overtime or at run-time, you can declare them within the fragment shader instead or change them to uniforms.

UPDATE_INTERVAL: Pause between each time the static updates, in seconds.

STATIC_GRANULARITY: Size of the individual static pixels. Choose a value between 0 and 1.

EDGE_BLUR: Amount of blur on the dark border around the edge of the screen.

BORDER_SIZE: Radial distance from the center where the border effect starts.


Shader code
shader_type canvas_item;
const float UPDATE_INTERVAL = .163;
const float STATIC_GRANULARITY = .005;
const float EDGE_BLUR = .5;
const float BORDER_SIZE = .3;

float generate_random_static (in float size, in float interval, in vec2 uv){
	float time_step = TIME - mod(TIME,interval);
	vec2 uv_step = uv - mod(uv, size);
	return fract(sin(dot(uv_step,vec2(12.0278*sin(time_step),15.0905)))*43758.5453);

vec2 get_polar_coords (vec2 center, vec2 uv){
	vec2 pos = uv-center;
	float r = length(pos);
	float theta = atan(pos.y,pos.x);
	return vec2(r,theta);

vec4 layer (in vec4 front_color, in vec4 back_color){
	return vec4(mix(back_color.rgb,front_color.rgb,front_color.a),front_color.a+back_color.a);

void fragment() {
	vec3 static_plot = vec3(generate_random_static(STATIC_GRANULARITY,UPDATE_INTERVAL,UV));
	vec2 c1 = vec2(0.5);
	vec2 pv1 = get_polar_coords(c1,UV);
	float func = BORDER_SIZE-.015*cos(4.0*pv1.y);
	float border_plot = smoothstep(func,func+EDGE_BLUR, pv1.x);
	vec4 border_color = vec4(vec3(0.0),1.0)*border_plot;
	COLOR = vec4(static_plot,.1);
	COLOR = layer(COLOR,border_color);
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

More from DrManatee

Palette Limiter Shader

Related shaders

Static Overlay

Diagonal Mask / Border / Edge

Hex Mask/Border/Outline

Notify of

Inline Feedbacks
View all comments