Tutorials page

An assortment of tutorials on various topics as and when I post them. To keep up to day, why not subscribe to the RSS feed?

Entries in concept (1)

Saturday
Feb122011

Shading Concepts 101: Colour Bleed.

In the last tutorial, Basic shading concepts, I put a sphere onto a grey background and added some shadow and lighting – direct and indirect.

In that circumstance, there wasn’t any colour bleed displayed, for simplicity.

In the real world there tends to be more colour and less infinite featureless grey plains. Scientists have noticed this on occasion, and have come up with a useful testing apparatus called a Cornell Box which can be used to demonstrate colour bleed – and so I’ve created my own for the purpose of this tutorial.

My version has three coloured walls in the primary colours, and neutral grey floor and ceiling.

Tehre's nothing in here.

Neutral grey floor and ceiling, one red, one blue and one green wall, with a little neutral grey shadow popped in for æsthetics, and to give the illusion of depth and light fading over distance.

Colour bleed?

Light is energy. In this example we’re using white light which (Simplifying the entire visible spectrum thing) is made up of three primary colours:

RGB diagram

Light comes in three primary colours – Red, Green and Blue. Light is additive – the more you add on the brighter it gets.

Pure colour at it’s maximum is called ‘saturated’. In the above diagram I’ve used three saturated colours overlaid as though they were coloured lights.

Paints are Subtractive – mix the three primary colours of paint (Red Yellow and Green) and you get dark brown…

If you mix the three light primary colours you get the secondary colours:

  • Red and Green make Yellow.
  • Red and Blue make Magenta (Or purple or Violet, depending on your eyesight).
  • Blue and Green make Cyan (bright blue?).
  • Red, Green and Blue together make White.

Bearing in mind we’re working with a computer which displays on a monitor, and there are specific hardware limitations in the screen’s output.

Where all the colours overlap, we get white.

Digression

You might notice that there are six colours and may recall that rainbows have seven colours: Red Orange Yellow, Green, Blue, Indigo, Valium Violet.

Sir Isaac Newton, inventor of the Cat-flap, Calculus, the theory of gravitation and Master of the Royal Mint also did some work on colours.

Unfortunately Sir Isaac was also an alchemist and believed that there was hidden evidence of the hand of God in the world so he decided that the rainbow should have seven colours rather than six because he felt it was more appropriate.

Therefore orange was promoted to a secondary colour instead of a tertiary colour that’s produced by mixing a primary and a secondary colour. he also labelled the secondary colour ‘Cyan’ as ‘Blue’ and pure blue ‘Indigo’.

So what happens when our white light, which we’ll say is 100% pure energy for the sake of explanation, hits say… a red wall?

The wall is red because it absorbs the blue and the green part of the light, and only reflects the red part. Thus 66% of our energy is absorbed and the rest is reflected. some goes to your eye, but some is reflected onto whatever is nearby.

That means in our Cornell box example, the white light would hit the coloured walls and then be reflected onto the floor and the other walls as coloured light.

Bearing in mind that since we know white is a mix of all colours, that any coloured light is technically less coloured

Let’s add that in.

Illumination-2-Bleed

Notice that the coloured walls are reflecting colour onto the grey ceiling and floor, but that the floor is also reflecting dim white light back up against them.

I could stop here, but where’s the fun in that?

Let’s introduce our good friend Sphere’s cousin, Neutral Grey Sphere!

Illumination-3-sphere

As you can see, Sphere is reflecting the light, the walls and has some shadow and direct illumination. But as yet there’s no indirect illumination. So can you guess what I’m going to do next?

That’s right I’m going to have a nice cup of tea.

And now I’m going to add in some indirect lighting, which will be:

  • Light reflected from the floor
  • Light reflected from the walls
  • Light reflected on to the walls from the sphere.

Illumination-4-sphere-indirect-illumination

The effect is quite subtle – you can see that the shadow under the sphere is being filled in with light from the walls and that the light from above is being bounced onto the walls, and that he coloured walls are adding a little coloured light to the sides of the sphere, and the floor is putting faint white light against the underside.

Limits.

In the real world, light will reflect backwards and forwards between objects until it’s too dim for the eye to register. In this example, it bounces once. This is a compromise between looking more realistic and the amount of time and effort it takes to do this.

In this tutorial, several basic assumptions have been made – That any light reflected from the walls will be only 33% as bright as pure white light, that the floor is reflecting 20% of the light (Approximating attenuation caused by distance) and so on.

It’s also assumed that all the materials are perfect – they reflect uniformly and are a perfect matte or gloss with no imperfections, that there is air and that the air is not absorbing any light.

This is not usually the case in the real world. That can also be added but for the purpose of this tutorial, I’ve handwaved all of that.