我有如下effect代码,在场景编辑器和模拟器预览中都能显示左黑右白的渐变,但是在浏览器预览中却显示纯黑。不知道为什么,请大佬帮忙看看这是为什么?我尝试了很多中方式(因为不熟,所以寻求AI协助了好长时间也没有解决)。代码如下:
CCEffect %{
techniques:
-
name: test
passes:
-
vert: vs:vert
frag: fs:frag
blendState:
targets:
- blend: false
rasterizerState:
cullMode: none
properties:
frequency: { value: 3.5, target: _GaborParams1.x }
theta: { value: 0.39, target: _GaborParams1.y }
phase: { value: 0.0, target: _GaborParams1.z }
sigma: { value: 0.5, target: _GaborParams1.w }
amplitude: { value: 1.0, target: _GaborParams2.x }
-
}%
CCProgram vs %{
precision highp float;
#include <builtin/uniforms/cc-global>
in vec3 a_position;
in vec2 a_texCoord;
in vec4 a_color;
out vec4 color;
out vec2 uv0;
vec4 vert () {
vec4 pos = vec4(a_position, 1.0);
pos = cc_matViewProj * pos;
uv0 = a_texCoord;
color = a_color;
return pos;
}
}%
CCProgram fs %{
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
#define PI 3.141592653589793
// 与 VS 对应,接收 uv0
in vec2 uv0;
in vec4 color;
layout(std140) uniform Constant {
vec4 _GaborParams1;
vec4 _GaborParams2;
};
vec4 frag() {
return vec4(vec3(uv0.x),1.0);
}
}%