我无法编译以下片段着色器:
uniform vec3 color;
uniform sampler2D tDiffuse;
varying vec2 vUv;
void main() {
vec4 texel = texture2D( tDiffuse, vUv );
vec3 luma = vec3( 0.299, 0.587, 0.114 );
float v = dot( texel.xyz, luma );
if (texel.x > 5)
gl_FragColor = vec4( v * color, texel.w );
else
gl_FragColor = texel;
}如果我将(texel.x > 5)更改为(1 > 5),则效果很好。但不知何故,texel.x会导致编译错误。有人看到这个代码有一个明显的问题吗?
发布于 2014-08-29 15:35:39
texel.x是一个浮点,5是一个int,不能直接比较两者。
尝试编写5.0:
if (texel.x > 5.0)https://stackoverflow.com/questions/25571449
复制相似问题