Created
November 23, 2020 16:47
-
-
Save jimmyjonezz/4732d99391eb751722c5a3cc6d54ddd9 to your computer and use it in GitHub Desktop.
chromatic_aberration.shader + shake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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