Skip to content

Instantly share code, notes, and snippets.

@lunarcloud
Last active Apr 21, 2022
Embed
What would you like to do?
Godot Anaglyph Shader
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