PICCANTE  0.4
The hottest HDR imaging library!
filter_gradient.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_GRADIENT_HPP
19 #define PIC_GL_FILTERING_FILTER_GRADIENT_HPP
20 
21 #include "../../gl/filtering/filter.hpp"
22 
23 namespace pic {
24 
29 {
30 protected:
34  void initShaders()
35  {
37  (
38  uniform sampler2D u_tex; \n
39  out vec4 f_color; \n
40 
41  void main(void) {
42  \n d
43  ivec2 coords = ivec2(gl_FragCoord.xy); \n
44  vec3 c0 = texelFetch(u_tex, coords + ivec2(1, 0), 0).xyz; \n
45  vec3 c1 = texelFetch(u_tex, coords - ivec2(1, 0), 0).xyz; \n
46  vec3 c2 = texelFetch(u_tex, coords + ivec2(0, 1), 0).xyz; \n
47  vec3 c3 = texelFetch(u_tex, coords - ivec2(0, 1), 0).xyz; \n
48  vec3 Gx = c1 - c0; \n
49  vec3 Gy = c2 - c3; \n
50  f_color = vec4(sqrt(Gx.xyz * Gx.xyz + Gy.xyz * Gy.xyz), 1.0);\n d d
51  }\n
52  );
53 
54  //
55  //
56  //
57 
58  technique.initStandard("330", vertex_source, fragment_source, "FilterGLGradient");
59 
60  technique.bind();
61  technique.setUniform1i("u_tex", 0);
62  technique.unbind();
63  }
64 
65 public:
66 
71  {
72  //protected values are assigned/computed
73  initShaders();
74  }
75 
77  {
78  release();
79  }
80 };
81 
82 } // end namespace pic
83 
84 #endif /* PIC_GL_FILTERING_FILTER_GRADIENT_HPP */
85 
TechniqueGL technique
Definition: display.hpp:45
void initShaders()
initShaders
Definition: filter_gradient.hpp:34
void bind()
bind
Definition: display.hpp:189
~FilterGLGradient()
Definition: filter_gradient.hpp:76
#define MAKE_STRING(input_string)
The FilterGLGradient class.
Definition: filter_gradient.hpp:28
The FilterGL class.
Definition: filter.hpp:35
bool initStandard(std::string version_number, std::string vertex_shader_source, std::string fragment_shader_source, std::string name)
initStandard
Definition: display.hpp:114
void unbind()
unbind
Definition: display.hpp:197
std::string vertex_source
Definition: display.hpp:57
FilterGLGradient()
FilterGLGradient.
Definition: filter_gradient.hpp:70
Definition: bilateral_separation.hpp:25
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