2D Canvas Group Tint

I have been converting most objects to have canvas groups but this caused issues with my shaders. I couldn’t find it anywhere easily so made it myself. has a toggle & tint color.

Shader code
shader_type canvas_item;
render_mode unshaded;

uniform bool tint_active = false;
uniform vec4 tint_color : source_color = vec4(1.0);
uniform sampler2D screen_texture : hint_screen_texture, filter_nearest;


void fragment() {
	
if (tint_active == true)
	{
	COLOR.rgb = tint_color.rgb;
	COLOR.a  = texture(screen_texture, SCREEN_UV).a;
	}
else
	{
	COLOR  = texture(screen_texture, SCREEN_UV);
	}
}
Tags
canvas, group, tint
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

Related shaders

Canvas Group Outline

Tint Blend

electric ball canvas item

Subscribe
Notify of
guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Jessesmari
Jessesmari
23 days ago

Hello there! Thank you very much for this Shader. Sadly, I can’t use it because it won’t work with z-Indexed Nodes, meaning Sprite2Ds for example, which have a z-Index other than “0”. My game demands the use of z-Indexes. Could you provide any solution to this? 🙂