Geogram  Version 1.9.1-rc
A programming library of geometric algorithms
unsharp_masking.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2000-2022 Inria
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * * Neither the name of the ALICE Project-Team nor the names of its
14  * contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  *
29  * Contact: Bruno Levy
30  *
31  * https://www.inria.fr/fr/bruno-levy
32  *
33  * Inria,
34  * Domaine de Voluceau,
35  * 78150 Le Chesnay - Rocquencourt
36  * FRANCE
37  *
38  */
39 
40 #ifndef H_OGF_RENDERER_GL_CONTEXT_UNSHARP_MASKING_GLSL_H
41 #define H_OGF_RENDERER_GL_CONTEXT_UNSHARP_MASKING_GLSL_H
42 
46 
52 namespace GEO {
53 
61  public:
66 
70  ~UnsharpMaskingImpl() override;
71 
75  double required_GLSL_version() const override;
76 
80  void pre_render(index_t w, index_t h) override;
81 
85  void post_render() override;
86 
90  void update() override;
91 
98  return intensity_;
99  }
100 
107  intensity_ = x;
108  }
109 
116  return contrast_;
117  }
118 
124  contrast_ = x;
125  }
126 
132  return blur_width_;
133  }
134 
140  blur_width_ = x;
141  }
142 
148  bool get_halos() const {
149  return halos_;
150  }
151 
156  void set_halos(bool x) {
157  halos_ = x;
158  }
159 
168  bool get_positive_shadows() const {
169  return positive_shadows_;
170  }
171 
180  void set_positive_shadows(bool x) {
181  positive_shadows_ = x;
182  }
183 
184  protected:
188  void initialize(index_t w, index_t h) override;
189 
193  void resize(index_t width, index_t height) override;
194 
203  void blur();
204 
211 
212  private:
213  index_t intensity_;
214  index_t contrast_;
215  index_t blur_width_;
216  bool halos_;
217  bool positive_shadows_;
218 
219  FrameBufferObject blur_1_;
220  FrameBufferObject blur_2_;
221 
222  GLuint unsharp_masking_program_;
223  GLuint blur_program_;
224  } ;
225 
230 
231 }
232 
233 #endif
An OpenGL frame buffer object.
Implementation of full screen effects.
A smart pointer with reference-counted copy semantics.
Definition: smart_pointer.h:76
Implementation of UnsharpMasking full screen effect.
double required_GLSL_version() const override
Gets the minimum required GLSL version needed to execute the shaders in this FullScreenEffectImpl.
void set_blur_width(index_t x)
Sets the size of the blurring kernel.
~UnsharpMaskingImpl() override
UnsharpMaskingImpl destructor.
void update() override
Callback called whenever parameters are changed in the GUI.
index_t get_intensity() const
Gets the intensity.
bool get_positive_shadows() const
Tests whether positive_shadows should be drawn.
index_t get_contrast() const
Gets the contrast.
bool get_halos() const
Tests whether halos should be drawn.
index_t get_blur_width() const
Gets the size of the blurring kernel.
void set_contrast(index_t x)
Sets the contrast. A value of 50 (default) corresponds to average contrast.
void display_final_texture()
Displays the final result.
void blur()
Applies a Gaussian blur to the depth buffer.
void set_positive_shadows(bool x)
Specifies whether positive_shadows should be used.
void set_halos(bool x)
Specifies whether halos should be used.
void resize(index_t width, index_t height) override
Callback called whenever the rendering context is resized.
UnsharpMaskingImpl()
UnsharpMaskingImpl constructor.
void initialize(index_t w, index_t h) override
Callback called the first time this FullScreenEffectImpl is used.
void set_intensity(index_t x)
Sets the intensity.
void pre_render(index_t w, index_t h) override
Callback called at the beginning of each frame.
void post_render() override
Callback called at the end of each frame.
Helper class for manipulating OpenGL frame buffer objects.
Low-level base class for full screen effects.
#define GEOGRAM_GFX_API
Linkage declaration for geogram symbols.
Definition: defs.h:55
Common include file, providing basic definitions. Should be included before anything else by all head...
Global Vorpaline namespace.
Definition: basic.h:55
SmartPointer< UnsharpMaskingImpl > UnsharpMaskingImpl_var
An automatic reference-counted pointer to an UnsharpMaskingImpl.
geo_index_t index_t
The type for storing and manipulating indices.
Definition: numeric.h:329