- Almost finished writing the dissertation introduction.
- I have managed to implement an edge detecting blur. It is not a completely accurate implementation, mathswise, but it is low cost.
- Have started working on the global illumination aspect - I have looked at screen space radiosity techniques and implemented a simple local radiosity effect in screen space. This is essentially using the same ssao calculation but also taking into account scene colours (which are rendered into a half screen size texture).
- Next I plan to go over the SSDO paper in detail, both for my lit review and to develop more ideas for the GI aspect.
Sunday, 27 March 2011
Progress Report ~5
Friday, 18 March 2011
Progress Report ~4
Met with Matt on Wednesday to update him on my progress, and discuss what I plan to do next.
I have optimised the SSAO performance by using downscaled SSAO and Blur textures. Both texture are half the screen size, and the final term is gained by upsampling the final blur texture using bilinear interpolation. This resulted in a considerable performance gain - the framerate(fps) is almost doubled, but the quality of the SSAO has suffered somewhat. However, I consider this to be an acceptable tradeoff, considering how much lower the frametime (ms) is now.
There are a few main areas that can be optimised to increase performance:
In regards to the blur pass, I am looking into implementing a smart blur which respects the edges - using normals/depth as a weight. As with the bilateral upsampling, this may impact the performance, but, depending on the quality increase, may be worthwhile.
I hope to get the majority of this done before next week, and then I will start on the global illumination aspect of my shader.
Also - In my previous post, I stated that I had changed the way I calculated the depthDifference from my original implementation: ie. from OccluderSample.a - linearDepth to sample.z - OccluderSample.a, because the original calculation produced odd results. I have now realised, that this because I had them in the wrong order. It should have been: linearDepth - OccluderSample.a. This produces correct looking results - which to my eyes seem slightly more defined than the sample.z - OccluderSample.a results. For now, I have implemented the ability to switch between the two within the program.
I have optimised the SSAO performance by using downscaled SSAO and Blur textures. Both texture are half the screen size, and the final term is gained by upsampling the final blur texture using bilinear interpolation. This resulted in a considerable performance gain - the framerate(fps) is almost doubled, but the quality of the SSAO has suffered somewhat. However, I consider this to be an acceptable tradeoff, considering how much lower the frametime (ms) is now.
There are a few main areas that can be optimised to increase performance:
- Texture Lookups: This is probably the most performance consuming aspect of the SSAO shader. Downsampling the SSAO and blur textures reduces the number of lookups and increases performance.
- Shader Organisation: Combining shader operations and reducing the amount of code can help to optimise the shaders. I will probably leave this optimisation till the end, as it will reduce the readability of the code.
- No. of Samples: Reducing the number of samples does result in faster performance, however the quality dip is not acceptable. Currently the sample no. stands at 16, which provides a reasonable balance between quality and speed.
- Blurring: The type and range of blur used will also be a factor in the performance of the program. Right now, a very simple gaussian blur has been implemented which uses two passes - vertical and horizental. Other types of blur such as bilateral(edge detecting) have yet to be tested.
In regards to the blur pass, I am looking into implementing a smart blur which respects the edges - using normals/depth as a weight. As with the bilateral upsampling, this may impact the performance, but, depending on the quality increase, may be worthwhile.
I hope to get the majority of this done before next week, and then I will start on the global illumination aspect of my shader.
Also - In my previous post, I stated that I had changed the way I calculated the depthDifference from my original implementation: ie. from OccluderSample.a - linearDepth to sample.z - OccluderSample.a, because the original calculation produced odd results. I have now realised, that this because I had them in the wrong order. It should have been: linearDepth - OccluderSample.a. This produces correct looking results - which to my eyes seem slightly more defined than the sample.z - OccluderSample.a results. For now, I have implemented the ability to switch between the two within the program.
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.
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:
Wednesday, 2 March 2011
Progress Report ~2
Another update! And so soon after the last one.
Met with Matt today, to update him on my progress and discuss what I'll be focusing on next.
There are two aspects to my research question - optimisation and global illumination. For the next fortnight I will be focusing on optimising the SSAO shader, since currently it's hitting my framerate quite substantially. Then I will focus on the global illumination aspect.
I left room for manouvering in my Gantt chart, so I should be okay for time - getting a cold and then the flu didn't help, but I'm confident that I can get everything/or most things that I planned to do, done.
Tasks for the next two weeks:
I'm also going to start writing the literature review, this week and next week and I've made a list of possible topics to include:
Met with Matt today, to update him on my progress and discuss what I'll be focusing on next.
There are two aspects to my research question - optimisation and global illumination. For the next fortnight I will be focusing on optimising the SSAO shader, since currently it's hitting my framerate quite substantially. Then I will focus on the global illumination aspect.
I left room for manouvering in my Gantt chart, so I should be okay for time - getting a cold and then the flu didn't help, but I'm confident that I can get everything/or most things that I planned to do, done.
Tasks for the next two weeks:
- Implement blur shader - test both Gaussian (using scene normals) and bilateral blurs
- Try and get rid of SSAO artifacts (as seen in previous post)
- Optimisation - using scene normals in SSAO calculation
- Optimisation - try out different occlusion functions
- Optimisation - investigate reducing texture lookups
- Optimisation -investigate other techniques that improve performance
I'm also going to start writing the literature review, this week and next week and I've made a list of possible topics to include:
- Background on Ambient Occlusion, and non screen space techniques
- Screen Space Ambient Occlusion - Crytek's method, and variations on it. e.g. Nvidia's Image Space Horizon Based AO, and Blizzard's implementation of SSAO in Starcraft 2.
- Screen Space Directional Occlusion - from the paper "Approximating Dynamic Global Illumination in Image Space"
- Screen Space Radiosity - from an article in Shaderx7 - it's a very small section of the article but I'm trying to find more on it.
Progress Report ~1
So, it's been a while since my last update and while there has been progress, it has been slower than I would have hoped.
One thing that hampered the work flow was the flu, which resulted in me having to go home for week 4 to recover. Incidently, week 4 was supposed to be a technical supervisor meeting week, but that had to be delayed to week 5 instead.
However, the main thing that slowed progress, was the many problems that I encountered trying to implement SSAO in my d3d9 application. The shader I was using came from an article on Blizzard's implemention of SSAO in StarCraft 2 in the book Game Programming Gems 8 - there were a lot of variables that weren't really explained in the shader and I had to guess at a lot of the values I plugged into them. When I did get the shader to actually produce a result, the graphical effects it produced were obviously not ambient occlusion:
Some problems were easily solved (though easy to overlook as well), such as the effect of being able to see the SSAO effect of the room through the walls - this was caused by the Alpha Blending being turned on in the main file, so easily fixed. But even after fixing that, the scene still looked wrong. I am reasonably sure no that the main problem lay in the way the shader converted screen space positions to view space positions using the depth values, but at the time I could not work out why it was not working.
Suffice it to say, I spent a few weeks trying to get that shader to work, but ultimately I decided that it would be better to start a new SSAO shader from scratch and test each element step by step - which is really what I should have done in the first place. After spending weeks trying to get the GPGems8 shader to work and failing, it took me far less time than that to produce a new shader from scratch and get it working. However, I probably wouldn't have been able to get it to work so quickly if I hadn't been learning from those early failures.
I will detail the steps I took in implementing the new shader in another post, but for now here are some screens of the working depth texture and SSAO texture.
Depth and Normals (normals in rgb, depth in a):
SSAO without blur:
Unfortunately, there are some weird artifacts in the SSAO, that occur when the camera is at a certain angle to that back wall of the scene - I have yet to determine the cause:
One thing that hampered the work flow was the flu, which resulted in me having to go home for week 4 to recover. Incidently, week 4 was supposed to be a technical supervisor meeting week, but that had to be delayed to week 5 instead.
However, the main thing that slowed progress, was the many problems that I encountered trying to implement SSAO in my d3d9 application. The shader I was using came from an article on Blizzard's implemention of SSAO in StarCraft 2 in the book Game Programming Gems 8 - there were a lot of variables that weren't really explained in the shader and I had to guess at a lot of the values I plugged into them. When I did get the shader to actually produce a result, the graphical effects it produced were obviously not ambient occlusion:
Some problems were easily solved (though easy to overlook as well), such as the effect of being able to see the SSAO effect of the room through the walls - this was caused by the Alpha Blending being turned on in the main file, so easily fixed. But even after fixing that, the scene still looked wrong. I am reasonably sure no that the main problem lay in the way the shader converted screen space positions to view space positions using the depth values, but at the time I could not work out why it was not working.
Suffice it to say, I spent a few weeks trying to get that shader to work, but ultimately I decided that it would be better to start a new SSAO shader from scratch and test each element step by step - which is really what I should have done in the first place. After spending weeks trying to get the GPGems8 shader to work and failing, it took me far less time than that to produce a new shader from scratch and get it working. However, I probably wouldn't have been able to get it to work so quickly if I hadn't been learning from those early failures.
I will detail the steps I took in implementing the new shader in another post, but for now here are some screens of the working depth texture and SSAO texture.
Depth and Normals (normals in rgb, depth in a):
SSAO without blur:
Unfortunately, there are some weird artifacts in the SSAO, that occur when the camera is at a certain angle to that back wall of the scene - I have yet to determine the cause:
Subscribe to:
Comments (Atom)




