启用了shader的transparent导致了深度顺序出现问题了
侧着看上面一个物体在下面红圈之上
换了个角度看深度就会出现问题
参考了 关于材质transparent 的层级渲染问题,一直得不到解决 depth_func开启LESS_EQUAL也没有解决
这是下面红圈的着色器,用opaque是没问题的,有大佬能看一下么
// Effect Syntax Guide: https://docs.cocos.com/creator/manual/zh/shader/index.html
CCEffect %{
techniques:
- name: opaque
passes:
- vert: legacy/main-functions/general-vs:vert # builtin header
frag: unlit-fs:frag
properties: &props
mainTexture: { value: white }
mainColor: { value: [1, 1, 1, 1], editor: { type: color } }
- name: transparent
passes:
- vert: general-vs:vert # builtin header
frag: unlit-fs:frag
blendState:
targets:
- blend: true
blendSrc: src_alpha
blendDst: one_minus_src_alpha
blendSrcAlpha: src_alpha
blendDstAlpha: one_minus_src_alpha
properties: *props
}%
CCProgram unlit-fs %{
precision highp float;
#include <legacy/output>
#include <legacy/fog-fs>
in vec2 v_uv;
in vec3 v_position;
in vec4 v_color;
uniform sampler2D mainTexture;
uniform Constant {
vec4 mainColor;
};
vec4 frag () {
vec4 a = vec4(1.0, 1.0, 1.0, 1.0);
vec4 col = mainColor * a;
CC_APPLY_FOG(col, v_position);
return CCFragOutput(col);
}
}%