Last active
April 21, 2022 20:29
-
-
Save lunarcloud/a2de2f9d456082dc69e99ab1e18d5074 to your computer and use it in GitHub Desktop.
Godot Anaglyph Shader
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; | |
render_mode unshaded; // TODO experiment with blend_disabled and mix with texture(SCREEN_TEXTURE, SCREEN_UV) ? | |
uniform float separation : hint_range(-25, 5) = 0.0; | |
uniform vec4 left_color : hint_color = vec4(0, 0, 1, 1); | |
uniform vec4 right_color : hint_color = vec4(1, 0, 0, 1); | |
const float s = 1000.0; | |
const vec3 greyscale = vec3(0.299, 0.587, 0.114) | |
void fragment() | |
{ | |
vec4 left_sprite = texture(TEXTURE, UV + vec2(separation/s, 0.0)); | |
left_sprite.rgb = left_color.rgb * dot(left_sprite.rgb, greyscale); | |
vec4 right_sprite = texture(TEXTURE, UV + vec2(separation/-s, 0.0)); | |
right_sprite.rgb = right_color.rgb * dot(right_sprite.rgb, greyscale); | |
COLOR = mix(left_sprite, right_sprite, 0.5); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment