Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

The 1 week extension

Sign in to follow this  


So my raytracer was done, right? Well, it turns out enough of the class didn't get enough of it done, so we got a 1 week extension. So that means I got another week to work on my scene, right? Well, sort of. Not only did I have other stuff to work on, I was actually pretty happy with my scene, so instead of spending a bunch of time making it better, I implemented two really cool, but turns out not that helpful for my grade (probably) features: bounding spheres and model loading.

First thing I did was bounding sphere, I'm sure you all know why this is helpful. First I started by putting all the triangles in their own spheres (collision against a sphere is much much faster than a triangle, in case you weren't aware). Then I recursively look for the pair of spheres that minimizes the distance between and combined radii, take those and put them in a bigger sphere. I do this until there is only one sphere at the top level (then I obviously have a tree of spheres). Not sure if this is the "way it's done", but it seems to work. In fact, on the scene from the previous entry it rendered 70% faster on my machine :).

I also added the ability to load MilkShape models. It's not as impressive as it sounds, since I had the code to load them laying around from my intro to graphics course, with a little hammering it plugged right in. Of course by the time I got all this working (yesterday), I didn't really have time to make a better scene than what I already had, so I stuck one of the models I had from before (a car my brother made me for my intro graphics final project) in the scene. It's not like it wasn't a little strange already:

right click for full size.
Sign in to follow this  


Recommended Comments

What ray-triangle collision check method are you using? It's normal for spheres to be faster (they're without question the single fastest collision check there is) but one-sphere-per-triangle sounds painful. In a large scene, or with large triangles, you can quickly reach a point where you have to do 8-9 really lame bounding sphere checks, all of which hit, just to check against a triangle - which is hit by 50% of your rays. Usually by the time you do 4 or 5 sphere checks, you've actually stopped saving time, and may as well have just done the triangle check to begin with.

There's ways to avoid that, of course, but they're probably more trouble than it's worth for your project; in general the idea is to maximize the number of triangles contained in each level of the bounding volume tree, and use a cost heuristic to stop adding more levels to the tree when it gets to a point where you're spending more time checking the bounding spheres than it would take to just check the triangles. You start from the other end (bound the entire scene) and work backwards towards fine details. The stopping point depends heavily on the type of geometry and such. Usually though all of this really only pays off when you're dealing with millions of polygons and they are many different sizes.

Share this comment

Link to comment
The triangle intersections we were shown is one that doesn't use any trig, described here. So I guess as far as triangles go it's pretty fast. Even though my scenes are pretty simple, I probably am building more spheres than necessary like you mentioned, which I didn't really think about. I plan on starting over from scratch now, now that I have some idea of how raytracers are put together and I have no deadline, and would like to implement more intelligent optimizations, so you're input is greatly appreciated. I'll likely do more research next time too, before jumping in, so if you have any advice on where to look that'd be great too :).


Nice car

Thanks :).

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!