Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'texelFetch' : no matching overloaded function found in opengl es 3.0

I am using OpenGL es 3.0 and my GLSL version #version 300 es.

I am trying to calculate luminous histogram in GPU. i had identified that my device supports Vertex texture fetch and trying to read color information in vertex shader using texelFetch function.i am using texelFetch because i pass in every texture coordinate so as to read color information at every pixel.

Attaching the code

#version 300 es 
uniform sampler2D imageTexture;
in vec2 texturePosition;
const float SCREEN_WIDTH = 1024.0;
in vec4 position;
vec2 texturePos;
out vec3 colorFactor;
const vec3 W = vec3(0.299, 0.587, 0.114); 
void main() {
    texturePos = texturePosition / SCREEN_WIDTH;
    vec3 color = texelFetch(imageTexture, texturePos.xy,0).rgb;
    float luminance = dot(color.xyz,W);
    colorFactor = vec3(1.0, 1.0, 1.0);
    gl_Position = vec4(-1.0 + (luminance *  0.00784313725), 0.0, 0.0, 1.0);
    gl_PointSize = 1.0;
};

now getting the error 'texelFetch' : no matching overloaded function found.

Could somebody help with error and provide suggestion to calculate luminous histogram in GPU.

like image 952
vishnu dinakaran Avatar asked Nov 08 '22 14:11

vishnu dinakaran


1 Answers

texturePos needs to be an ivec2, with integer texture coordinates (i.e. the pixel position in the texture) rather than normalized [0.0 1.0] floating point coordinates.

The code below should work:

#version 300 es 
uniform sampler2D imageTexture;
in ivec2 texturePosition;
in vec4 position;
out vec3 colorFactor;
const vec3 W = vec3(0.299, 0.587, 0.114); 
void main() {
    vec3 color = texelFetch(imageTexture, texturePosition, 0).rgb;
    float luminance = dot(color, W);
    colorFactor = vec3(1.0, 1.0, 1.0);
    gl_Position = vec4(-1.0 + (luminance *  0.00784313725), 0.0, 0.0, 1.0);
    gl_PointSize = 1.0;
};

But you need to feed the 'texturePosition' input array with integers containing all the (x,y) pixel coordinates you want to include in your histogram as integers. (with VBOs).

As pointed out in the comments, you'll need to use glVertexAttribIPointer() to feed integer types.

like image 154
246tNt Avatar answered Nov 14 '22 23:11

246tNt