Shadow Blues

Shadows are not absolute: light reflecting off of surrounding objects, or just diffusing through the atmosphere, always gives them a little touch of light and of color.  Outdoors, this frequently means blue, taking on the color of the faint reflected light coming from the sky.

Artists, meanwhile, have been cleverly exaggerating this blue-shadows thing for many decades: our eye tends read cool hues (blues, greens, purples) as receding or distant, while warm hues (reds, yellows, oranges) are read as advancing or important.  The contrast created by warm highlights and cool shadows also serves to make the image more vibrant.

Simulated lighting frequently neglects this, so after a bit of discussion with Tim, I set out to make our shadows blue.  I ended up reusing one of my favorite shader tricks, something that actually allows for a lot more than that.

The trick in question is the ramp texture: I calculate a pretty normal half-Lambert lighting term that ranges from 0 to 1, but use that term in a texture lookup rather than multiplying directly.

Standard lighting
A character lit with the base lighting term
Blue-shadow lighting
A character lit with a gradient that fades to dark blue rather than black
Toon lighting
A character lit by a sharply-transitioning gradient to produce a "cartoon" look

The lookup value also includes the effects of cast shadows; you can see the shadow cast by the cylinder on the character’s back in the images above.  Light attenuation, however, happens outside this system: if it didn’t, multiple point lights affecting the same object start to accumulate significant brightness even in the “dim” edges of the light region.