We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexDiscussionExhibition › Ray Tracing and Photon Mapping
Page Index Toggle Pages: 1
Ray Tracing and Photon Mapping (Read 2916 times)
Ray Tracing and Photon Mapping
Jan 30th, 2008, 10:05pm
 
Hi All,

I recently made an interactive raytracer and photon mapper with Processing:

http://www.cc.gatech.edu/~phlosoft/photon/

The goal was to give intuition for how photon mapping augments a basic raytracer by letting you play around with the lighting and some spheres in realtime. Any feedback is appreciated. Thanks!

-Grant
Re: Ray Tracing and Photon Mapping
Reply #1 - Jan 31st, 2008, 12:43am
 
OMG, very interesting..
Great code, but I need to spend much more time to try to understand what is going on inside..
It is quite surprising, that your code seems to be relatively short one.. Beautiful!

About an idea; it is first time I have seen a real photon mapper in "live-render" action..
As a studied photographer, I have ever dreamed about live rendering of 3d scenes.

That's impressing that it comes from java-processing, it's still very fast..

What to say, it's awesome..
It needs to add just some of light refraction, caustics, some dispersion, maybe sub-scattering or even light wavelengths (and of course: to manage to keep this monster near to realtime)..
then you can release new "live maxwell renderer". :)

Great work! I am impressed.
Regards, kof.
Re: Ray Tracing and Photon Mapping
Reply #2 - Jan 31st, 2008, 9:50pm
 
Thanks, kof.  Bear in mind that both the speed and shortness of the code are due to the fact that this is the barest-bones implementation that can be called "photon mapping" -- you're right that there are no caustics, no sub-surface scattering -- and it is a very simple scene.

I too was surprised at the interactive speeds -- chalk it up to a victory for processing.  I honestly used to do these kinds of experiments in CodeWarrior or XCode, but it was always kind of a chore just to get up a window and start drawing pixels, so I never even tried to make anything interactive.  Processing somehow "gave me permission" to do it -- made it seem possible. </satisfied customer>
Re: Ray Tracing and Photon Mapping
Reply #3 - Feb 1st, 2008, 12:06pm
 
That is amazing... I'm really impressed. Glad to have one of your "hard-core" graphics guys trying out Processing!
Re: Ray Tracing and Photon Mapping
Reply #4 - Feb 16th, 2008, 12:15am
 
Totally agree.
grant, this is mindboggling!
Thanks for showing it.
Re: Ray Tracing and Photon Mapping
Reply #5 - Mar 7th, 2008, 11:54am
 
Wow, I am truly impressed.

The last time I dabbled with ray-tracing was years ago in QBasic writing my own assembly graphics routines to speed things up.  Times have changed.

Oh, I could never get photon mapping to work properly.  7 years later, and I've forgotten even more Cheesy.

This is phenomenal code; not only does it--as mentioned--run surprisingly quickly, it looks awesome.  The soft shadows, the richness of the texture on the walls...very, very impressive.
Re: Ray Tracing and Photon Mapping
Reply #6 - Apr 18th, 2008, 7:08pm
 
I have to chime in with more praise.  This thing is so awesome!  Mad respect for your work Grant!  I've been playing with your code (hope you don't mind!)- I'd love to throw out a few thoughts.

First, I'm wondering about the difficulty of adding the ability to render arbitrary polys in the engine.  It appears that the code is currently wired to use preregistered mathematically defined shapes.  Maybe a method similar to beginShape() that would dynamically add the triangles to your object list.   You should be able to do that in about 10 lines of code, right? Wink

It seems to me that if you were going to add one major update, that would be the one Cheesy  It would be so cool to have a renderer like this, that was 'homegrown' from the Processing community.

Keep up the amazing work man!

Re: Ray Tracing and Photon Mapping
Reply #7 - Apr 25th, 2008, 10:32pm
 
Thanks, movax.  Yes, please do play with the code all you want!

I *really* like the idea of simply adding an additional photo-realistic rendering mode (analogous to P3D or OPENGL) that just renders whatever you've thrown onto the list with beginShape().  And it looks like Mark Chadwick has integrated the amazing Sunflow renderer with processing in a somewhat similar manner already:
http://hipstersinc.com/p5sunflow/

Sunflow Gallery: http://sunflow.sourceforge.net/index.php?pg=gall

You're right that my code is hard-wired for spheres and planes, and though raytracing arbitrary polygons isn't so bad (adding ray-triangle intersection may, in fact, be just 10 lines Smiley ), the dirty secret is that as you add more complex geometry with nooks and crannies, many more photons may be needed to get the lighting correct.  The key to the speed here is simple shapes and few photons, so I'd have to play around and see how my code scales to more complex scenes.

Thanks for the feedback -- no immediate plans, but I'll let you know if I push in this direction.  If someone else wants to give it a shot, I'd love to see it.
Re: Ray Tracing and Photon Mapping
Reply #8 - Apr 25th, 2008, 11:43pm
 
Hey Grant - thanks for the response.  Yeah I've been using p5sunflow, and the results are completely amazing.  As of right now, p5sunflow doesn't do any reflective properties, and its soo slowwwww.  And Mark, the developer has too many cool projects to go full-on with it.

I don't know if yours would be any faster, but I would love to be able to have shiny reflective/refractive(?) objects.  Also, just having a raytracer that came from, and was made specifically for Processing would be great!  

I actually went as far as to look up the math for adding polygon tracing- you are right that it wouldn't be too bad.  In fact, its a matter of extending the plane-intersection part of the code.  First, check the plane which the poly lies on.  If hit, then bounding box check, if hit, then do a polygon ray test.  A very simple one is here :
http://www.siggraph.org/education/materials/HyperGraph/raytrace/raypolygon_intersection.htm  Of course, the part where you draw (register) all your polys would have to be made as well.

So the theory isn't too bad.  The hard part really is building it in a way to be useful in the Processing context, as a plugin renderer for the size() command.  *That* I know nothing about.

Whatever the case, your codez rock!
Page Index Toggle Pages: 1