4 corner gradient

Pick 4 different colours for each of the UV’s 4 corners.

Shader code
shader_type canvas_item;

uniform vec4 topleft:source_color;
uniform vec4 topright:source_color;
uniform vec4 bottomleft:source_color;
uniform vec4 bottomright:source_color;

void fragment() {
	vec4 top = mix(topleft, topright, UV.x);
	vec4 bottom = mix(bottomleft, bottomright, UV.x);
	COLOR =  mix(top, bottom, UV.y);
}
Tags
gradient
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

Corner Void

set corner radius for texture

Corner radius

Subscribe
Notify of
guest

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Orbbloff
2 years ago

Why are you doing that in line 9? Isn’t it the same just using UV built-in?