Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
chromatic_aberration.shader + shake
// chromatic_aberration.shader
// based on code from https://gist.github.com/uheartbeast/312a7ea761b8712c448b31c30c0d8f1f
shader_type canvas_item;
uniform bool apply = true;
uniform float amount = 1.0;
uniform float strength : hint_range(0.0, 2.0) = 1.0;
uniform sampler2D offset_texture : hint_white;
void fragment() {
vec4 texture_color = texture(SCREEN_TEXTURE, SCREEN_UV);
vec4 color = texture_color;
vec4 new_color;
if (apply == true) {
float adjusted_amount = amount / 100.0;
new_color.r = texture(SCREEN_TEXTURE, vec2(SCREEN_UV.x - adjusted_amount, SCREEN_UV.y)).r;
new_color.g = texture(SCREEN_TEXTURE, SCREEN_UV).g;
new_color.b = texture(SCREEN_TEXTURE, vec2(SCREEN_UV.x + adjusted_amount, SCREEN_UV.y)).b;
}
COLOR = mix(color, new_color, strength);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment