Friday, July 07, 2006

Spatial Subdivisions fully and totally working!!

Yeeeeeeahhh!!! Man I am totally psyched about this. This afternoon, I spent about 2 more hours on Spatial Subdivisons and totally figured out the problem with Hierarchical modeling not working! It actually had nothing to do with my MCS AABB-> WCS OBB -> WCS AABB bounding box conversion like I had assumed. That was actually totally fine and working perfectly. It turned out to be something totally ridiculous/a silly mistake - I was looping over the primitives inside the current voxel and returning the first one I found with the closest intersection point which was still inside the current voxel... i.e. I was returning early before checking all the primitives in the Voxel's primitive list!!!! Silly mistake but it was an awesome fix - just move the return value outside of the for loop, and my entire hierarchical problem was fixed!! That is soooo freakin' awesome, I was hoping to get this done today and I totally did, that rocks.

Anyway I also used Physically Based Rendering by Matt Pharr and Greg Humphreys, holy crud that book is totally awesome. I had an issue that I couldn't resolve and they totally explain it in that book and I was really impressed with the clarity and the efficiency of their explanation and code implementation. Sweeeet!! I used Physically Based Rendering to use the World Coordinate System Axis-Aligned Bounding Boxes to place the objects inside Voxels, rather than doing the other method of transforming the Voxel into Model Coordinate Space or something gross like that and then doing the Intersection there. I was considering that, but this approach that Pharr mentions is much better and easier to implement so I went with that.

So this totally ROCKS now that it's done. I ran Matt Lausch's refraction test with multiple hierarchical spheres in the background. Without Subdivisions: 25 seconds... with Subdivisions.... wait fooor itt... waiiit fooor itt..... 10 seconds!!!!!!!!!! Amazing!! This is some awesome speedup/Raytracing efficiency. I guess you can do even better if you have an Adaptive Method, but this is good enough for now. Good times!!

Here are some renders and even more impressively (to me anyway) hehe is the render stats!!! This is great. This is going to make my final image render sooooo much faster!! I have also implemented it in such a way that this speedup affects secondary recursive rays (eg. reflection and refraction) too so that will in turn also speed up my render time. This roooccksss.

Here are some images from today!


Hierarchical rendering with Grid subdivisions working


Render time with no subdivision speedup - 25 seconds


Image rendered in 25 seconds


Render time with subdivision speedup - 10 seconds


Image rendered in 10 seconds, note it is the same as the image above

No comments: