Pride Flag Canvas Item Shader, Godot 4.x & 3.x

Pride flag shader for godot engine 4.x and 3.x versions.

Put this shader on a ColorRect or whatever you want!

Shader code
// Pride Flag Shader by Harmony Monroe
// harmonymonroe.com

shader_type canvas_item;
render_mode blend_mix;

const vec4 col1 = vec4(1, 0, 0, 1);
const vec4 col2 = vec4(1, 0.5, 0, 1);
const vec4 col3 = vec4(1, 1, 0, 1);
const vec4 col4 = vec4(0, 1, 0, 1);
const vec4 col5 = vec4(0, 0, 1, 1);
const vec4 col6 = vec4(1, 0, 1, 1);

const float div1 = 1.0 / 6.0;
const float div2 = 2.0 / 6.0;
const float div3 = 3.0 / 6.0;
const float div4 = 4.0 / 6.0;
const float div5 = 5.0 / 6.0;


void fragment(){
	float uvy = UV.y;
	
	if (uvy < div1) {
		COLOR = col1;
	}
	else if (uvy < div2) {
		COLOR = col2;
	}
	else if (uvy < div3) {
		COLOR = col3;
	}
	else if (uvy < div4) {
		COLOR = col4;
	}
	else if (uvy < div5) {
		COLOR = col5;
	}
	else {
		COLOR = col6;
	}
}
Live Preview
Tags
bisexual, gay, homosexual, inclusive, lesbian, LGBT, lgbtq+, pansexual, plus, pride, proud, queer, trans
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.

More from harmony

Related shaders

guest

7 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
admin
Admin
26 days ago

Because of how the comments on similar posts have been in the past, I want to preface this by saying that only comments about the actual shader itself will be allowed. I don’t want to close this comment section, and I don’t want to require login in order to leave comments, so please be civilized, mature, and respectful.

gaudimancer
25 days ago

Incredible shader !

Gurney
Gurney
25 days ago

The only issue is that because If statements are so slow, I’m afraid that my game wouldn’t be able to render, say, a Pride Parade without catastrophic frame loss. Unfortunately I’ve found 5 If statements in the code, excluding a trailing Else statement I also found.

Additionally, the use of magic numbers could contribute to how difficult this shader is to read. If I wanted to program a Pride Parade (which I do), I would first need to look inside the shader and identify precisely how these magic numbers affect the rendered material. If you could change the const magic number “6.0” to say, a float uniform called color_band_distance, I would be able to use the new shader to accommodate a variety of cases in which I may need some Thick pride for the Pride Parade I’ve previously mentioned that I am programming.

Other than that, this is an Incredible shader !

Thank you for making another one!

tentabrobpy
24 days ago
Reply to  Gurney

“If statements are slow” was true 20 years ago, not so much nowadays. A few comparisons determining a single color assignment isn’t going to kill anyone’s device.

Last edited 24 days ago by tentabrobpy
Gurney
Gurney
23 days ago
Reply to  tentabrobpy

the small issue is that my game is programmed to run on an ACME SmartFridgeTM device– and I did not find a dedicated GPU whenever I disassembled it or looked through the maker’s toolkit available on the ACME Appliances website. (I may have missed it, because how else could GPU shader work?1?_)

also my Pride Parade scene crashes the game on this device, and also has a 25% chance to also break the smart fridge and force a restart. I know it sounds weird, but I’m only using the fridge to playtest because I want my game to run on cheap and wisely available devices so that everyone regardless of income inequality and systemic racism can use to play my game on any device.

The fridge is Linux based, btw. Maybe linux does bad if-stametes?

Also what about my Thick pride flag for the Pride Parade I am programming? I would like those consts become uniforms. That would be nice 10./10 !

tentabrobpy
23 days ago
Reply to  Gurney

🙄

Nill Kiggers
Nill Kiggers
2 days ago

faggotry is a mental illness