这个警告恶心了我半天,运行没有错,只是设置材质的时候会警告。
用
if USE_TINT
endif
依照https://forum.cocos.org/t/topic/115154可以解决,老哥只是简单提了一句。用法我也搞了半天。
// 闪白效果shader
CCEffect %{
techniques:
- passes:
- vert: vs
frag: fs
blendState:
targets:- blend: true
rasterizerState:
cullMode: none
properties:
texture: { value: white }
flashIntensity: { value: 0.0 }
}%
- blend: true
- vert: vs
CCProgram vs %{
precision highp float;
include <cc-global>
include <cc-local>
in vec3 a_position;
in vec4 a_color;
out vec4 v_color;
if USE_TEXTURE
in vec2 a_uv0;
out vec2 v_uv0;
endif
if USE_TINT
in vec4 a_color0;
out vec4 v_dark;
in vec4 a_color1;
out vec4 v_light;
endif
void main () {
vec4 pos = vec4(a_position, 1);
#if CC_USE_MODEL
pos = cc_matViewProj * cc_matWorld * pos;
#else
pos = cc_matViewProj * pos;
#endif
#if USE_TEXTURE
v_uv0 = a_uv0;
#endif
v_color = a_color;
#if USE_TINT
v_dark = a_color0;
v_light = a_color1;
#endif
gl_Position = pos;
}
}%
CCProgram fs %{
precision highp float;
include <cc-global>
include <alpha-test>
in vec4 v_color;
if USE_TEXTURE
in vec2 v_uv0;
uniform sampler2D texture;
endif
if USE_TINT
in vec4 v_dark;
in vec4 v_light;
endif
uniform FLASH {
float flashIntensity;
};
void main () {
vec4 o = vec4(1, 1, 1, 1);
#if USE_TEXTURE
o *= texture(texture, v_uv0);
#endif
#if USE_TINT
vec4 tint = v_light * o.r + v_dark * (1.0 - o.r);
o.rgb = tint.rgb * o.a;
#endif
o *= v_color;
// 实现闪白效果
vec4 flashColor = vec4(1.0, 1.0, 1.0, o.a);
o = mix(o, flashColor, flashIntensity);
gl_FragColor = o;
}
}%
要类似这么搞才行。