
Phew, that took some figuring out. I've got tetrahedral interpolation working in my voxel renderer now, so it only needs to look up 4 values to find the radius at a point, not 8. It should give a fairly decent performance improvement, but I'm not sure because I'm using a different pc. The down side is that I lose the curves I liked so much, although it looks about as good (better in some cases, worse in others). Most of the information I found about tetrahedral interpolation was in legalese (it's patented), and no one on gamedev.net seemed to know much about it, so I had to figure most of it out on my own.
I might write more about it later, but the basic idea is that you 1. Divide your cube into 6 tetrahedrons and find which one your point of interest is inside using the plane equations (this can be boiled down to a switch statement) and 2. Interpolate between the values at the 4 vertices of the tetrahedron (the equation can be greatly simplified for the relevant special cases). Took me three pages of working to figure out, but someone who knew their stuff could probably do it in one. Not to mention the stupid mistake where I got the switch statement exactly wrong...
I suppose the next thing is converting my normal vector calculation into some kind of tetrahedral scheme. I'm almost sure it's possible, but it may yet give me a headache.
|