User Functions
Don't have an account yet? Sign up as a New User
Lost your password?
Events
There are no upcoming events
|
 |
| Author: |
|
| Dated: |
Saturday, July 18 2009 @ 02:15 AM NZST |
| Viewed: |
186 times |
|
My volumetric renderer (technically, distance field renderer) has been sitting stagnant for a long time. Largely because I had several headaches getting sphere subtraction going with the sparse volume, so I felt stupid, and it seemed like it had been much surpassed already (already being after ~5 years of intermittent development ;-). Anyway, I recently got motivated to come back to it and progress has been surprisingly easy! I'll start with the pictures, everyone likes pictures.
 
The left image shows the brand new ability to subtract cubes from the environment. Works surprisingly well considering sharp edges can't be represented perfectly and are the achilles heel of the poor renderer. The right image shows how I've made the environment as a whole more complex, which I couldn't do before (see technical details). Also, it shows how a 2048^3 volume is still astoundingly massive. In the centre of the image you might see some little marks on one of the surfaces. Those are the same cubes shown in the left image.
So, technical details...
I started by doing some work on the sphere subtraction. Some of it didn't really make sense. But the big thing was that I was wasting tons of memory. You see, I have a low detail grid for the entire environment, and I create high detail sections around the surface where the detail is actually needed (details are meaningless in empty space/solid wall). The problem was, when subtracting a sphere I hadn't figured out how to remove the unneeded leaf nodes entirely contained by the sphere. In fact, for no particular reason, have an image of what happens when I neither remove nor update the high detail bits:

Having that sorted allowed me to use multiple large spheres without wasting so much memory that I hit the 2gb 32bit limit and die. So currently, the environment is created by randomly subtracting 25 spheres with radius 350 and 100 spheres with radius 200. It's ok looking, but nothing special. Takes about 1.6 gigs of memory. I really need to get some noise in, but that's a more formidable task than it first appears. The following paragraph worth of work neatly gives me a bit of a framework to do it in though.
I've converted my subtractSphere function into a generic subtractPrimitive function by shifting various bits of code into a Sphere class which inherits from Primitive. Now all I have to do to add primitives like the new box is make a child class of primitive and implement 4 functions. Those functions could be mistaken for a trig exam, but still. Luckily this isn't code which I need to optimise the, ahem, tripe out of or it would be harder to do this sort of thing.
During my developments, I noticed something about the threading (the renderer uses 4 threads). Each thread is being created every frame. I'm not sure how much this is costing me, but it would certainly be faster to use a thread pool. So that's a potential speedup, along with not using recursion and, I don't know, converting the entire damn thing to cuda or something.
One last treat for people who read this far, or more probably, skipped to the end. A photo of a bunch of renderer related notes I found when I started cleaning my room (it's a big job). Not quite readable, but not quite worth reading either.
|
Trackback URL for this entry: http://razorcode.net/trackback.php/VolrendCubeSubtraction
No trackback comments for this entry.
|