Double Vision w/ chromatic aberration
to use this shader, add a colorrect or something as a child of your character controller (not as a child of the camera as we want it to apear infront of everything for the proper double vision effect) this is my first shader btw, please point out any issues! my yt is : https://www.youtube.com/@xXUnhingedDevXx
Shader code
shader_type canvas_item;
uniform lowp sampler2D screen_texture : hint_screen_texture, filter_nearest_mipmap, repeat_enable;
uniform lowp float alpha : hint_range(0.0, 1.0);
uniform lowp float scale : hint_range(0.0, 2.0);
uniform lowp float red_shift;
uniform lowp float blue_shift;
uniform lowp float green_shift;
uniform lowp float red_mult = 1;
void fragment() {
vec2 uvs = SCREEN_UV * scale;
vec4 final_texture = texture(screen_texture, uvs);
float r = texture(screen_texture, uvs + vec2(SCREEN_PIXEL_SIZE*red_shift), 0.0).r * red_mult;
float g = texture(screen_texture, uvs + vec2(SCREEN_PIXEL_SIZE*green_shift), 0.0).g;
float b = texture(screen_texture, uvs + vec2(SCREEN_PIXEL_SIZE*blue_shift), 0.0).b;
COLOR = vec4(r, g, b, alpha);
}
Whenever I tried to use it, it gave out the error:
error(3): Expected valid type hint after ‘:’
I’m using Godot 3.5 so if this is made for Godot 4, that may be the issue.
Yes this was made for Godot 4.This issue happens because gd 3.x has a “SCREEN_TEXTURE” built in where as gd 4.x does not, this is why i had to create a sampler 2d with a hint like that. Heres how you fix the issue: delete line 3 and replace any remaning “screen_texture”s with “SCREEN_TEXTURE” this shouldfix the issue