繁体   English   中英

GLSL'texture2D':在iPhone上找不到匹配的重载函数OpenGL ES2

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

我正在尝试使用GLSL的着色器,但是当我尝试从纹理中获取数据以尝试简单的对比度增强算法时,我得到了一个有趣的错误。

'texture2D' : no matching overloaded function found 

它发生在这个代码中,其中“final”是用于保存正在处理的颜色的vec4变量。 这里的想法是将像素的颜色从周围的颜色中推出(实验想法)。 我将在代码中标记出错误的行。

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;

为什么不工作? 谢谢。

假设tex最初在着色器源的顶部被声明为一个uniform sampler2D ,它将被片段的第一行重新声明为局部变量,它隐藏了原始定义。 更改任一变量以保持其名称不同应该可以解决您的编译问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM