Directional Lighting

BlitzMax Forums/BlitzMax Programming/Directional Lighting

SillyPutty(Posted 2005) [#1]
Has anyone got an idea on how to place lightsources so that shadows be generated correctly ?

For instance light affecting objects and casting shadows.

I have seen it talked about in older threads, the only place I have seen it implemented is in one of cyanides projects, check the second pic.

http://www.blitzbasic.com/Community/posts.php?topic=50188

Any ideas ?


boomboommax(Posted 2005) [#2]
lo er, the way i did it was pretty fake actually (but looked damn nice!) i just did some angle calcs based on light positions and rendered shadow meshes extruded out from the walls.

(used gl_quads)


SillyPutty(Posted 2005) [#3]
ah ok !

so for the first back facing poly you encountered, you marked that point as the begin of a shadow mesh ?

From that did you then work out correct "cone" angles to determine the angle of light cutoff ?


boomboommax(Posted 2005) [#4]
well if you know the positions of the end points on the "wall" get the angles from the light to the ends and you can extrude the shadow out from that, (coneage will be sorted auto)

lil warning thou, it looks pretty cool but unless the shadows are pretty dark you may notice some overlap sometimes er, you could do some more math to makesure they fit snug thou.


SillyPutty(Posted 2005) [#5]
my math really stinks, I am gonna battle with this :(


boomboommax(Posted 2005) [#6]
i will try and make you an example right now!
brb


SillyPutty(Posted 2005) [#7]
oh man, I would be eternally grateful !!


boomboommax(Posted 2005) [#8]
ok heres a simple example, there are problems with this method , but er with some carefull thinking you can cover them up.

http://legion.gibbering.net/cyanidenights/forum/viewtopic.php?p=13#13


SillyPutty(Posted 2005) [#9]
OMW, that is fantastic !!!

I think guys are gonna give you props for this !!


boomboommax(Posted 2005) [#10]
well its a pretty simple method it might even be in the code archives (?) aint looked but er, nehow! hope it helps


SillyPutty(Posted 2005) [#11]
it helps ! thanks again :)


Hotcakes(Posted 2005) [#12]
I've seen OMW a lot lately. wtf does it stand for?


SillyPutty(Posted 2005) [#13]
OMW = Oh My Word :)

Cyanide, I see that with this method, there will be problems with convex hulls ?

What I could do is render the shadows in the first pass, and overlay my hulls(mages) over the shadows. Would this be ok to do ?


SillyPutty(Posted 2006) [#14]
Oh noes, I seem to have misplaced the backup I made of this code-snippet and this link is down

legion.gibbering.net/cyanidenights/forum/viewtopic.php?p=13#13

Cyanide aka Boomboommax, do you still have this code available ? I am pretty sure from your previous help, and looking at the code before I could figure it out, however, having the snippet again would really help.


tonyg(Posted 2006) [#15]
Would this help?


SillyPutty(Posted 2006) [#16]
yeah, I was looking at trying this out too, thanks.

If for some reason I am feeling adventurous I will see if I can get the prior example re-coded.


SillyPutty(Posted 2006) [#17]
ok, just got home and knocked this up quick from memory

http://www.blitzbasic.com/codearcs/codearcs.php?code=1833