Author |
Message |
apython1992

|
Posted: Wed Mar 09, 2011 11:13 pm Post subject: Raytracer |
|
|
This is the output from the beginning works of a raytracer implemented entirely in python (probably a poor choice for this kind of project, but what the heck). More to come once I add reflection and refraction.
Description: |
|
Filesize: |
66.06 KB |
Viewed: |
327 Time(s) |

|
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
apython1992

|
Posted: Sun Mar 13, 2011 8:19 pm Post subject: Re: Raytracer |
|
|
An update.
Description: |
|
Filesize: |
69.86 KB |
Viewed: |
319 Time(s) |

|
|
|
|
|
|
 |
apython1992

|
Posted: Sat Mar 26, 2011 6:02 pm Post subject: Re: Raytracer |
|
|
Yet another update. Recursive raytracing in place for reflections.
Description: |
|
Filesize: |
85.23 KB |
Viewed: |
357 Time(s) |

|
Description: |
|
Filesize: |
122.14 KB |
Viewed: |
349 Time(s) |

|
|
|
|
|
|
 |
SNIPERDUDE

|
Posted: Sat Mar 26, 2011 8:39 pm Post subject: RE:Raytracer |
|
|
Looking pretty good man, how fast does it render? I know it varies by task and machine, just curious.
|
|
|
|
|
 |
apython1992

|
Posted: Sat Mar 26, 2011 8:45 pm Post subject: Re: Raytracer |
|
|
Thanks man, before making it recursive I spent some time making various optimizations and it took around 72 seconds to render. Now, with reflections and such it takes about two minutes, so it's not horrible but it could be better.
|
|
|
|
|
 |
SNIPERDUDE

|
Posted: Sat Mar 26, 2011 8:50 pm Post subject: RE:Raytracer |
|
|
Pretty decent. How are you optimizing?
|
|
|
|
|
 |
apython1992

|
Posted: Sun Mar 27, 2011 1:14 am Post subject: Re: Raytracer |
|
|
Well, at first I was more concerned with just making sure the math was right and stuff so at first I was making a lot of unnecessary calculations. When I made sure everything was right, the first few optimizations were algorithmic - using a geometric solution as opposed to an algebraic solution for calculating the sphere-ray intersections, for example. I made quite a number of those kinds of optimizations and it really helped. Then I made some little tweaks here and there, replacing list comprehensions with function mapping where possible, and stuff like that. Overall, I went from taking 8 minutes to render a non-recursive image to taking 2 minutes to render a recursive (reflected) image, but I know there are still optimizations to be made. I read about storing the previously intersected object in a temporary cache so that the next primary ray would test an intersection with that object first, which sounds like it would speed things up quite a bit given large enough objects. Also, I've read a tiny bit on dividing up the scene into segments, and surrounding complex composite objects with simple, quick-to-test polygons, which will be a handy optimization when I start using more than just simple geometric objects.
I profiled my code and the vast majority of time is spent calculating ray-object intersections, so I've mostly focused on tweaking these parts up and algorithmically doing as few intersection tests as possible. You seem to know a bit about this...do you have any ideas for optimization that I might not have thought about yet?
|
|
|
|
|
 |
SNIPERDUDE

|
Posted: Sun Mar 27, 2011 4:23 pm Post subject: RE:Raytracer |
|
|
Regarding your first optimizations it really goes to show how far efficient coding and planning ahead (prevents redundancies) goes.
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
apython1992

|
Posted: Sun Mar 27, 2011 5:20 pm Post subject: RE:Raytracer |
|
|
I couldn't agree more!
|
|
|
|
|
 |
QuantumPhysics
|
Posted: Mon Oct 08, 2012 11:11 am Post subject: RE:Raytracer |
|
|
Sorry for resurrecting the dead thread but this is amazing! Really great work. My reaction was absolute, wow!
|
|
|
|
|
 |
|