Friday, 11 March 2011

Progress Report ~3

So, my last post detailed the current list of tasks for improving my SSAO shader and I'm pleased to say that I have made some good progress there.


Implement blur shader - test both Gaussian (using scene normals) and bilateral blurs:  I have implemented a very simple bilateral blur, which produces relatively good results. I have still to implement a gaussian blur using the scene normals/depth. 

Try and get rid of SSAO artifacts (as seen in previous post): As the screenshots to follow will show, I managed to get rid of the banding artifacts that were present in the SSAO term.At first, I thought it may be a depth precision issue, so I changed the texture format from D3DFMT_A16B16G16R16F to D3DFMT_A32B32G32R32F. This did get rid of the banding somewhat, but not completely. I finally figured out that it was a self occlusion artifact, and once I started using the dot product of the normals as a weight, the artifacts disappeared completely and the scene now looks a lot cleaner.  

Optimisation - using scene normals in SSAO calculation: The SSAO shader now uses the scene normals to both alter the direction of the ray and as a weight in calculating the AO term. This prevents self occlusion and improves the ao quality. 

Optimisation - try out different occlusion functions: The original ao calculation I was using was this; 

step(falloff,depthDifference)*(1.0-smoothstep(falloff,strength,depthDifference)); 

which produced the ao seen in the previous post's screenshots. I then added in the normals to the calculation as so;

step(falloff,depthDifference)*normDiff*(1.0-smoothstep(falloff,strength,depthDifference)); 

While this eliminated the self occlusion, it also produced ambient occlusion that didn't look quite right. I found that eliminating the step function from the calculation greatly improved the results, i.e.                                                 
     
if (depthDifference>= falloff && depthDifference <= strength)
finalColour += normDiff*(1.0-smoothstep(falloff,strength,depthDifference));  
   
However, I discovered that the reason that the previous ao calculation was wrong due to the way I got depthDifference. Originally I had been getting depthDifference from sampleDepth - linearDepth, i.e. the depth of the occluder pixel - the depth of the current pixel, both taken from the depth texture. Changing this to sample.z - sampleDepth (as done in the StarCraft SSAO), fixed the problem and I was able to go back to using:    
                          
step(falloff,depthDifference)*normDiff*(1.0-smoothstep(falloff,strength,depthDifference));

Optimisation - investigate reducing texture lookups: Reducing the size of any of the textures involved - i.e. Depth buffer, SSAO buffer, or blurred SSAO buffer - greatly improves performance, but also decreases graphical quality. I have come across a technique called bilateral upsampling which may help to remedy this, and I will be researching into it this weekend.

Optimisation -investigate other techniques that improve performance: I have been trying a number of tweaks to my shader: such as combining multiple operations in one, and decreasing the number of samples. However, the number of texture lookups is the main performance factor, I believe, and so that is my focus.

When it comes to graphical quality, theSSAO produced is quite noisy, and even blurring does not get rid of the noise completely. I am pretty sure that this is due to the way I am getting the random normals and is something I need to look into fixing, hopefully before Wednesday.

In regards to the dissertation, I am in the midst of writing the introduction and will try to start the lit review next week at some point. 

SSAO term:



Blurred SSAO term: 

No comments:

Post a Comment