Monday, September 19, 2016

Blog 2: Algorithms

Ambient occlusion

Ambient occlusion is a way to render shading in a 3D area. This algorithm calculates how exposed areas in a scene should be and create ambient lighting. The Algorithm's goal is to figure out the darker areas of an object. Once it has calculated this then the computer can darken that part of the image to make a simulation of natural light. This is done by finding an "accessibility value" that is calculated for each surface point. This effect does not necessarily create shadows, but instead just darken areas on the surface to help improve a rendered image's tone. This process is normally done as an extra effect done in post processing to help improve the image instead of creating it.

One real time application for this algorithm is computer games, this uses a different variation of ambient occlusion called screen space ambient occlusion (SSAO). This is a much more efficient version of the ambient occlusion algorithm that is able to develop the effect in real time. SSAO was originally invented by Vladimir Kajalin while working on the video game Crysis. It was released as a feature in the game when it came out in 2007. The algorithm is implemented as a shader that gathers the same information as the ambient occlusion algorithm, but saves a value for every pixel. The it calculates the occlusion for each pixel and assigns it a value. This is a very costly method that is extremely inefficient, and would make it impossible to run anything at real time speeds. So to get real time speeds SSAO uses a randomly rotated kernal. A kernal is a method used for sharpening or blurring an image using a small matrix. It does this by using a convolution operation to determine weather to sharpen or blur each pixel in relation to the other to get the desired effect. The random kernal orientation is repeated every N pixels which allows the user to set how extreme of the desired effect the want, and allow different amounts of post processing effect to take place. High quality results tend to be in the area of 16 or less to receive an acceptable effect. Because the algorithm is only processing a portion of the pixels you still receive the desired effect without using as much processor space because not every pixel has to be calculated.

This algorithm is very complicated and could in theory be calculated by hand but realistically you have to have a computer do all the calculations for you. This is because you wold have to do the same calculation for every point in your image which would become very tedious, and be very prone to mistakes.

Ambient occlusion is a Algorithm that will give you a precise output every time. Like what was said in the book " it is a fail safe way to achieve a specific goal". The problem that is frequently faced with this algorithm is that it's a very inefficient way of calculating the desired output. The SSAO is a heuristic that was created from the algorithm that is able to be much more efficient and still recreate mostly the same outcome. it takes only a portion of the pixels and uses that to represent all the ones surrounding it instead of calculating every single pixel like the algorithm does.

I decided to to choose this algorithm for my blog because I have always seen it as an option to turn on when playing video games, and I know that it helped make my game look better. I never knew how it worked and was interested in what it did. I can say that after our lecture in class and reading about it for the last hour I understand it, and I think that is really cool how it is able to calculate the different levels of shading, and help make the image look better.

No comments:

Post a Comment