18 #ifndef PIC_GL_FILTERING_REINHARD_TMO_SINGLE_PASS_HPP 19 #define PIC_GL_FILTERING_REINHARD_TMO_SINGLE_PASS_HPP 21 #include "../../base.hpp" 23 #include "../../util/vec.hpp" 24 #include "../../util/std_util.hpp" 26 #include "../../gl/filtering/filter.hpp" 27 #include "../../util/file_lister.hpp" 28 #include "../../gl/point_samplers/sampler_random_m.hpp" 85 float epsilon = 0.05f;
110 uniform sampler2D u_tex;
111 uniform sampler2D u_tex_col;
112 uniform isampler2D u_poisson;
113 uniform sampler2D u_rand;
114 uniform
int nSamples;
116 uniform
float sigmas2;
117 uniform
float sigmar2;
118 uniform
int kernelSize;
119 uniform
float kernelSizef;
124 ivec2 coordsFrag = ivec2(gl_FragCoord.xy);
126 float colRef = texelFetch(u_tex, coordsFrag, 0).x;
131 float shifter = texture(u_rand, gl_FragCoord.xy).x;
135 for(
int i = 0; i < nSamples; i++) {
137 ivec3 coords = texelFetch(u_poisson, ivec2(i, shifter), 0).xyz;
140 float tmpCol = texelFetch(u_tex, coordsFrag.xy + coords.xy, 0).x;
143 float tmpCol2 = tmpCol - colRef;
144 float dstR = tmpCol2 * tmpCol2;
146 int coordsz = coords.x * coords.x + coords.y * coords.y;
147 float tmp = exp(-dstR / sigmar2 -
float(coordsz) / sigmas2);
149 color += tmpCol * tmp;
154 float bilateral = weight > 0.0 ? (color / weight) : colRef;
157 Lw = Lw < 1e-9 ? 1e-9 : Lw;
158 vec3 color_hdr = texelFetch(u_tex_col, coordsFrag, 0).xyz / Lw;
160 float Ld = (Lw * a) / (bilateral * a + 1.0);
162 f_color = vec4(color_hdr * Ld, 1.0);
178 flag = (this->sigma_s !=
sigma_s);
183 flag = flag || (this->sigma_r !=
sigma_r);
187 this->Lwa =
Lwa > 0.0f ?
Lwa : this->
Lwa;
191 int halfKernelSize = kernelSize >> 1;
201 Vec2i window =
Vec2i(halfKernelSize, halfKernelSize);
208 printf(
"Window: %d\n", halfKernelSize);
225 float sigmas2 = 2.0f * this->sigma_s * this->
sigma_s;
226 float sigmar2 = 2.0f * this->sigma_r * this->
sigma_r;
ImageGL * imageRand
Definition: filter_reinhard_single_pass.hpp:45
TechniqueGL technique
Definition: display.hpp:45
float alpha
Definition: filter_reinhard_single_pass.hpp:42
FilterGLReinhardSinglePass(float alpha, float phi)
FilterGLReinhardSinglePass.
static int getKernelSize(float sigma)
KernelSize computes the size of a kernel in pixel give its sigma.
Definition: precomputed_gaussian.hpp:121
T * delete_s(T *data)
delete_s
Definition: std_util.hpp:123
~FilterGLReinhardSinglePass()
void bind()
bind
Definition: display.hpp:189
float Lwa
Definition: filter_reinhard_single_pass.hpp:51
#define MAKE_STRING(input_string)
The ImageGL class.
Definition: image.hpp:42
Vec< 2, int > Vec2i
Vec2i.
Definition: vec.hpp:829
float sigma_s
Definition: filter_reinhard_single_pass.hpp:38
void setUniform1f(const char *name_uniform, float value0)
SetUniform1f.
Definition: display.hpp:247
void update(float sigma_s, float sigma_r, float Lwa)
update
void updateGL(Vec< N, int > window, int nSamples)
updateGL
Definition: sampler_random_m.hpp:129
The FilterGL class.
Definition: filter.hpp:35
void setRand(unsigned int seed)
setRand
Definition: filter_radial_basis_function.hpp:1392
GLuint generateTexture()
generateTexture
Definition: sampler_random_m.hpp:151
The FilterGL class.
Definition: display.hpp:35
The MRSamplersGL class.
Definition: sampler_random_m.hpp:45
#define PIC_INLINE
Definition: base.hpp:33
The ImageGL class.
Definition: display.hpp:42
The Vec class.
Definition: display.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
ImageGLVec param
Definition: display.hpp:49
MRSamplersGL< 2 > * ms
Definition: filter_reinhard_single_pass.hpp:39
float sigma_r
Definition: filter_reinhard_single_pass.hpp:38
Definition: point_samplers.hpp:51
void unbind()
unbind
Definition: display.hpp:197
std::string vertex_source
Definition: display.hpp:57
Definition: bilateral_separation.hpp:25
The FilterGLReinhardSinglePass class.
Definition: filter_reinhard_single_pass.hpp:35
void releaseAux()
releaseAux
Definition: filter_reinhard_single_pass.hpp:66
std::string fragment_source
Definition: display.hpp:57
int nSamples
Definition: display.hpp:53
ImageGL * getImage()
getImage
Definition: display.hpp:89
float sigmoid_constant
Definition: filter_reinhard_single_pass.hpp:38
void release()
release
Definition: display.hpp:85
void setUniform1i(const char *name_uniform, int value0)
SetUniform.
Definition: display.hpp:236
void loadFromMemory()
loadFromMemory