cocos creator 3.8.1使用自定义的材质后,图片不展示了,着色器代码如下:
// Effect Syntax Guide: https://docs.cocos.com/creator/manual/zh/shader/index.html
CCEffect %{
techniques:
- name: shadow
passes:- vert: shadow-vs:vert
frag: shadow-fs:frag
blendState:
target:- blend: true
resterizerState:
cullMode: node
properties: &props
mainTexture: { value: white }
alphaThreshold: { value: 0.5}
wide: { value: 0.5}
radius: { value: 1.}
light: { value: 1.}
}%
- blend: true
- vert: shadow-vs:vert
CCProgram shadow-vs %{
precision highp float;
#include <builtin/uniforms/cc-global>
#if USER_LOCAL
#include <builtin/uniforms/cc-local>
#endif
in vec3 a_position;
in vec4 a_color;
out vec4 v_color;
#if USE_TEXTURE
in vec2 a_uv0;
out vec2 v_uv0;
#endif
vec4 vert () {
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;
return pos;
}
}%
CCProgram shadow-fs %{
precision highp float;
#include <builtin/internal/alpha-test>
in vec4 v_color;
#if USE_TEXTURE
in vec2 v_uv0;
uniform sampler2D mainTexture;
#endif
uniform Constant {
float wide;
float radius;
float light;
};
vec4 frag () {
vec4 o = vec4(0, 0.45, 0.4, 1);
o.a *= light;
vec2 uv = v_uv0 - 0.5;
o.a -= 1.0 - smoothstep(1. - wide, 1., length(uv) * 1./radius);
o *= v_color;
ALPHA_TEST(o);
return o;
}
}%