Posted: 13th Jan 2006 01:57
I can't be arsed to explain, but using an online integrator, i was able to show that the lighting from a hemisphere of light (ie like a sky) is proportional to 1+ the y component of the surface normal. NB diffuse lighting.
This is great news because firstly it gets rid of all that horrible uniform shading on the `darkside` of objects that has been really annoying for me in the past, but also, it can be reproduced by using 2 directional lights in db.
It is a bit frustrating, because it should really require only one dot product of the normal with the lighting "direction", rather than two with a truncation to stop negative illumination on the backsides of the object, but that's life.
OK so if the sky is colour SKYCOLOUR, and the ground is GROUNDCOLOUR, i use an ambient light of (SKYCOLOUR+GROUNDCOLOUR)/2, a downward pointing directional light of (SKYCOLOUR-GROUNDCOLOUR)/2, and an upward pointing directional light of (GROUNDCOLOUR-SKYCOLOUR)/2
Note that if the ground is darker than the sky, as is normal, then this upward light is negative.
By using a not too bright skycolour, you can add in another directional light for the sun too. This isn't in the code tho.
This hemispherical lighting is suited to large outside terrain type games.
Note that for `negative` lights, you can't use color light x,rgb(r,g,b) command.
Here i used sky colour rgb(225,225,255), ground colour rgb(160,150,140). THese are shown in the screeny. THe plane is textured in a flat mid grey colour. If it were white, the top would be the colour of the sky, and the bottom the colour of the ground.
Attachments
Login to view attachments