4 corner gradient

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

Shader code
shader_type canvas_item;

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

void fragment() {
	vec2 uv_corner = vec3(UV, 0.0).xy;
	vec4 top = mix(topleft, topright, uv_corner.x);
	vec4 bottom = mix(bottomleft, bottomright, uv_corner.x);
	COLOR =  mix(top, bottom, uv_corner.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

Moving Rainbow Gradient

guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Orbbloff
Orbbloff
10 months ago

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