Geogram
Version 1.9.1-rc
A programming library of geometric algorithms
|
Implementation of AmbientOcclusion full screen effect. More...
#include <geogram_gfx/full_screen_effects/ambient_occlusion.h>
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_ |
Implementation of AmbientOcclusion full screen effect.
Definition at line 57 of file ambient_occlusion.h.
|
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_.
|
protected |
Creates a texture with random values in it.
Used to randomly rotate the direction sampling pattern.
|
protected |
Displays the final result.
It composites the final result with the previously rendered frame.
|
inline |
Gets the size of the blurring kernel.
Definition at line 129 of file ambient_occlusion.h.
|
inline |
Gets the contrast.
A value of 10 (default) corresponds to average contrast.
Definition at line 113 of file ambient_occlusion.h.
|
inline |
Gets the lightness.
A value of 10 (default) corresponds to average lightness.
Definition at line 95 of file ambient_occlusion.h.
|
inline |
Gets the maximum radius around a pixel where ambient occlusion is computed.
Definition at line 169 of file ambient_occlusion.h.
|
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.
Definition at line 148 of file ambient_occlusion.h.
|
protected |
Gets the inverse of the projection transform.
It is used by the SSAO shader, to inverse-map screen-space coordinates into world space.
|
inline |
Gets the multiplicative factor applied to each step when traversing from a pixel.
Definition at line 189 of file ambient_occlusion.h.
Callback called the first time this FullScreenEffectImpl is used.
[in] | w,h | width 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.
|
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.
Callback called at the beginning of each frame.
[in] | width,height | dimension of the rendering context. |
Baseclass implementation redirects rendering to draw_FBO_.
Reimplemented from GEO::FullScreenEffectImpl.
|
overridevirtual |
Gets the minimum required GLSL version needed to execute the shaders in this FullScreenEffectImpl.
Default implementation returns 1.0.
Reimplemented from GEO::FullScreenEffectImpl.
Callback called whenever the rendering context is resized.
Subclasses may overload this callback, for instance to resize FrameBufferObject.
[in] | w,h | new width and height of the rendering context, in pixels. |
Reimplemented from GEO::FullScreenEffectImpl.
|
inline |
Sets the size of the blurring kernel.
[in] | x | the size of the blurring kernel, in pixels. |
Definition at line 137 of file ambient_occlusion.h.
|
inline |
Sets the contrast.
A value of 10 (default) corresponds to average contrast.
Definition at line 121 of file ambient_occlusion.h.
|
inline |
Sets the lightness.
[in] | x | the lightness, as an integer. |
A value of 10 (default) corresponds to average lightness.
Definition at line 104 of file ambient_occlusion.h.
|
inline |
Sets the maximum radius around a pixel where ambient occlusion is computed.
[in] | x | the radius, relative to screen size, in 0.0 ... 1.0. |
Definition at line 179 of file ambient_occlusion.h.
|
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.
[in] | x | the number of directions. |
Definition at line 159 of file ambient_occlusion.h.
|
inline |
Sets the multiplicative factor applied to each step when traversing from a pixel.
[in] | x | the multiplicative step. |
Definition at line 198 of file ambient_occlusion.h.
|
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.