CCEffect %{
techniques:
- passes:
- vert: vs
frag: fs
depthStencilState:
depthTest: false
depthWrite: false
blendState:
targets:- blend: true
blendSrc: src_alpha
blendDst: one_minus_src_alpha
rasterizerState:
cullMode: none
properties:
intensity: { value: 0.5, editor: { type: slider, range: [0, 1] } }
color: { value: [1.0, 1.0, 1.0, 1.0], editor: { type: color } }
}%
- blend: true
CCProgram vs %{
precision highp float;
#include
#include
in vec3 a_position;
in vec2 a_texCoord;
out vec2 v_texCoord;
void main () {
v_texCoord = a_texCoord;
gl_Position = cc_matViewProj * cc_matWorld * vec4(a_position, 1.0);
}
}%
CCProgram fs %{
precision highp float;
#include <legacy/output>
in vec2 v_texCoord;
#pragma builtin(local)
layout(set = 2, binding = 10) uniform sampler2D cc_spriteTexture;
uniform EffectUniform {
vec4 color;
float intensity;
};
layout(___location = 0) out vec4 o_fragColor;
void main () {
vec4 texColor = texture(cc_spriteTexture, v_texCoord);
// 只混合RGB颜色,保持原始alpha不变
vec3 finalColor = mix(texColor.rgb, color.rgb, intensity);
o_fragColor = vec4(finalColor, texColor.a);
}
}%
在Editor中,能显示正常;放到游戏中,就完全不显示,全透明了。有啥可能的原因