Created
August 27, 2019 14:42
-
-
Save uheartbeast/312a7ea761b8712c448b31c30c0d8f1f to your computer and use it in GitHub Desktop.
Simple Chromatic Aberration Shader for Godot 3
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
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