Bodycam footage

For all your porcine needs

This is more of a shader stack than a single shader
Fisheye Effect + Chromatic Aberration + Grain + Radial Crop Feathering

Instructions:

1- Create a CanvasLayer node

2- Add a ColorRect to the CanvasLayer node

3- Click on the ColorRect -> Material -> New ShaderMaterial -> Shader -> Create New Shader -> Paste the code below

CREDITS

Shader code
shader_type canvas_item;

uniform float aspect = 1.0;
uniform float distortion = 1.0;
uniform float radius = 1.07;
uniform float alpha : hint_range(0.0, 1.0, 0.1) = 1.0;
uniform float crop = 0.943;
uniform vec4 crop_color : source_color = vec4(0,0,0,1);
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;
uniform float crop_feathering = 0.1;

const float base_distortion = 0.99; 
uniform float channel_offset : hint_range(-0.1, 0.1, 0.001) = 0.005; 
uniform float noise_strength = 5.0;

vec2 distort(vec2 p)
{
    float d = length(p);
    float z = sqrt(distortion + d * d * -distortion);
    float r = atan(d, z) / 3.1415926535;
    float phi = atan(p.y, p.x);
    return vec2(r * cos(phi) * (1.0 / aspect) + 0.5, r * sin(phi) + 0.5);
}

void fragment()
{
    vec2 xy = (SCREEN_UV * 2.0 - 1.0); 
    xy = vec2(xy.x * aspect, xy.y); 
    float d = length(xy);
    vec4 tex;
    if (d < radius)
    {
        vec2 distorted_uv_r = distort(xy * (base_distortion + 0.0 * channel_offset)); 
        vec2 distorted_uv_g = distort(xy * (base_distortion + 1.0 * channel_offset)); 
        vec2 distorted_uv_b = distort(xy * (base_distortion + 2.0 * channel_offset)); 
        
        tex.r = texture(SCREEN_TEXTURE, distorted_uv_r).r;
        tex.g = texture(SCREEN_TEXTURE, distorted_uv_g).g;
        tex.b = texture(SCREEN_TEXTURE, distorted_uv_b).b;
    	float x = (UV.x + 4.0 ) * (UV.y + 4.0 ) * (TIME * 10.0);
		tex = tex+vec4(mod((mod(x, 13.0) ) * (mod(x, 123.0) ), 0.01)-0.005) * noise_strength;
        COLOR = tex;
        COLOR.a = alpha;
    }

    if (d > crop)
    {
        float softness = smoothstep(crop, crop + crop_feathering, d);
        COLOR = mix(tex, crop_color, softness);
        COLOR.a = alpha;
    }
}
Live Preview
Tags
bodycam, chromatic aberration, fisheye, unrecord
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 cyanone

Comments 16

    1. Kiril

      The countries depend on the texture you applied the shader to.

      0
    2. Might be the chromatic aberration, you can tweak or disable it in the shader parameters

      0
    3. dioporco

      modify the crop value in the shader settings

      0
    1. I haven't been able to recreate this, could you post a screenshot of the parameters? btw are you using the Forward renderer?

      0
        1. dioporco

          if you could drop the settings you used for the screenshots, that would be cool!

          0
          1. https://i.postimg.cc/DyhNnT4S/image.png

             

            this is what it looks like for me with the default parameters on a fresh project. 🤔
            I will adjust the default parameters so it doesn't show the color border but I have no idea why it would appear as magenta to you and others... normally it means that there's a missing texture but this shader uses no textures...

            0
  1. RTrager

    Only a black square appears on my screen. How can I fix that?

    0
    1. Kisihvalur

      try to lower the aspect in shader parameters

      0
  2. How Do I Make the Black Oval Very Small, (What variable do I tweak) Oh, and by the way, When I Change a variable, the changes do not sync and I get the same thing in game but different in the editor

    0
    1. Cyborg

      How did you do this I was having the same problem as the oval is very big and not realistic to a real Bodycam.

      -1
  3. This is such a cool shader, I will definitely use it in my projects (you will be credited ofc).

     

    Since I won't be implementing this right away, I do have to ask if someone would be polite enough and point out which blocks of code should be taken out if I wanted to exclude the black borders along side the curvature that comes with them.

     

    Thanks in advance!

    1