Chromatic Abberation (With Offset)
Properties work as :
Strength
is the strength of the effect (max in white) .- Black in the
Offset Image
represents 0 effect of chromatic abberation while white does max. - No
Offset Image
will act like full white image.
My favorite method is :
– Canvas Layer
–Control ( FULL_RECT )
—Color Rect ( FULL_RECT , color : white , with the shader)
One example of offset texture is provided .
Shader code
shader_type canvas_item;
uniform sampler2D offset_image : hint_white;
uniform float strength = 1.0;
void fragment() {
vec4 output = texture(SCREEN_TEXTURE, SCREEN_UV);
float shift = strength * texture(offset_image, SCREEN_UV).r / 100.0;
output.r = texture(SCREEN_TEXTURE, vec2(SCREEN_UV.x + shift, SCREEN_UV.y)).r;
output.g = texture(SCREEN_TEXTURE, SCREEN_UV).g;
output.b = texture(SCREEN_TEXTURE, vec2(SCREEN_UV.x - shift, SCREEN_UV.y)).b;
COLOR = output;
}
For Godot4: