A mirage?

This commit is contained in:
Mario Brandao
2023-12-15 09:06:36 +01:00
parent 9bbaede508
commit cac890d6de
6 changed files with 134 additions and 5 deletions

View File

@ -4,12 +4,18 @@ shader_type canvas_item;
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear;
uniform float strength = 20.0;
uniform float focus_radius : hint_range(0.0, 1.0) = 0.0;
uniform float focus_edge : hint_range(0.0, 1.0) = 0.0;
void fragment() {
vec2 ca_offset = vec2(strength, 0.0) * SCREEN_PIXEL_SIZE;
float red = texture(SCREEN_TEXTURE, SCREEN_UV - ca_offset).r;
vec2 CENTER = vec2(0.5, 0.5);
float d = distance(SCREEN_UV, CENTER);
float within_radius = smoothstep(focus_radius, focus_radius + focus_edge, d);
vec2 offset = vec2(strength * within_radius, 0.0) * SCREEN_PIXEL_SIZE;
float red = texture(SCREEN_TEXTURE, SCREEN_UV - offset).r;
float green = texture(SCREEN_TEXTURE, SCREEN_UV).g;
float blue = texture(SCREEN_TEXTURE, SCREEN_UV + ca_offset).b;
float blue = texture(SCREEN_TEXTURE, SCREEN_UV + offset).b;
COLOR = vec4(red, green, blue, 1.0);
}