effect 在浏览器预览中uv传递不到frag中去?

我有如下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);
}

}%

在线等,希望得到大家的帮助。

你这排版乱糟糟的让别人怎么看……

预览和浏览器执行不一致,那可能是你使用的纹理勾上了 Packable,例如内置的 sprite_splash 单色纹理就是勾上的。具体看这个文章的 4.3 小节

`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);
}

}%`

大哥,太厉害了。我是默认的sprite的图片,默认他是勾选packable的,换了后就可以了。