![]() |
Workspace 6.21.5
|
Class for using Screen Space Ambient Occlusion (SSAO) within an OpenGL renderer. More...
#include <Rendering/OpenGL/wsglscreenspaceambientocclusion.h>
Inherits QObject.
Signals | |
void | reinitRequested () |
Public Member Functions | |
WSGLScreenSpaceAmbientOcclusion () | |
~WSGLScreenSpaceAmbientOcclusion () override | |
GLfloat | getAttenuation () const |
GLfloat | getEdgeSize () |
unsigned | getNumSamples () const |
GLfloat | getSampleLength () const |
bool | getSsaoSupported () const |
GLfloat | getStrength () const |
bool | initialize (WSGLContext &context) |
bool | renderLayersWithSsao (GLuint fbo, const Camera &camera, const Mesh::BoundingBox &sceneExtent, const Mesh::TransformMatrix &matWorldViewProj, WSGLBufferObjectCacheItemPtr &vboSquareVerts, WSGLBufferObjectCacheItemPtr &vboSquareElem, WSGLLayers &screenLayers, WSGLTexture &colorTexture, WSGLTexture *specularTexture) |
bool | resize () |
void | setAdjust (GLfloat x, GLfloat y) |
void | setAttenuation (GLfloat f) |
void | setBackgroundColor (const QColor &color) |
void | setNumSamples (unsigned i) |
void | setSampleLength (GLfloat f) |
void | setSize (int viewportWidth, int viewportHeight) |
void | setSpecularHighlighting (bool b) |
void | setStrength (GLfloat f) |
SSAO is a shadowing technique used to make depth more perceptible within a scene. SSAO is expensive, so it is recommended it only be activated:
- If the user has not disabled it in an attempt to improve performance.
All data will be stored as pixel unpack buffers in the WSGLBufferObjectCache provided by the caller.
To add the SSAO capability to a new shader, follow these steps:
1. Add the capability to the shader's implementation. 2. Add the required code to the shader: 2a. If the shader doesn't use specular highlighting (eg. Blinn-Phong) replace "gl_FragColor = ..." with: if (wsgl_uScreenSpaceAmbientOcclusionEnabled) wsgl_ScreenSpaceAmbientOcclusionSpecular(normal, color.a, gl_FragCoord.z); gl_FragData[0] = color; 2b. If the shader does use specular highlighting (eg. Blinn-Phong) replace "gl_FragColor = ..." with: if (wsgl_uScreenSpaceAmbientOcclusionEnabled) { color = Color without specular highlights; vec4 specular = only specular highlights; wsgl_ScreenSpaceAmbientOcclusionSpecular(normal, color.a, gl_FragCoord.z, specular); } else color = Color with specular highlighting; gl_FragData[0] = color; 3. Replace the virtual shader function 'bool appliesScreenSpaceAmbientOcclusion' so it always returns true. 4. If the shader applies specular lighting, replace the virtual shader function 'bool appliesSpecular' to return true.
The SSAO currently supports:
- Depth Peeling - Specular Highlighting - Transparent objects (Alpha Blending)
The SSAO current doesn't support:
- Half resolution - Window edge clipping
|
override |
GLfloat getAttenuation | ( | ) | const |
GLfloat getEdgeSize | ( | ) |
unsigned getNumSamples | ( | ) | const |
GLfloat getSampleLength | ( | ) | const |
bool getSsaoSupported | ( | ) | const |
GLfloat getStrength | ( | ) | const |
bool initialize | ( | WSGLContext & | context | ) |
|
signal |
bool renderLayersWithSsao | ( | GLuint | fbo, |
const Camera & | camera, | ||
const Mesh::BoundingBox & | sceneExtent, | ||
const Mesh::TransformMatrix & | matWorldViewProj, | ||
WSGLBufferObjectCacheItemPtr & | vboSquareVerts, | ||
WSGLBufferObjectCacheItemPtr & | vboSquareElem, | ||
WSGLLayers & | screenLayers, | ||
WSGLTexture & | colorTexture, | ||
WSGLTexture * | specularTexture | ||
) |
bool resize | ( | ) |
void setAdjust | ( | GLfloat | x, |
GLfloat | y | ||
) |
void setAttenuation | ( | GLfloat | f | ) |
void setBackgroundColor | ( | const QColor & | color | ) |
void setNumSamples | ( | unsigned | i | ) |
void setSampleLength | ( | GLfloat | f | ) |
void setSize | ( | int | viewportWidth, |
int | viewportHeight | ||
) |
void setSpecularHighlighting | ( | bool | b | ) |
void setStrength | ( | GLfloat | f | ) |