🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Color interpolation between orange and blue

Started by
6 comments, last by ahw 6 years, 10 months ago

Hi guys, 

I dont know if this is the right section, but I did not know where to post this. 

I am implementing a day night cycle on my game engine and I was wondering if there was a nice way to interpolate properly between warm colors, such as orange (sunset) and dark blue (night) color. I am using HSL format.

Thank  you.

Advertisement

I've spent a lot of time studying sunsets for this exact same reason.  The end of the sunset is fine - you can fade from orange to purple to dark blue.  The start of sunset can look odd though - fading from blue sky directly to yellow goes through an unnatural greenish colour.  Try fading to a whitish colour first.  This only applies to colours on the horizon - your upper sky colour can fade straight from blue (day) to black (night) over the entire sunset length.

Storm Clouds over the Western Front - 2D aerial combat WIP | DarklightXNA on Twitter | 2DFlightSim on Youtube
41 minutes ago, xbattlestation said:

The start of sunset can look odd though - fading from blue sky directly to yellow goes through an unnatural greenish colour.

Actually, it's not unnatural - it's entirely natural. Go on images.google.com and type in "sunset colors," and you will find some that have green, and it's beautiful. You'll also find some images with no green, and you can study the transitional hues in those.

-- Tom Sloper -- sloperama.com

21 hours ago, xbattlestation said:

I've spent a lot of time studying sunsets for this exact same reason.  The end of the sunset is fine - you can fade from orange to purple to dark blue.  The start of sunset can look odd though - fading from blue sky directly to yellow goes through an unnatural greenish colour.  Try fading to a whitish colour first.  This only applies to colours on the horizon - your upper sky colour can fade straight from blue (day) to black (night) over the entire sunset length.

Thank you for your answer. Can you, please, help me with the colours you think it should be better to use? Currently I am using:

NOON : horizon = blue, upper = blue.

SUNSET: horizon = orange, upper = blue

NIGHT: horizon = dark blue, upper = black

DAWN: horizon = light orange, upper = light blue

Do you think it could work? and What colorus would you suggest me to use for interpolate better between them? Thank you so much for your help.

Yeah you've pretty much got it.  I find a solid blue for daytime doesn't quite look right - but it'll depend on the art style you want your game to have.  Personally I think a blue fading to a very light blue on the horizon looks great.

As for the general flow - yeah I think you have that right.  Just remember from blue to orange via extremely light blue / white otherwise you'll get green (which just looks very unnatural in my eyes), and fade from orange to dark blue via purple for a dusky look.

Again, depending on your art style, realistic sky colours are not necessarily as vivid as you'd think.  Take some sunset photos from a google search, and run a colour picker tool on them - they aren't outright orange, but rather a washed out version.  Clouds on the other hand tend to reflect very vivid colours.  But half the fun is working this stuff out for yourself, and experimenting to find what works for you.

Storm Clouds over the Western Front - 2D aerial combat WIP | DarklightXNA on Twitter | 2DFlightSim on Youtube
On 15/08/2017 at 11:28 PM, Alessandro Pozzer said:

What colours would you suggest me to use for interpolate better between them?

If you interpolate the RGB values of two complementary colours you will go through a neutral region of the RGB space. The middle of your gradient will be "grey".

There are other ways of interpolating colours, like interpolating the parameters of your two colours while in the L*a*b* or HSL space. Use this tool for some previews: http://davidjohnstone.net/pages/lch-lab-colour-gradient-picker

interpolateHSL.png.ec2de6f5989c8c04f5ac8cc23ab45e57.png

If you just want to know how to do a gradient, I'm not sure you need much help. But if you want to learn about sunsets and sky colour, you may want to look up Rayleigh scattering and associated phenomena.

A good start would be this article linked from the Wikipedia page on Rayleigh scattering.

I get a feeling you might want to reformulate your original question. What do you want to know, really? The colour of the sky throughout a day/night cycle? The colours to use to properly light your scene?

-----------------------------Sancte Isidore ora pro nobis !

This topic is closed to new replies.

Advertisement