This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-12-19 06:41:07

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Optics help for a raytracer

I'm working on a raytracer in Python (hey, something to keep me busy!), and I'm kind of stuck. Here's a pic of what I can do now (it took 20 minutes to render):
http://i45.tinypic.com/spaouo.png
There are 50 light sources here, but the whole scene is kind of dim. That's because I basically take the mean of all light contributed by each light source to a point. Clearly this is wrong (adding a light of 0 intensity darkens the whole scene  tongue ), but I can't think of a "proper" physically accurate way to add light. I can't just directly add colors, or I'd end up with more than 100% intensity. I can't multiply all components, because then light would get dimmer. What do I do?  hmm


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#2 2012-12-19 09:17:01

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: Optics help for a raytracer

Maybe you could divide the intensity of a light by the square of its distance from the point, then add all of these? The trouble here is, you can get over 100% intensity. Another possibility is taking away each light's intensity from 100, multiplying all of these, then taking the result away from 100. That way, every light will add a bit of brightness, 0 intensity lights have no effect and the intensity will never go over 100%. I've never even touched raytracers, so I don't know whether this would work, but it might be worth trying.


/* No comment */

Offline

 

#3 2012-12-19 09:29:57

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: Optics help for a raytracer

Maybe just have a maximum value at 100%? Surely you have to limit the dynamic range of your (virtual) camera's sensor somewhere...

(I'm not sure if "dynamic range" is the right term here. I just mean the range of intensities that the sensor differentiates between.)

Last edited by blob8108 (2012-12-19 09:30:46)


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

Board footer