18 #ifndef PIC_GL_FILTERING_FILTER_BILATERAL_3DS_HPP 19 #define PIC_GL_FILTERING_FILTER_BILATERAL_3DS_HPP 21 #include "../../base.hpp" 22 #include "../../util/vec.hpp" 23 #include "../../util/std_util.hpp" 24 #include "../../gl/filtering/filter.hpp" 131 int halfKernelSize = kernelSize >> 1;
134 frame = halfKernelSizeTime;
137 Vec3i window =
Vec3i(halfKernelSize, halfKernelSize, halfKernelSizeTime);
142 printf(
"Window Space: %d Window Time: %d\n", halfKernelSize,
160 uniform sampler2DArray u_tex;
162 uniform isampler2D u_poisson;
163 uniform sampler2D u_rand;
164 uniform
int TOKEN_BANANA;
173 vec3 color = vec3(0.0, 0.0, 0.0);
174 ivec3 texSize = textureSize(u_tex, 0);
175 ivec3 coordsFrag = ivec3(gl_FragCoord.xy,
frame % texSize.z);
177 vec3 colRef = texelFetch(u_tex, coordsFrag, 0).xyz;
180 for(
int i = 0; i < TOKEN_BANANA; i++) {
182 float shifter = texelFetch(u_rand, coordsFrag.xy % 128, 0).x;
183 ivec4 coords = texelFetch(u_poisson, ivec2(i, shifter), 0).xyzw;
186 tmpCoords.xy = coords.xy + coordsFrag.xy;
187 tmpCoords.z = (
frame + coords.z) % texSize.z;
189 tmpCol = texelFetch(u_tex, tmpCoords, 0).xyz;
190 vec3 tmpCol2 = tmpCol - colRef;
191 float dstR = dot(tmpCol2.xyz, tmpCol2.xyz);
192 float tmp = exp(-dstR /
sigmar2 -
float(coords.w) /
sigmas2 -
float(
193 coords.z * coords.z) /
sigmat2);
194 color.xyz += tmpCol * tmp;
198 f_color = vec4(weight > 0.0 ? (color / weight) : vec3(1.0), 1.0);
219 flag = (this->sigma_s ==
sigma_s);
224 flag = flag || (this->sigma_r ==
sigma_r);
229 flag = flag || (this->sigma_t ==
sigma_t);
237 int halfKernelSize = kernelSize >> 1;
239 Vec3i window =
Vec3i(halfKernelSize, halfKernelSize, halfKernelSize);
269 if(imgIn[0] == NULL) {
273 int w = imgIn[0]->
width;
274 int h = imgIn[0]->height;
277 imgOut =
new ImageGL(1, w, h, imgIn[0]->channels,
IMG_GPU, imgIn[0]->getTarget());
289 glViewport(0, 0, (GLsizei)w, (GLsizei)h);
295 glActiveTexture(GL_TEXTURE2);
298 glActiveTexture(GL_TEXTURE1);
301 glActiveTexture(GL_TEXTURE0);
314 glActiveTexture(GL_TEXTURE2);
317 glActiveTexture(GL_TEXTURE1);
318 glBindTexture(GL_TEXTURE_2D, 0);
320 glActiveTexture(GL_TEXTURE0);
TechniqueGL technique
Definition: display.hpp:45
The Fbo class.
Definition: display.hpp:32
float sigma_r
Definition: filter_bilateral_3ds.hpp:34
static int getKernelSize(float sigma)
KernelSize computes the size of a kernel in pixel give its sigma.
Definition: precomputed_gaussian.hpp:121
Vec< 3, int > Vec3i
Vec3i.
Definition: vec.hpp:834
void update(float sigma_s, float sigma_r, float sigma_t)
update
void FragmentShader()
FragmentShader.
float sigma_s
Definition: filter_bilateral_3ds.hpp:34
bool create(int width, int height, bool bDepth)
create
Definition: display.hpp:207
void bindTexture()
bindTexture
int frame
Definition: filter_bilateral_3ds.hpp:36
void bindTexture()
bindTexture
Definition: image.hpp:981
int getFrame()
getFrame
Definition: filter_bilateral_3ds.hpp:98
GLuint generateTextureGL(GLenum target, GLenum format_type, bool mipmap)
generateTextureGL
float sigmas2
Definition: filter_bilateral_3ds.hpp:35
void bind()
bind
Definition: display.hpp:189
GLuint getTexture()
getTexture
Definition: display.hpp:80
#define MAKE_STRING(input_string)
FilterGLBilateral3DS(float sigma_s, float sigma_r, float sigma_t)
FilterGLBilateral3DS.
float sigmat2
Definition: filter_bilateral_3ds.hpp:35
ImageGL * Process(ImageGLVec imgIn, ImageGL *imgOut)
Process.
The ImageGL class.
Definition: image.hpp:42
GLuint getTexture() const
getTexture
Definition: display.hpp:369
void setUniform1f(const char *name_uniform, float value0)
SetUniform1f.
Definition: display.hpp:247
ImageGL * imageRand
Definition: filter_bilateral_3ds.hpp:40
void initShaders()
initShaders
Fbo * fbo
Definition: display.hpp:39
void updateGL(Vec< N, int > window, int nSamples)
updateGL
Definition: sampler_random_m.hpp:129
void bind()
bind
Definition: display.hpp:427
QuadGL * quad
Definition: display.hpp:42
The FilterGL class.
Definition: filter.hpp:35
MRSamplersGL< 3 > * ms
Definition: filter_bilateral_3ds.hpp:37
void nextFrame()
nextFrame
Definition: filter_bilateral_3ds.hpp:89
void unBindTexture()
unBindTexture
void Render()
Render draws a quad on screen.
Definition: display.hpp:140
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
int width
Definition: filter_radial_basis_function.hpp:80
bool initStandard(std::string version_number, std::string vertex_shader_source, std::string fragment_shader_source, std::string name)
initStandard
Definition: display.hpp:114
Definition: point_samplers.hpp:51
void unbind()
unbind
Definition: display.hpp:197
void setFrame(int frame)
setFrame
Definition: filter_bilateral_3ds.hpp:81
void unBindTexture()
unBindTexture
Definition: image.hpp:986
std::string vertex_source
Definition: display.hpp:57
Definition: bilateral_separation.hpp:25
The FilterGLBilateral3DS class.
Definition: filter_bilateral_3ds.hpp:31
int kernelSizeTime
Definition: filter_bilateral_3ds.hpp:36
float sigma_t
Definition: filter_bilateral_3ds.hpp:34
#define MAX(a, b)
Definition: math.hpp:73
void setUniform()
setUniform
void unbind()
unbind
Definition: display.hpp:442
std::vector< ImageGL * > ImageGLVec
ImageGLVec an std::vector of pic::ImageGL.
Definition: display.hpp:32
std::string fragment_source
Definition: display.hpp:57
int nSamples
Definition: display.hpp:53
std::vector< ImageGL * > ImageGLVec
ImageGLVec an std::vector of pic::ImageGL.
Definition: image_vec.hpp:32
void release()
release
Definition: display.hpp:85
float sigmar2
Definition: filter_bilateral_3ds.hpp:35
void setUniform1i(const char *name_uniform, int value0)
SetUniform.
Definition: display.hpp:236