Godot 4, color balance shader like in XnView Classic color balance
Asked Answered
C

1

0

Hi,

I need help converting the color balance system from XnView Classic to a shader usable in Godot 4.

Here are some screenshots of the system I'm talking about, it's called "Color balance" and each color (red, green and blue) are from -255 to 255.

Here is the beginning of the shader, it is in Godot 4 using Compatibility mode.

shader_type spatial;

render_mode unshaded;

uniform sampler2D texture_albedo;

void fragment() {
	vec4 texture_color = texture(texture_albedo, UV);
}

This shader will be attached to a Sprite3D and I would like to change the colors of that sprite the same way I can do it in XnView color balance.

Can you help me please ?

Ps: Already checked godotshaders, tested all sort of shader but none would do what I need.

Cayuga answered 9/4, 2023 at 13:53 Comment(0)
C
0

I figuret it out, here is the final shader that will act like the XnView colour balance.

shader_type spatial;

render_mode unshaded, blend_mix, cull_back, specular_disabled, ambient_light_disabled, shadows_disabled;

uniform sampler2D texture_albedo;

uniform float Red: hint_range(-255, 255, 1);
uniform float Green: hint_range(-255, 255, 1);
uniform float Blue: hint_range(-255, 255, 1);

void fragment() {
	vec4 texture_color = texture(texture_albedo, UV);
	vec4 chosen_col = texture_color;
	
	float red = (chosen_col.r * Red / 255.0);
	float green = (chosen_col.g * Green / 255.0);
	float blue = (chosen_col.b * Blue / 255.0);
	
	ALPHA = texture_color.a;
	ALBEDO = chosen_col.rgb + vec3(red, green, blue);
}
Cayuga answered 9/4, 2023 at 23:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.