----------------------------------- apython1992 Wed Mar 09, 2011 11:13 pm 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. ----------------------------------- apython1992 Sun Mar 13, 2011 8:19 pm Re: Raytracer ----------------------------------- An update. ----------------------------------- apython1992 Sat Mar 26, 2011 6:02 pm Re: Raytracer ----------------------------------- Yet another update. Recursive raytracing in place for reflections. ----------------------------------- SNIPERDUDE Sat Mar 26, 2011 8:39 pm RE:Raytracer ----------------------------------- Looking pretty good man, how fast does it render? I know it varies by task and machine, just curious. ----------------------------------- apython1992 Sat Mar 26, 2011 8:45 pm 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 Sat Mar 26, 2011 8:50 pm RE:Raytracer ----------------------------------- Pretty decent. How are you optimizing? ----------------------------------- apython1992 Sun Mar 27, 2011 1:14 am 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 Sun Mar 27, 2011 4:23 pm RE:Raytracer ----------------------------------- Regarding your first optimizations it really goes to show how far efficient coding and planning ahead (prevents redundancies) goes. ----------------------------------- apython1992 Sun Mar 27, 2011 5:20 pm RE:Raytracer ----------------------------------- I couldn't agree more! ----------------------------------- QuantumPhysics Mon Oct 08, 2012 11:11 am RE:Raytracer ----------------------------------- Sorry for resurrecting the dead thread but this is amazing! Really great work. My reaction was absolute, wow!