Skip to content

Instantly share code, notes, and snippets.

@uheartbeast
Created August 27, 2019 14:42
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uheartbeast/312a7ea761b8712c448b31c30c0d8f1f to your computer and use it in GitHub Desktop.
Save uheartbeast/312a7ea761b8712c448b31c30c0d8f1f to your computer and use it in GitHub Desktop.
Simple Chromatic Aberration Shader for Godot 3
shader_type canvas_item;
uniform bool apply = true;
uniform float amount = 1.0;
uniform sampler2D offset_texture : hint_white;
void fragment() {
vec4 texture_color = texture(TEXTURE, UV);
vec4 color = texture_color;
if (apply == true) {
float adjusted_amount = amount * texture(offset_texture, UV).r / 100.0;
color.r = texture(TEXTURE, vec2(UV.x + adjusted_amount, UV.y)).r;
color.g = texture(TEXTURE, UV).g;
color.b = texture(TEXTURE, vec2(UV.x - adjusted_amount, UV.y)).b;
}
COLOR = color;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment