18 #ifndef PIC_UTIL_GL_REDUX_HPP 19 #define PIC_UTIL_GL_REDUX_HPP 73 GLuint
Process(GLuint texIn,
int width,
int height,
int channels, GLuint texOut);
84 GLuint
Redux(GLuint texIn,
int width,
int height,
int channels, std::vector<GLuint> &stack)
86 if(stack.empty() || (texIn == 0)) {
90 GLuint texFlt = texIn;
92 for(
unsigned int i = 0; i < stack.size(); i++) {
98 Process(texFlt, width, height, channels, stack[i]);
112 ReduxGL(
"color = (color00 + color10 + color01 + color11) / 4.0;",
false);
123 ReduxGL(
"color = color00 + color10 + color01 + color11;",
false);
134 ReduxGL(
"color = (color00 + color10 + color01 + color11) / 4.0;",
true);
145 ReduxGL(
"color = min(color00, color10);\n " 146 "color = min(color, color01);\n " 147 "color = min(color, color11);\n",
false);
158 ReduxGL(
"color = max(color00, color10);\n " 159 "color = max(color, color01);\n " 160 "color = max(color, color11);\n",
false);
171 ReduxGL(
"vec4 maxVal = vec4(1e-6); " 172 "if(color00.x>0.0f) color = color00; " 173 "if(color01.x>0.0f) color = min(color,color01); " 174 "if(color10.x>0.0f) color = min(color,color10); " 175 "if(color11.x>0.0f) color = min(color,color11);\n",
false);
186 ReduxGL(
"vec4 sum = color00 + color01 + color10 + color11; " 187 "color = sum.x < 0.5? vec4(0.0) : sum; " 188 "color = ((sum.x > 0.5) && (sum.x < 3.5))? vec4(10.0) : color; " 189 "color = ((sum.x > 3.5) && (sum.x < 4.5))? vec4(1.0) : color; " 190 "color = sum.x > 4.5 ? vec4(10.0) : color;\n",
false);
217 std::vector<GLuint> &stack,
int minSize = 2)
227 while(checkSize >= minSize) {
233 checkSize =
MIN(width, height);
248 quad =
new QuadGL(
false);
274 uniform sampler2D u_tex; \n
279 ivec2 texSize = textureSize(u_tex, 0);
280 ivec2 coords = ivec2(gl_FragCoord.xy) * 2;
282 vec4 color00 = texelFetch(u_tex, coords ,0);
284 vec4 color10 = texelFetch(u_tex, coords + ivec2(1, 0), 0);
286 vec4 color01 = texelFetch(u_tex, coords + ivec2(0, 1), 0);
288 vec4 color11 = texelFetch(u_tex, coords + ivec2(1, 1), 0);
292 ___REDUX_OPERATION___ \n
293 f_color = vec4(color.xyz, 1.0);
301 size_t processing_found =
fragment_source.find(
"___REDUX_OPERATION___");
312 std::string domain_transform =
"float eps = 1e-6; " 313 "color00 = log(color00 + eps); " 314 "color01 = log(color01 + eps); " 315 "color10 = log(color10 + eps) ; " 316 "color11 = log(color11 + eps);";
338 if(width < 1 || height < 1) {
347 fbo->
create(width, height, 1,
false, texOut);
351 glViewport(0, 0, (GLsizei)width, (GLsizei)height);
357 glActiveTexture(GL_TEXTURE0);
358 glBindTexture(GL_TEXTURE_2D, texIn);
370 glActiveTexture(GL_TEXTURE0);
371 glBindTexture(GL_TEXTURE_2D, 0);
static ReduxGL * createSum()
createSum
Definition: redux.hpp:120
int counter
Definition: redux.hpp:42
static ReduxGL * createLogMean()
createLogMean
Definition: redux.hpp:131
std::string fragment_source_domain_transform
Definition: redux.hpp:45
void unbind()
unbind
Definition: technique.hpp:197
static ReduxGL * createMean()
createMean
Definition: redux.hpp:109
The Fbo class.
Definition: fbo.hpp:32
#define MAKE_STRING(input_string)
bool initStandard(std::string version_number, std::string vertex_shader_source, std::string fragment_shader_source, std::string name)
initStandard
Definition: technique.hpp:114
The TechniqueGL class.
Definition: technique.hpp:31
static std::string getVertexProgramV3()
getVertexProgramV3 creates a simple vertex program.
Definition: quad.hpp:216
PIC_INLINE GLuint generateTexture2DGL(int width, int height, int channels, float *data=NULL, bool mipmap=false)
generateTexture2DGL
Definition: buffer_allocation.hpp:37
The QuadGL class.
Definition: quad.hpp:30
GLuint Redux(GLuint texIn, int width, int height, int channels, std::vector< GLuint > &stack)
Redux.
Definition: redux.hpp:84
TechniqueGL techinques[2]
Definition: redux.hpp:46
QuadGL * quad
Definition: redux.hpp:39
std::string reduxOperation
Definition: redux.hpp:48
static ReduxGL * createMax()
createMax
Definition: redux.hpp:155
bool bDomainTransform
Definition: redux.hpp:41
The ReduxGL class.
Definition: redux.hpp:32
ReduxGL(std::string reduxOperation, bool bDomainTransform)
ReduxGL.
static int divideByTwoWithEvenDividend(int x)
divideByTwoWithEvenDividend if x is even it computes x / 2 otherwise (x + 1) / 2. ...
Definition: redux.hpp:199
std::string geometry_source
Definition: redux.hpp:45
static ReduxGL * createMin()
createMin
Definition: redux.hpp:142
#define PIC_INLINE
Definition: base.hpp:33
GLuint Process(GLuint texIn, int width, int height, int channels, GLuint texOut)
Process.
bool create(int width, int height, bool bDepth)
create
#define MIN(a, b)
Definition: math.hpp:69
void Render()
Render draws a quad on screen.
Definition: quad.hpp:140
static ReduxGL * createMinPos()
createMinPos
Definition: redux.hpp:168
void initShaders()
initShaders
Definition: bilateral_separation.hpp:25
static ReduxGL * createCheck()
createCheck
Definition: redux.hpp:183
std::string vertex_source
Definition: redux.hpp:45
Fbo * fbo
Definition: redux.hpp:36
void setUniform1i(const char *name_uniform, int value0)
SetUniform.
Definition: technique.hpp:236
static void allocateReduxData(int width, int height, int channels, std::vector< GLuint > &stack, int minSize=2)
allocateReduxData allocates a pyramid for computing the Redux operator.
Definition: redux.hpp:216
std::string fragment_source
Definition: redux.hpp:45
void bind()
bind
Definition: technique.hpp:189