The 1 week extension

Published February 28, 2006
Advertisement
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.
Previous Entry The result
Next Entry Ringneck continues
0 likes 3 comments

Comments

Rob Loach
Nice car [wink].
February 28, 2006 01:31 AM
ApochPiQ
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.
February 28, 2006 10:42 AM
Rixter
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 :).


Quote:
Nice car

Thanks :).
February 28, 2006 12:42 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

Spicy Curse

1168 views

Missile Command

1130 views

I wanna make games

1125 views

A letter

1192 views

End of Days

1260 views

Workin' Hard.

1000 views

Not much new...

1016 views
Advertisement