Stepped Gradient

Stepped Gradient is a Retro-styled Shader for Gradients. use/change some params in the shader parameters or in the code itself

first_color and second_color is obviously. the colors itself.

position is where the gradient should start (like an position offset!)

stepIntensify is how many steps for the gradient color to be given to.

 

inspired by: https://godotshaders.com/shader/linear-gradient/

Shader code
shader_type canvas_item;

uniform vec4 first_color = vec4(1.0);
uniform vec4 second_color = vec4(0, 0, 0, 1.0);
uniform float position : hint_range(-2, 2) = 0.5;
uniform int stepIntensify : hint_range(1, 50) = 10;

void fragment() {
	float pos = round(smoothstep(0,1,(position + UV.y) / 2.0) * float(stepIntensify));
	COLOR = mix(first_color,second_color,pos/float(stepIntensify)); 
}
Live Preview
Tags
gradient, retro, rough, stepped
The shader code and all code snippets in this post are under GNU GPL v.3 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 imakeshaders

Related shaders

guest

1 Comment
Oldest
Newest Most Voted
Dahim
Dahim
13 days ago

hey you should change ur first color and second color to smth like this :
uniform vec4 first_color : source_color = vec4(1.0);
uniform vec4 second_color : source_color = vec4(0, 0, 0, 1.0);

this way we can directly pick a color using the godot base color picker instead of tweaking with numbers