Fnaf / Clickteam perspective (displacement) – Godot 4.2

Works in Godot 4.2

This shader was made by someone named “Fishy” who created this shader for me, and he gave me permission to share this shader.

This is a recreation of a shader seen in Clickteam Fusion. This shader is used in games like Fnaf (Five Nights at Freddy’s)

This shader is applied to the entire screen, such as by using a ColorRect node. Also, the effect won’t be affected if the window size changes.

Here are the properties you can change: Zoom, Sharpness, Direction, and Wrapping Mode

Shader code
shader_type canvas_item;

/**
 * In relative units now (0-1)
 */
uniform float zoom = 1.0;

/**
 * Higher values = less distortion in the center
 */
uniform float sharpness = 2.0;

/**
 * (1, 0) for horizontal only, (0, 1) for vertical only
 */
uniform vec2 direction = vec2(1.0, 0.0);

/**
 * 0: Repeats
 * 1: Clamps
 * 2: Clips
 */
uniform int wrapping_mode = 0;

uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;

void fragment() {
    float fB;
    float fC;

    vec2 posTex;
    vec4 color = vec4(0.0, 0.0, 0.0, 1.0);
    vec2 uv = SCREEN_UV;
    vec2 ndir = normalize(direction);
    float fac1 = abs(dot(uv - 0.5, normalize(ndir.yx))) * 2.0;
    float fac2 = -dot(uv - 0.5, normalize(ndir)) * 2.0;
    vec2 new_uv = uv + pow(fac1, sharpness) * fac2 * zoom * ndir;
    switch (wrapping_mode)
    {
        case 2:
            if (0.0 > new_uv.x || new_uv.x > 1.0 || 0.0 > new_uv.y || new_uv.y > 1.0)
            {
                COLOR = vec4(0);
                break;
            }
        case 0:
            new_uv = fract(new_uv);
            // fall-through
        case 1:
            new_uv = clamp(new_uv, vec2(0), vec2(1));
            COLOR = textureLod(SCREEN_TEXTURE, new_uv, 0.0);
            break;
    }
}
Tags
clickteam, displacement, fnaf, perspective
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 The2AndOnly

Scratch brightness effect

Scratch fisheye effect

Scratch color effect

Related shaders

Accurate FNAF Clickteam “Panorama”

FNAF Faked 3D Displacement Shader

Jolly 2 OFFICE DISPLACEMENT effect

Subscribe
Notify of
guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
ayo
ayo
5 months ago

english or spanish?