PICCANTE  0.4
The hottest HDR imaging library!
filter_from_stroke_to_mask.hpp
Go to the documentation of this file.
1 /*
2 
3 PICCANTE
4 The hottest HDR imaging library!
5 http://vcg.isti.cnr.it/piccante
6 
7 Copyright (C) 2014
8 Visual Computing Laboratory - ISTI CNR
9 http://vcg.isti.cnr.it
10 First author: Francesco Banterle
11 
12 This Source Code Form is subject to the terms of the Mozilla Public
13 License, v. 2.0. If a copy of the MPL was not distributed with this
14 file, You can obtain one at http://mozilla.org/MPL/2.0/.
15 
16 */
17 
18 #ifndef PIC_GL_FILTERING_FILTER_FROM_STROKE_TO_MASK_HPP
19 #define PIC_GL_FILTERING_FILTER_FROM_STROKE_TO_MASK_HPP
20 
21 #include "../../base.hpp"
22 #include "../../filtering/filter_luminance.hpp"
23 #include "../../gl/filtering/filter.hpp"
24 
25 namespace pic {
26 
31 {
32 protected:
33 
37  void initShaders();
38 
39 public:
44 
49 
51 
56  void update(LUMINANCE_TYPE type);
57 
64  static ImageGL *execute(ImageGL *imgIn, ImageGL *imgOut)
65  {
67  imgOut = filter.Process(SingleGL(imgIn), imgOut);
68  return imgOut;
69  }
70 };
71 
73 {
74  this->type = LT_CIE_LUMINANCE;
75 
76  initShaders();
77 }
78 
80 {
81  this->type = type;
82 
83  initShaders();
84 }
85 
87 {
88  release();
89 }
90 
92 {
94  (
95  uniform sampler2D u_tex; \n
96  uniform vec3 weights; \n
97  out vec4 f_color; \n
98  \n
99  void main(void) {
100  \n
101  ivec2 coords = ivec2(gl_FragCoord.xy); \n
102  vec3 color = texelFetch(u_tex, coords, 0).xyz; \n
103  float L = dot(color, weights); \n
104  f_color = vec4(L, L, L, 1.0); \n
105  \n
106  }
107  );
108 
109  technique.initStandard("330", vertex_source, fragment_source, "FilterGLFromStrokeToMask");
110 
111  update(type);
112 }
113 
115 {
116  technique.bind();
117  technique.setUniform1i("u_tex", 0);
118  technique.unbind();
119 }
120 
121 } // end namespace pic
122 
123 #endif /* PIC_GL_FILTERING_FILTER_FROM_STROKE_TO_MASK_HPP */
124 
Definition: filter_luminance.hpp:28
TechniqueGL technique
Definition: display.hpp:45
LUMINANCE_TYPE
Definition: filter_luminance.hpp:28
void update(LUMINANCE_TYPE type)
update
Definition: filter_from_stroke_to_mask.hpp:114
static ImageGL * execute(ImageGL *imgIn, ImageGL *imgOut)
execute
Definition: filter_from_stroke_to_mask.hpp:64
void initShaders()
initShaders
Definition: filter_from_stroke_to_mask.hpp:91
void bind()
bind
Definition: display.hpp:189
#define MAKE_STRING(input_string)
PIC_INLINE ImageGLVec SingleGL(ImageGL *img)
SingleGL creates a single for filters input.
Definition: image_vec.hpp:39
The ImageGL class.
Definition: image.hpp:42
virtual ImageGL * Process(ImageGLVec imgIn, ImageGL *imgOut)
Process.
Definition: display.hpp:258
The FilterGL class.
Definition: filter.hpp:35
#define PIC_INLINE
Definition: base.hpp:33
bool initStandard(std::string version_number, std::string vertex_shader_source, std::string fragment_shader_source, std::string name)
initStandard
Definition: display.hpp:114
The FilterGLFromStrokeToMask class.
Definition: filter_from_stroke_to_mask.hpp:30
void unbind()
unbind
Definition: display.hpp:197
std::string vertex_source
Definition: display.hpp:57
Definition: bilateral_separation.hpp:25
~FilterGLFromStrokeToMask()
Definition: filter_from_stroke_to_mask.hpp:86
FilterGLFromStrokeToMask()
FilterGLFromStrokeToMask.
Definition: filter_from_stroke_to_mask.hpp:72
std::string fragment_source
Definition: display.hpp:57
void release()
release
Definition: display.hpp:85
void setUniform1i(const char *name_uniform, int value0)
SetUniform.
Definition: display.hpp:236