Algorithm

Posted on 04-11-2008 under 3ds max, Algorithm

I continued developing my method for SSAO and worked a bit on making it look better over a series of frames in an animation. So basically I ended up generating the same sphere for any given number of samples (same random seed) and then rotate the samples using by reflecting them with a per-pixel random normal, as described here.

That is all fine, but the real improvement came when I used energy minimization on my sampling sphere. Instead of just settling with random spherical coordinates I put my sphere through a energy minimization routine, and the difference is staggering. I’ll let the pictures speak for themselves:

SSAO without energy minimization
Notice how noisy and high contrast this looks.

SSAO with energy minimization
Much less noise with the same number of samples, and more realistic contrast.

So how does one do this? It is quite simple. Just generate your sample sphere with normalized vectors. Then iterate through them and apply some force between each point until they reach and equilibrium. About 100 iterations should be more than enough, and since this is done in a pre-process stage it really doesn’t matter how long it takes.

Here is some code: Read more »

Tags: , , , ,

Posted on 04-09-2008 under 3ds max, Algorithm

Ok, now it is time to actually show how the method I use works. This is C style code, but with some changes from my original code, for clarity. That is because my code handles the many layers of the 3ds max G-buffer and how pixels are weighted and works with transparency. Also, my code also has a method for simulating ambient radiance (more on that in a later post).

Read on for the actual code.

Read more »

Tags: , , , ,