Minecraft Crosshair Invert

Shader code
shader_type canvas_item;

// Declare the screen texture manually
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;

void fragment() {
	vec4 tex_color = texture(TEXTURE, UV);

	if (tex_color.a > 0.0) {
		// Read the screen color underneath using screen UVs
		vec4 screen_color = textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0);
		COLOR = vec4(1.0 - screen_color.rgb, tex_color.a);
	} else {
		COLOR = vec4(0.0, 0.0, 0.0, 0.0);
	}
}
Live Preview
The shader code and all code snippets in this post are under MIT license and can be used freely. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

More from ReVybes

Related shaders

guest

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Wordiii
Wordiii
9 months ago

I was looking on how to do this for so long
Thanks

Zugerujk
5 months ago

This really helped me figure out the effect. You’re credited in the additional credits for my game Island Off Outer Darkness. Thank you, so much!