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.

DarkBASIC Professional Discussion / Calculating colour between multiple lights?

Author
Message
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 15th Aug 2011 21:06 Edited at: 15th Aug 2011 21:08
Hey everyone


Light 1 is positioned at x1,y1,z1, has range1, color r1,g1,b1.
Light 2 is positioned at x2,y2,z2, has range2, color r2,g2,b2.
Light 3 is positioned at x3,y3,z3, has range3, color r3,g3,b3.

Point x is at px,py,pz.

How do I calculate the color you'd see at point x? I don't think it's linear, is it?


Thanks,

TheComet

Max P
16
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 15th Aug 2011 21:13 Edited at: 16th Aug 2011 12:51
It's untested code, but it should work:

edit Made a small mistake, updated the code.
SJPro
23
Years of Service
User Offline
Joined: 3rd Jul 2003
Location:
Posted: 16th Aug 2011 14:00
It's worth noting that the above assumes a linear relationship. Real light follows the inverse square law. I'm not sure how lighting is implemented in darkbasic/directx especially wrt to when it has a range.

www.freewarehub.net

Login to post a reply

Server time is: 2026-07-10 12:03:00
Your offset time is: 2026-07-10 12:03:00