| Support Forum G3D Web Page |
Screen-space ambient obscurance.
More...
Inherits G3D::ReferenceCountedObject.
Classes | |
| class | PerViewBuffers |
Public Member Functions | |
| const String & | name () const |
| For debugging and visualization purposes. More... | |
| void | setShaderArgs (UniformTable &args, const String &prefix="ambientOcclusion_", const Sampler &sampler=Sampler::buffer()) |
Binds:
sampler2D <prefix>##buffer;
ivec2 <prefix>##offset;
#define <prefix>##notNull 1;
to args. More... | |
| shared_ptr< Texture > | texture () const |
| Returns the ao buffer texture, or Texture::white() if AO is disabled or supported on this GPU. More... | |
| void | update (RenderDevice *rd, const AmbientOcclusionSettings &settings, const shared_ptr< Camera > &camera, const shared_ptr< Texture > &depthTexture, const shared_ptr< Texture > &peeledDepthBuffer=nullptr, const shared_ptr< Texture > &normalBuffer=nullptr, const shared_ptr< Texture > &ssVelocityBuffer=nullptr, const Vector2int16 guardBandSize=Vector2int16(0, 0)) |
| Convenience method for resizing the AO texture from aoFramebuffer to match the size of its depth buffer and then computing AO from the depth buffer. More... | |
Static Public Member Functions | |
| static shared_ptr< AmbientOcclusion > | create (const String &name="G3D::AmbientOcclusion") |
| Create a new AmbientOcclusion instance. More... | |
| static bool | supported () |
| Returns false if this graphics card is known to perform AmbientOcclusion abnormally slowly. More... | |
Protected Member Functions | |
| AmbientOcclusion (const String &name) | |
| void | blurHorizontal (RenderDevice *rd, const AmbientOcclusionSettings &settings, const shared_ptr< Texture > &depthBuffer, const float farPlaneZ, const Vector4 &projConstant=Vector4::zero(), const shared_ptr< Texture > &normalBuffer=shared_ptr< Texture >()) |
| normalBuffer and normalReadScaleBias are only used if settings.useNormalsInBlur is true and normalBuffer is non-null. More... | |
| void | blurOneDirection (RenderDevice *rd, const AmbientOcclusionSettings &settings, const shared_ptr< Texture > &depthBuffer, const float farPlaneZ, const Vector4 &projConstant, const shared_ptr< Texture > &normalBuffer, const Vector2int16 &axis, const shared_ptr< Framebuffer > &framebuffer, const shared_ptr< Texture > &source) |
| Shared code for the vertical and horizontal blur passes. More... | |
| void | blurVertical (RenderDevice *rd, const AmbientOcclusionSettings &settings, const shared_ptr< Texture > &depthBuffer, const float farPlaneZ, const Vector4 &projConstant=Vector4::zero(), const shared_ptr< Texture > &normalBuffer=shared_ptr< Texture >()) |
| normalBuffer and normalReadScaleBias are only used if settings.useNormalsInBlur is true and normalBuffer is non-null. More... | |
| void | compute (RenderDevice *rd, const AmbientOcclusionSettings &settings, const shared_ptr< Texture > &depthBuffer, const Vector3 &clipConstant, const Vector4 &projConstant, float projScale, const float farPlaneZ, const CoordinateFrame ¤tCameraFrame, const CoordinateFrame &prevCameraFrame, const shared_ptr< Texture > &peeledDepthBuffer=nullptr, const shared_ptr< Texture > &normalBuffer=nullptr, const shared_ptr< Texture > &ssVelocityBuffer=nullptr) |
Render the obscurance constant at each pixel to the currently-bound framebuffer. More... | |
| void | compute (RenderDevice *rd, const AmbientOcclusionSettings &settings, const shared_ptr< Texture > &depthBuffer, const shared_ptr< Camera > &camera, const shared_ptr< Texture > &peeledDepthBuffer=nullptr, const shared_ptr< Texture > &normalBuffer=nullptr, const shared_ptr< Texture > &ssVelocityBuffer=nullptr) |
| Convenience wrapper for the full version of compute(). More... | |
| void | computeCSZ (RenderDevice *rd, const Array< shared_ptr< Framebuffer > > &cszFramebuffers, const shared_ptr< Texture > &csZBuffer, const AmbientOcclusionSettings &settings, const shared_ptr< Texture > &depthBuffer, const Vector3 &clipInfo, const shared_ptr< Texture > &peeledDepthBuffer) |
| virtual void | computeRawAO (RenderDevice *rd, const AmbientOcclusionSettings &settings, const shared_ptr< Texture > &depthBuffer, const Vector3 &clipConstant, const Vector4 &projConstant, float projScale, const float farPlaneZ, const shared_ptr< Texture > &csZBuffer, const shared_ptr< Texture > &peeledCSZBuffer=shared_ptr< Texture >(), const shared_ptr< Texture > &normalBuffer=shared_ptr< Texture >()) |
| void | initializePerViewBuffers (int size) |
| Creates the per view buffers if necessary. More... | |
| void | packBlurKeys (RenderDevice *rd, const AmbientOcclusionSettings &settings, const shared_ptr< Texture > &depthBuffer, const Vector3 &clipInfo, const float farPlaneZ, const shared_ptr< Texture > &normalBuffer) |
| void | resizeBuffers (const shared_ptr< Texture > &depthTexture, bool packKey) |
Static Protected Member Functions | |
| template<class T , class ... ArgTypes> | |
| static shared_ptr< T > | createShared (ArgTypes &&... args) |
| Like std::make_shared, but works for protected constructors. More... | |
Protected Attributes | |
| shared_ptr< Shader > | m_aoShader |
| int | m_guardBandSize |
| For raw and temporally-filtered buffers. More... | |
| shared_ptr< Texture > | m_hBlurredBuffer |
| Has AO in R and depth in G. More... | |
| shared_ptr< Framebuffer > | m_hBlurredFramebuffer |
| shared_ptr< Shader > | m_minifyShader |
| String | m_name |
| Used for debugging and visualization purposes. More... | |
| int | m_outputGuardBandSize |
| For spatially blurred and output buffers. More... | |
| shared_ptr< Framebuffer > | m_packedKeyBuffer |
| If normals enabled, RGBA8, RG is CSZ, and BA is normal in Oct16. More... | |
| Array< shared_ptr< PerViewBuffers > > | m_perViewBuffers |
| For now, can only be 1 or 2 in size. More... | |
| shared_ptr< Texture > | m_rawAOBuffer |
| Has AO in R and depth in G * 256 + B. More... | |
| shared_ptr< Framebuffer > | m_rawAOFramebuffer |
| shared_ptr< Texture > | m_resultBuffer |
| shared_ptr< Framebuffer > | m_resultFramebuffer |
| String | m_shaderFilenamePrefix |
| Prefix for the shaders. More... | |
| TemporalFilter | m_temporalFilter |
| shared_ptr< Texture > | m_temporallyFilteredBuffer |
| Has AO in R and depth in G * 256 + B. More... | |
| shared_ptr< Texture > | m_texture |
| As of the last call to update. More... | |
| shared_ptr< UniformTable > | m_uniformTable |
| Appended to all Args for shader passes run by this class. More... | |
Screen-space ambient obscurance.
Create one instance of AmbientObscurance per viewport or Framebuffer rendered in the frame. Otherwise every update() call will trigger significant texture reallocation.
|
inlineprotected |
|
protected |
normalBuffer and normalReadScaleBias are only used if settings.useNormalsInBlur is true and normalBuffer is non-null.
projConstant is only used if settings.useNormalsInBlur is true and normalBuffer is null
|
protected |
Shared code for the vertical and horizontal blur passes.
|
protected |
normalBuffer and normalReadScaleBias are only used if settings.useNormalsInBlur is true and normalBuffer is non-null.
projConstant is only used if settings.useNormalsInBlur is true and normalBuffer is null
|
protected |
Render the obscurance constant at each pixel to the currently-bound framebuffer.
| rd | The rendering device/graphics context. The currently-bound framebuffer must match the dimensions of depthBuffer. |
| settings | See G3D::AmbientOcclusionSettings. |
| depthBuffer | Standard hyperbolic depth buffer. Can be from either an infinite or finite far plane depending on the values in projConstant and clipConstant. |
| clipConstant | Constants based on clipping planes: |
| projConstant | Constants based on the projection matrix: |
| projScale | Pixels-per-meter at z=-1, e.g., computed by: |
This is usually around 500.
| peeledDepthBuffer | An optional peeled depth texture, rendered from the same viewpoint as the depthBuffer, but not necessarily with the same resolution. |
|
protected |
Convenience wrapper for the full version of compute().
| camera | The camera that the scene was rendered with. |
|
protected |
|
protectedvirtual |
|
static |
Create a new AmbientOcclusion instance.
Only one is ever needed, but if you are rendering to differently-sized framebuffers it is faster to create one instance per resolution than to constantly force AmbientOcclusion to resize its internal buffers.
|
inlinestaticprotectedinherited |
Like std::make_shared, but works for protected constructors.
Call as createShared<myclass>.
|
protected |
Creates the per view buffers if necessary.
|
inline |
For debugging and visualization purposes.
|
protected |
|
protected |
| void G3D::AmbientOcclusion::setShaderArgs | ( | UniformTable & | args, |
| const String & | prefix = "ambientOcclusion_", |
||
| const Sampler & | sampler = Sampler::buffer() |
||
| ) |
Binds:
sampler2D <prefix>##buffer;
ivec2 <prefix>##offset;
#define <prefix>##notNull 1;
to args.
|
static |
Returns false if this graphics card is known to perform AmbientOcclusion abnormally slowly.
|
inline |
Returns the ao buffer texture, or Texture::white() if AO is disabled or supported on this GPU.
Modulate indirect illumination by this
| void G3D::AmbientOcclusion::update | ( | RenderDevice * | rd, |
| const AmbientOcclusionSettings & | settings, | ||
| const shared_ptr< Camera > & | camera, | ||
| const shared_ptr< Texture > & | depthTexture, | ||
| const shared_ptr< Texture > & | peeledDepthBuffer = nullptr, |
||
| const shared_ptr< Texture > & | normalBuffer = nullptr, |
||
| const shared_ptr< Texture > & | ssVelocityBuffer = nullptr, |
||
| const Vector2int16 | guardBandSize = Vector2int16(0, 0) |
||
| ) |
Convenience method for resizing the AO texture from aoFramebuffer to match the size of its depth buffer and then computing AO from the depth buffer.
| guardBandSize | Required to be the same in both dimensions and non-negative |
|
protected |
|
protected |
For raw and temporally-filtered buffers.
|
protected |
Has AO in R and depth in G.
|
protected |
|
protected |
|
protected |
Used for debugging and visualization purposes.
Referenced by name().
|
protected |
For spatially blurred and output buffers.
|
protected |
If normals enabled, RGBA8, RG is CSZ, and BA is normal in Oct16.
|
protected |
For now, can only be 1 or 2 in size.
|
protected |
Has AO in R and depth in G * 256 + B.
|
protected |
|
protected |
|
protected |
|
protected |
Prefix for the shaders.
Default is "AmbientOcclusion_". This is useful when subclassing AmbientOcclusion to avoid a conflict with the default shaders.
|
protected |
|
protected |
Has AO in R and depth in G * 256 + B.
|
protected |
As of the last call to update.
This is either m_resultBuffer or Texture::white()
Referenced by texture().
|
protected |
Appended to all Args for shader passes run by this class.
Useful for prototyping minor variations; simply inherit from this class, modify the shaders and add any new uniforms/macros required here. Note that because of the inherent slowness of iterating over hash tables, such a modification is not as performant as possible.
1.8.15