Given a vec3 color how can I make it lighter and more desaturated so that I can simulate distance?
I tried using mix, but I cant figure out what the third argument does? Every time I use it I get all white...
Given a vec3 color how can I make it lighter and more desaturated so that I can simulate distance?
I tried using mix, but I cant figure out what the third argument does? Every time I use it I get all white...
Well, white is (1, 1, 1) so if you want a lighter color you can just mix it with white (the last parameter is the percent to mix it by).
my_color = mix(my_color, white, 0.3)
Which would be 30% more white.
I was pleasantly surprised when I discovered you can directly manipulate hsv values of the Color object (hsv stands for hue, saturation, value(brightness))
var color = Color(1.0, 0.0, 0.0)
color.s -= .1 #desaturate
color.v += .1 # brighten
color.h += .1 # hue shift
EDIT: Oh. It's shaders. Nevermind the above then :) I just woke up, minutes ago.
For distance fog, other than mixing, doing a simple additive blend often works fine as it will have the effect of brightening and desaturating the color appearance. Color you add doesn't have to be very bright, so exepriment with what works best.
color += distance_color * strength;
© 2022 - 2024 — McMap. All rights reserved.