Color blindness simulator shader

Adaptation to godot from zenek1290 minecraft shader

Apply the shader material to a mesh and look through it
The shader has 5 modes
0-No modification
1-protanopia
2-deuteranopia
3-tritanopia
4-achromatopsia

shader_type spatial;
render_mode unshaded;
uniform sampler2D SCREEN_TEXTURE:hint_screen_texture;
uniform int mode : hint_range(0,4) = 0;

const mat4 prota = mat4(
	vec4(0.170556992,0.170556991,-0.004517144,0.0),
	vec4(0.829443014,0.829443008,0.004517144 ,0.0),
 	vec4(0.0,0.0,1.0,0.0 ),
	vec4(0.0,0.0,0.0,1.0)
);
const mat4 deute = mat4(
	vec4(0.33066007,0.33066007,-0.02785538,0.0),
	vec4(0.66933993,0.66933993,0.02785538,0.0),
 	vec4(0.0,0.0,1.0,0.0),
	vec4(0.0,0.0,0.0,1.0)
);
const mat4 trita = mat4(
	vec4(1, 0, 0,0.0),
	vec4(0.1273,0.8739,0.8739,0.0),
 	vec4(-0.1273, 0.1260, 0.1260,0.0),
	vec4(0.0,0.0,0.0,1.0)
);
 const mat4 achroma = mat4(
	vec4(0.299, 0.587 ,  0.114,0.0),
	vec4(0.299, 0.587 ,  0.114,0.0),
 	vec4(0.299, 0.587 ,  0.114,0.0),
	vec4(0.0,0.0,0.0,1.0)
);

void fragment() {
	vec4 source =texture(SCREEN_TEXTURE,SCREEN_UV).rgba;
	vec4 target;
	switch(mode){
		case 0:
			target=source;   
			break;
		case 1:
			target=prota*source;	
			break;
		case 2:
			target=deute*source;	
			break;
		case 3:
			target=trita*source;	
			break;
		case 4:
			target=source*achroma;	
			break;
	}
	ALBEDO = target.rgb;
}
5 Likes

This is awesome! I usually use Photoshop to test stuff like. A plugin is much better. :pray:

1 Like

thank you! It has its limitations, but it is practical.

That’s my favorite kind of practical. The more complicated something is, the less likely people are to use it. It’s often worth it to slap limitations on something in exchange for usability. :+1::+1: