Tonight, the tracer tackled a 1.1 million+ triangle ship. That's pretty impressive, considering the raw GPU buffer data weighs in at over 140 MB. But the system didn't break down. I can't say that it was as responsive as with the usual 100k scenes...but that shouldn't be a surprise.
The Welder code for this ship is actually pretty cool, and it only takes 50 lines to get the above result! The thing is way more procedural than the previous ships, so different seeds actually make a significant difference with this algorithm. I'd definitely call that a success for 50 lines of code...yay Welder!
Saturday, May 12, 2012
Thursday, May 10, 2012
Hope
It's always inspiring to see a nice, clean image come out of the tracer. It makes me think that I have a chance at producing something decent in the end. We'll see!
The scene appears to be free of fireflies, acceleration structure errors, and smooth normal problems. Yay! Furthermore, it's the most complex scene I've rendered yet, weighing in at half a million polys, and I was able to get this high-res result in ~6 minutes. Sounds pretty good to me!
The scene appears to be free of fireflies, acceleration structure errors, and smooth normal problems. Yay! Furthermore, it's the most complex scene I've rendered yet, weighing in at half a million polys, and I was able to get this high-res result in ~6 minutes. Sounds pretty good to me!
Cutting it Too Close
I recently ran into a pretty heart-sinking problem:
Indeed, that's NOT the kind of thing one wants to see 5 weeks before the competition. Especially when I've been working super hard on this tracer for over a month. Surprisingly, I had not seen anything like this from my KD trees before, as they always seemed to work nicely. But this is obviously an acceleration structure problem; there's simply no other explanation for those results.
Thankfully, it only took me about 4 hours to solve this one (it could have been way worse...). It comes down to a pretty tricky case: if a cell contains triangles that are perfectly-aligned with one of the cardinal planes (in this case, the sides of the ship are axis-aligned), then the KD tree may try to split space "too" finely. If you think about a triangle that's planar with the xy, xz, or yz plane, it makes sense that, in theory, such a triangle could be contained in an AABB of zero volume. This would no doubt cause precision problems with the ray-AABB intersection test. Well, I was limiting my KD tree to a depth of 30, and allowing it 50 splitting plane choices with 3 recursive refinements (each of which also considered 50 splitting planes). In short, this means that my KD tree builder is absurdly precise...to the point that it actually will cut space "too" closely for floating-point precision to handle. If we start cutting space to the point of having bounding boxes with side lengths of 1e-5, floats start to cry in agony, and everything breaks down.
It took a good amount of thought to understand that - but now it makes sense. Bottom line: don't cut it too close! When considering a split, make sure that you don't slice a bounding box along a side that is already dangerously short. I've set this "dangerously short" threshold to 5e-5, which seems to be about as small of a side as I can split before precision becomes a problem. In theory, I probably should have checked the lengths of the resultant split sides rather than the length of the side before splitting...maybe I'll change it to that later.
Whew, that was a close call :)
Indeed, that's NOT the kind of thing one wants to see 5 weeks before the competition. Especially when I've been working super hard on this tracer for over a month. Surprisingly, I had not seen anything like this from my KD trees before, as they always seemed to work nicely. But this is obviously an acceleration structure problem; there's simply no other explanation for those results.
Thankfully, it only took me about 4 hours to solve this one (it could have been way worse...). It comes down to a pretty tricky case: if a cell contains triangles that are perfectly-aligned with one of the cardinal planes (in this case, the sides of the ship are axis-aligned), then the KD tree may try to split space "too" finely. If you think about a triangle that's planar with the xy, xz, or yz plane, it makes sense that, in theory, such a triangle could be contained in an AABB of zero volume. This would no doubt cause precision problems with the ray-AABB intersection test. Well, I was limiting my KD tree to a depth of 30, and allowing it 50 splitting plane choices with 3 recursive refinements (each of which also considered 50 splitting planes). In short, this means that my KD tree builder is absurdly precise...to the point that it actually will cut space "too" closely for floating-point precision to handle. If we start cutting space to the point of having bounding boxes with side lengths of 1e-5, floats start to cry in agony, and everything breaks down.
It took a good amount of thought to understand that - but now it makes sense. Bottom line: don't cut it too close! When considering a split, make sure that you don't slice a bounding box along a side that is already dangerously short. I've set this "dangerously short" threshold to 5e-5, which seems to be about as small of a side as I can split before precision becomes a problem. In theory, I probably should have checked the lengths of the resultant split sides rather than the length of the side before splitting...maybe I'll change it to that later.
Whew, that was a close call :)
100
This post officially marks the 100th screenshot that I've uploaded to this blog (not including shots of Welder code or inspirational images). I think it's fitting that it should be a pretty good one!
I'm hard at work on figuring out how to build ships, and the results are promising, but not perfect yet. Still, it's pretty impressive that one can build this out of nothing more than math, using a pretty simple programming language!
I won't post the Welder code for that one, since it's pretty lengthy (70 lines). There's a lot going on in that image, including highly-detailed guns that are welded onto the hull.
Unfortunately, I should mention that this screenshot is cheating a bit: notice how nice the texture looks? Well, it's really coincidence that the triplanar texturing just happens to line up in such a way that dark stripes seem to decorate the hull. That's not actually part of my design/code, and it boosts the aesthetics significantly. Take note: well-placed stripes would make a pleasing texture for the final thing...
I'm hard at work on figuring out how to build ships, and the results are promising, but not perfect yet. Still, it's pretty impressive that one can build this out of nothing more than math, using a pretty simple programming language!
I won't post the Welder code for that one, since it's pretty lengthy (70 lines). There's a lot going on in that image, including highly-detailed guns that are welded onto the hull.
Unfortunately, I should mention that this screenshot is cheating a bit: notice how nice the texture looks? Well, it's really coincidence that the triplanar texturing just happens to line up in such a way that dark stripes seem to decorate the hull. That's not actually part of my design/code, and it boosts the aesthetics significantly. Take note: well-placed stripes would make a pleasing texture for the final thing...
Wednesday, May 9, 2012
Guns
Tonight I'm playing with guns! I'm continuing to develop more convenience features in Welder, but the whole creation process is getting very smooth. It's awesome how quickly I can build stuff by continual tweaking and updating in real-time. Here are some guns mounted on a block:
And the code, now with syntax highlighting. Thanks be to the awesome Notepad++!
You can already see the power of having this in code form rather than in model form: when I want a new gun, I can also specify the angle of the barrels! This will make it easy to point it at something. Of course, that's a dumb example...there are loads of things that I could have parametrized in the gun generation code. But I'm just starting to get my feet wet :)
HQ Asteroid
I rendered one of the asteroids from the previously-described Welder program. It turned out quite nice:
Although it's a bit odd that there's an asteroid stuck in the floor :P
It looks great to me, but I still think it needs more detail. Texture will definitely help, but I think a nice normal map will drive everything home. With a good texture and normal map, this puppy should look fantastically-detailed. I won't be worrying about texturing until next week, though.
Although it's a bit odd that there's an asteroid stuck in the floor :P
It looks great to me, but I still think it needs more detail. Texture will definitely help, but I think a nice normal map will drive everything home. With a good texture and normal map, this puppy should look fantastically-detailed. I won't be worrying about texturing until next week, though.
Welder: Asteroids
Welder now has 3D Worley noise as an intrinsic (quite a powerful intrinsic...), so I've got everything I need to make asteroids in Welder now. I've been playing around with more detailed asteroids. I'm also working on a cratering algorithm for extra realism. So far, the results have been fantastic, although the cratering algorithm is very slow for high-resolution roids. Unfortunately, this is just the price I'll have to pay for using a scripting language (although the algorithm would still be slow in c++).
Here are some results. Disregard the horrible texture on the second asteroid, it's just there so that the details are more visible.
I'm really happy with the level of detail of these asteroids. Of course, asteroids were never really a challenging problem for this project...but it's good to know that they're basically solved.
Here's the code (I just change the seed to get a new roid):
Here are some results. Disregard the horrible texture on the second asteroid, it's just there so that the details are more visible.
I'm really happy with the level of detail of these asteroids. Of course, asteroids were never really a challenging problem for this project...but it's good to know that they're basically solved.
Here's the code (I just change the seed to get a new roid):
Subscribe to:
Posts (Atom)










