Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / hemispherical skylight using two directional lights

Author
Message
Mr Tank
21
Years of Service
User Offline
Joined: 25th Nov 2002
Location: United Kingdom
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
TEH_CODERER
21
Years of Service
User Offline
Joined: 12th Nov 2003
Location: Right behind you!
Posted: 14th Jan 2006 20:05
Think I get you! Nice one!

[url]andrewneale2004@yahoo.com[/url]
http://www.elbsoftware.dbspot.com
Codelike
18
Years of Service
User Offline
Joined: 13th Dec 2005
Location: DBP - Scouseland
Posted: 27th Jan 2006 04:26
'Ambient backlighting'

I have an XP3000+, 1.5gb DDR333, a 6600GT and I'm programming 3k text-based exe's?!
Turoid
21
Years of Service
User Offline
Joined: 1st Nov 2003
Location: The Netherlands
Posted: 27th Jan 2006 14:54
nice


.::Studying game design at the moment::.

Login to post a reply

Server time is: 2024-11-23 07:24:06
Your offset time is: 2024-11-23 07:24:06