Code Monkey home page Code Monkey logo

ssao's Introduction

Screen space ambient occlusion

Screen space ambient occlusion (SSAO) is a computer graphics technique for efficiently approximating the ambient occlusion effect in real time. It was developed by Vladimir Kajalin while working at Crytek and was used for the first time in 2007 by the video game Crysis, also developed by Crytek. While not an incredibly obvious effect, the image with SSAO enabled does feel a lot more realistic due to these small occlusion-like details, giving the entire scene a greater feel of depth.

example

Implementation

Implementing this effect was done by using OpenGL for Java. In addition, the library rafgl was used, which is a library written by my teaching assistant at university. The purpose of rafgl is to make working with OpenGL in Java much easier. Furthermore, the classes GameCamera, GameObject and GameShader are classes I entirely took my teaching assistant as well, and their role is to handle the behaviour of the camera, model objects and the shaders.

I used 5 shaders to achieve SSAO, and those are:

  1. Geometry shader - The basic shader
  2. SSAO shader - The actual shader where we produce the effect. The SSAO shader runs on a 2D screen-filled quad that calculates the occlusion value for each of the generated fragments (for use in the final lighting shader)
  3. Blur shader - Since we are using noise to randomize the kernel for better quality and performance, we have to use blurring to remove the noise
  4. Lighting shader - The shader that applies the occlusion factors to the lighting equatio. All we have to do is multiply the per-fragment ambient occlusion factor to the lighting's ambient component
  5. Postprocessing shader- Shader that lets us turn the effect on or off

This project was made possible largely thanks to information in the following article: https://learnopengl.com/Advanced-Lighting/SSAO

Results

SSAO Off:

ssaoOff

SSAO On:

ssaoOn

SSAO Shade Off:

ssaoOffClose

SSAO Shade On (Close):

ssaoOnClose

SSAO Shade On (Further away):

ssaoOnFurther

Usage

The program is started by running Main.java. The camera can be moved around using WASD and the arrow keys. The effect can be tweaked using QERT, QE will tweak the radius, RT will tweak the bias. The space key can be used to turn the effect on or off, to see the difference. Z and X will move the wall behind the model, demonstrating the range check part of the technique.

ssao's People

Contributors

baksonator avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.