开发者

GLSL 'texture2D' : no matching overloaded function found OpenGL ES2 on iPhone

I'm experimenting with shaders with GLSL but I get a funny error when I try to take data from a texture to try a simple contrast enhancement algorithm.

'texture2D' : no matching overloaded function found 

It happens with this code where "final" is the vec4 variable to hold the colour that is being worked on. The idea here is to push the pixel's colour further from the surrounding ones (An experimental idea). I'll mark the line in the code which has the error.

highp vec4 tex = texture2D(tex,vec2(texcoord.x+1.0,texcoord.y));
highp float total = tex.r + tex.g + tex.b;
tex = texture2D(tex,vec2(texcoord.x-1.0,texcoord.y)); <----This one as well as the next similar lines
total += tex.r + tex.g + tex.b;
tex = texture2D(tex,vec2(texcoord.x,texcoord.y+1.0));
total += tex.r + tex.g + tex.b;
tex = texture2D(tex,vec2(texcoord.x,texcoord.y-1.0));
total += tex.r + tex.g + tex.b;
highp float di = 12.0;
highp vec4 close_av = total/di;
final = (final - close_av)*1开发者_开发知识库.3+close_av;

Why wont it work? Thank you.


Assuming that tex was originally declared as a uniform sampler2D at the top of your shader source, it is being redeclared as a local variable by the first line of your snippet, which hides the original definition. Changing either variable to keep their names distinct should fix your compilation issues.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜