Color shift Color Reducer post-processing

Very basic shader with hue saturation vibration seperated limiter and shifter

add a quad mesh in front of the camera then set size to 2 and check flip faces

The idea is that you can either have high hue count low Vibrance and saturation to something like tunnel and box or low hue and high vibrance and saturation to something like the other photo

HSV to RGB and RGB to HSV taken from here https://github.com/paddy-exe/ShaderFunction-Extras/blob/main/addons/ShaderFunction-Extras/Utility/utility.gdshaderinc

sky in the screenshot is https://godotshaders.com/shader/stylized-sky-shader-with-clouds/ i believe

water and flames is from my previous shader https://godotshaders.com/shader/glowing-shield-beam-buble-dark-magic-fresnel/

Shader code
shader_type spatial;
render_mode unshaded, fog_disabled;

uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;


uniform vec3 colorCount = vec3(32); //Max HSV Count
uniform vec3 colorShift = vec3(1.0); //Shift HSV colors 

uniform bool doShiftFirst = false; // do shifting colors first or flooring colors
uniform bool includeAlpha = true; // Include alpha objects. if certain objects that have alpha aren`t rendering disabling might help

vec3 hsv_to_rgb(vec3 color) {
	vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
	vec3 p = abs(fract(color.xxx + K.xyz) * 6.0 - K.www);
	return color.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), color.y);
}

vec3 rgb_to_hsv(vec3 color) {
	vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
	vec4 p = mix(vec4(color.bg, K.wz), vec4(color.gb, K.xy), step(color.b, color.g));
	vec4 q = mix(vec4(p.xyw, color.r), vec4(color.r, p.yzx), step(p.x, color.r));
	float d = q.x - min(q.w, q.y);
	float e = 1.0e-10;
	return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}

void vertex()
{
	POSITION = vec4(VERTEX.xy, 1.0, 1.0);
}

void fragment() {
	vec4 tex = texture(SCREEN_TEXTURE, vec2(UV.x, -UV.y));
	vec3 hvs = rgb_to_hsv(tex.xyz);
	
	if (doShiftFirst){
		hvs.xyz = (hvs * colorShift);
	}
	
	hvs.x =  floor(hvs.x * colorCount.x) / colorCount.x;
	hvs.y =  floor(hvs.y * colorCount.y) / colorCount.y;
	hvs.z =  floor(hvs.z * colorCount.z) / colorCount.z;
	
	if (!doShiftFirst){
		hvs.xyz = (hvs * colorShift);
	}

	ALBEDO = hsv_to_rgb(hvs.xyz);
	
	if (!includeAlpha){
		ALPHA = tex.w;
	}
}
Tags
Color, colour, limit, Post processing, reduce, shift, spartial
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 xhaya

Glowing shield/beam/buble/magic/frost Fresnel

Space Background

Related shaders

Simple Hue Shift

Depth based Tilt-shift

Hue Shift

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments