Geogram  Version 1.9.1-rc
A programming library of geometric algorithms
GEO::AmbientOcclusionImpl Class Reference

Implementation of AmbientOcclusion full screen effect. More...

#include <geogram_gfx/full_screen_effects/ambient_occlusion.h>

Inheritance diagram for GEO::AmbientOcclusionImpl:
GEO::FullScreenEffectImpl GEO::Counted GEO::GLSL::PseudoFileProvider

Public Member Functions

 AmbientOcclusionImpl ()
 AmbientOcclusionImpl constructor.
 
 ~AmbientOcclusionImpl () override
 AmbientOcclusionImpl destructor.
 
double required_GLSL_version () const override
 Gets the minimum required GLSL version needed to execute the shaders in this FullScreenEffectImpl. More...
 
void pre_render (index_t w, index_t h) override
 Callback called at the beginning of each frame. More...
 
void post_render () override
 Callback called at the end of each frame. More...
 
void update () override
 Callback called whenever parameters are changed in the GUI. More...
 
index_t get_lightness () const
 Gets the lightness. More...
 
void set_lightness (index_t x)
 Sets the lightness. More...
 
index_t get_contrast () const
 Gets the contrast. More...
 
void set_contrast (index_t x)
 Sets the contrast. More...
 
index_t get_blur_width () const
 Gets the size of the blurring kernel. More...
 
void set_blur_width (index_t x)
 Sets the size of the blurring kernel. More...
 
index_t get_nb_directions () const
 Gets the number of directions. More...
 
void set_nb_directions (index_t x)
 Sets the number of directions. More...
 
double get_max_radius () const
 Gets the maximum radius around a pixel where ambient occlusion is computed. More...
 
void set_max_radius (double x)
 Sets the maximum radius around a pixel where ambient occlusion is computed. More...
 
double get_step_mul () const
 Gets the multiplicative factor applied to each step when traversing from a pixel. More...
 
void set_step_mul (double x)
 Sets the multiplicative factor applied to each step when traversing from a pixel. More...
 
- Public Member Functions inherited from GEO::FullScreenEffectImpl
 FullScreenEffectImpl ()
 FullScreenEffectImpl constructor.
 
 ~FullScreenEffectImpl () override
 FullScreenEffectImpl destructor.
 
index_t width () const
 Gets the width of the rendering context. More...
 
index_t height () const
 Gets the height of the rendering context. More...
 
bool OK () const
 Tests whether this FullScreenEffect can be used. More...
 
virtual void get_vertex_shader_preamble_pseudo_file (std::vector< GLSL::Source > &sources)
 Gets the content of the virtual file GLUP/current_profile/vertex_shader_preamble.h. More...
 
virtual void get_fragment_shader_preamble_pseudo_file (std::vector< GLSL::Source > &sources)
 Gets the content of the virtual file GLUP/current_profile/fragment_shader_preamble.h. More...
 
- Public Member Functions inherited from GEO::Counted
void ref () const
 Increments the reference count. More...
 
void unref () const
 Decrements the reference count. More...
 
bool is_shared () const
 Check if the object is shared. More...
 
int nb_refs () const
 Gets the number of references that point to this object. More...
 
- Public Member Functions inherited from GEO::GLSL::PseudoFileProvider
virtual ~PseudoFileProvider ()
 PseudoFileProvider destructor.
 

Protected Member Functions

void initialize (index_t w, index_t h) override
 Callback called the first time this FullScreenEffectImpl is used. More...
 
void resize (index_t w, index_t h) override
 Callback called whenever the rendering context is resized. More...
 
void create_random_tex ()
 Creates a texture with random values in it. More...
 
void display_final_texture ()
 Displays the final result. More...
 
void compute_SSAO ()
 Computes the ambient occlusion in the blur_1_ FrameBufferObject, from the depth textures.
 
void blur ()
 Applies a Gaussian blur to the (raw) ambient occlusion computed by apply_shader(). More...
 
void get_proj_inv ()
 Gets the inverse of the projection transform. More...
 
- Protected Member Functions inherited from GEO::FullScreenEffectImpl
void reset_alpha ()
 Resets alpha plane to 1.0 (opaque)
 
- Protected Member Functions inherited from GEO::Counted
 Counted ()
 Creates a reference counted object. More...
 
virtual ~Counted ()
 Destroys a reference counted object. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from GEO::Counted
static void ref (const Counted *counted)
 Increments the reference count. More...
 
static void unref (const Counted *counted)
 Decrements the reference count. More...
 
- Protected Attributes inherited from GEO::FullScreenEffectImpl
FrameBufferObject draw_FBO_
 
bool ES_profile_
 

Detailed Description

Implementation of AmbientOcclusion full screen effect.

Definition at line 57 of file ambient_occlusion.h.

Member Function Documentation

◆ blur()

void GEO::AmbientOcclusionImpl::blur ( )
protected

Applies a Gaussian blur to the (raw) ambient occlusion computed by apply_shader().

The input and the result are both in blur_1_. The function uses blur_2_ as a work variable. It does two passes of 1D blurring (horizontal and vertical, one from blur_1_ to blur_2_ and the other from blur_2_ to blur_1_.

◆ create_random_tex()

void GEO::AmbientOcclusionImpl::create_random_tex ( )
protected

Creates a texture with random values in it.

Used to randomly rotate the direction sampling pattern.

◆ display_final_texture()

void GEO::AmbientOcclusionImpl::display_final_texture ( )
protected

Displays the final result.

It composites the final result with the previously rendered frame.

◆ get_blur_width()

index_t GEO::AmbientOcclusionImpl::get_blur_width ( ) const
inline

Gets the size of the blurring kernel.

Returns
the size of the blurring kernel, in pixels.

Definition at line 129 of file ambient_occlusion.h.

◆ get_contrast()

index_t GEO::AmbientOcclusionImpl::get_contrast ( ) const
inline

Gets the contrast.

Returns
the contrast, as an integer.

A value of 10 (default) corresponds to average contrast.

Definition at line 113 of file ambient_occlusion.h.

◆ get_lightness()

index_t GEO::AmbientOcclusionImpl::get_lightness ( ) const
inline

Gets the lightness.

Returns
the lightness, as an integer.

A value of 10 (default) corresponds to average lightness.

Definition at line 95 of file ambient_occlusion.h.

◆ get_max_radius()

double GEO::AmbientOcclusionImpl::get_max_radius ( ) const
inline

Gets the maximum radius around a pixel where ambient occlusion is computed.

Returns
the radius, relative to screen size, in 0.0 ... 1.0.

Definition at line 169 of file ambient_occlusion.h.

◆ get_nb_directions()

index_t GEO::AmbientOcclusionImpl::get_nb_directions ( ) const
inline

Gets the number of directions.

These directions are used to compute the visibility integrals (the higher, the better), typical value is 5 to 10.

Returns
x the number of directions.

Definition at line 148 of file ambient_occlusion.h.

◆ get_proj_inv()

void GEO::AmbientOcclusionImpl::get_proj_inv ( )
protected

Gets the inverse of the projection transform.

It is used by the SSAO shader, to inverse-map screen-space coordinates into world space.

◆ get_step_mul()

double GEO::AmbientOcclusionImpl::get_step_mul ( ) const
inline

Gets the multiplicative factor applied to each step when traversing from a pixel.

Returns
the multiplicative step.

Definition at line 189 of file ambient_occlusion.h.

◆ initialize()

void GEO::AmbientOcclusionImpl::initialize ( index_t  w,
index_t  h 
)
overrideprotectedvirtual

Callback called the first time this FullScreenEffectImpl is used.

Parameters
[in]w,hwidth and height of the rendering context.

Subclasses may overload this callback. The OpenGL context is properly bound when this function is called.

Reimplemented from GEO::FullScreenEffectImpl.

◆ post_render()

void GEO::AmbientOcclusionImpl::post_render ( )
overridevirtual

Callback called at the end of each frame.

Subclasses may overload this function, and use it to transfered the content of FrameBufferObjects to the screen. Baseclass implementation copies the contents of draw_FBO_ to the screen.

Reimplemented from GEO::FullScreenEffectImpl.

◆ pre_render()

void GEO::AmbientOcclusionImpl::pre_render ( index_t  w,
index_t  h 
)
overridevirtual

Callback called at the beginning of each frame.

Parameters
[in]width,heightdimension of the rendering context.

Baseclass implementation redirects rendering to draw_FBO_.

Reimplemented from GEO::FullScreenEffectImpl.

◆ required_GLSL_version()

double GEO::AmbientOcclusionImpl::required_GLSL_version ( ) const
overridevirtual

Gets the minimum required GLSL version needed to execute the shaders in this FullScreenEffectImpl.

Default implementation returns 1.0.

Returns
the minimum required GLSL version as a double precision floating point number.

Reimplemented from GEO::FullScreenEffectImpl.

◆ resize()

void GEO::AmbientOcclusionImpl::resize ( index_t  w,
index_t  h 
)
overrideprotectedvirtual

Callback called whenever the rendering context is resized.

Subclasses may overload this callback, for instance to resize FrameBufferObject.

Parameters
[in]w,hnew width and height of the rendering context, in pixels.

Reimplemented from GEO::FullScreenEffectImpl.

◆ set_blur_width()

void GEO::AmbientOcclusionImpl::set_blur_width ( index_t  x)
inline

Sets the size of the blurring kernel.

Parameters
[in]xthe size of the blurring kernel, in pixels.

Definition at line 137 of file ambient_occlusion.h.

◆ set_contrast()

void GEO::AmbientOcclusionImpl::set_contrast ( index_t  x)
inline

Sets the contrast.

A value of 10 (default) corresponds to average contrast.

Definition at line 121 of file ambient_occlusion.h.

◆ set_lightness()

void GEO::AmbientOcclusionImpl::set_lightness ( index_t  x)
inline

Sets the lightness.

Parameters
[in]xthe lightness, as an integer.

A value of 10 (default) corresponds to average lightness.

Definition at line 104 of file ambient_occlusion.h.

◆ set_max_radius()

void GEO::AmbientOcclusionImpl::set_max_radius ( double  x)
inline

Sets the maximum radius around a pixel where ambient occlusion is computed.

Parameters
[in]xthe radius, relative to screen size, in 0.0 ... 1.0.

Definition at line 179 of file ambient_occlusion.h.

◆ set_nb_directions()

void GEO::AmbientOcclusionImpl::set_nb_directions ( index_t  x)
inline

Sets the number of directions.

These directions are used to compute the visibility integrals (the higher, the better), typical value is 5 to 10.

Parameters
[in]xthe number of directions.

Definition at line 159 of file ambient_occlusion.h.

◆ set_step_mul()

void GEO::AmbientOcclusionImpl::set_step_mul ( double  x)
inline

Sets the multiplicative factor applied to each step when traversing from a pixel.

Parameters
[in]xthe multiplicative step.

Definition at line 198 of file ambient_occlusion.h.

◆ update()

void GEO::AmbientOcclusionImpl::update ( )
overridevirtual

Callback called whenever parameters are changed in the GUI.

Subclasses may overload this function, and use it to transfer parameters to shader uniforms.

Reimplemented from GEO::FullScreenEffectImpl.


The documentation for this class was generated from the following file: