WebGL中,一般纹理的取值范围都是[0, 1],但在creator中,测试显示是[0, 0.1]:
顶点着色器
uniform mat4 viewProj;
attribute vec3 a_position;
attribute vec2 a_uv0;
varying vec2 v_uv0;
void main() {
vec4 pos = viewProj * vec4(a_position, 1.);
gl_Position = pos;
v_uv0 = a_uv0;
}
片元着色器
#ifdef GL_ES
precision mediump float;
#endif
uniform sampler2D texture;
varying vec2 v_uv0;
void main() {
if (v_uv0.x > 0.1)
gl_FragColor = vec4(1, 0, 0, 1.0);
else
gl_FragColor = vec4(0, 1, 0, 1.0);
}
最终看到的是绿色的方块,不知道是不是bug。