为什么启用透明混合与光照后,shader就不显示内容了?

引擎版本:3.8
shader启用透明混合前:
image
shader启用透明混合后:

经过测试发现,当使用cc-forward-light.chunk后,只要在代码内启用透明混合,shader就完全不显示了?
image
如果进入cc-forward-light.chunk中处理代码,当shader中引入下图中框起的任意一个变量,透明混合的shader就会不显示…

————————

大家有没有让shader同时支持“透明”和“光照”的方法?
“isA2C: true”可以,但各个平台不通用,而且效果不太好。

相关的shader代码:
// Effect Syntax Guide: https://docs.cocos.com/creator/manual/zh/shader/index.html
CCEffect %{
techniques:

  • name: opaque
    passes:
    • vert: unlit-vs:vert # builtin header
      frag: unlit-fs:frag
      properties: &props
      mainTexture: { value: white }
      mainColor: { value: [1, 1, 1, 1], editor: { type: color } }
    • &forward-add
      vert: unlit-vs:vert # builtin header
      frag: unlit-fs:frag
      phase: forward-add
      propertyIndex: 0
      embeddedMacros: { CC_FORWARD_ADD: true }
      depthStencilState:
      depthFunc: equal
      depthTest: true
      depthWrite: false
      blendState:
      targets:
      • blend: true
        blendSrc: one
        blendDst: one
        blendSrcAlpha: zero
        blendDstAlpha: one
    • &deferred-forward
      vert: unlit-vs:vert # builtin header
      frag: unlit-fs:frag
      pass: gbuffer
      phase: gbuffer
      embeddedMacros: { CC_PIPELINE_TYPE: 1 }
      propertyIndex: 0
      } CCProgram shared-ubos {
      uniform Constants {
      vec4 mainColor;
      };
      } CCProgram unlit-vs {
      precision highp float;
      precision lowp int;
      #include <legacy/input-standard>
      #include <builtin/uniforms/cc-global>
      #include <legacy/local-batch>
      #include <legacy/input-standard>
      #include <legacy/fog-vs>
      #include <legacy/shadow-map-vs>
      in vec4 a_color;
      #include
      out vec3 v_position;
      out vec3 v_normal;
      out vec3 v_tangent;
      out vec3 v_bitangent;
      out vec2 v_uv;
      out vec2 v_uv1;
      out vec4 v_color;
      vec4 vert () {
      StandardVertInput In;
      CCVertInput(In);
      mat4 matWorld, matWorldIT;
      CCGetWorldMatrixFull(matWorld, matWorldIT);
      vec4 pos = matWorld * In.position;
      v_position = pos.xyz;
      v_normal = normalize((matWorldIT * vec4(In.normal, 0.0)).xyz);
      v_tangent = normalize((matWorld * vec4(In.tangent.xyz, 0.0)).xyz);
      v_bitangent = cross(v_normal, v_tangent) * In.tangent.w; // note the cross order
      v_uv = a_texCoord;
      v_color = a_color;
      CC_TRANSFER_FOG(pos);
      CC_TRANSFER_SHADOW(pos);
      return cc_matProj * ((cc_matView * matWorld) * In.position);
      }
      } CCProgram unlit-fs {
      precision highp float;
      precision lowp int;
      #include <legacy/output>
      #include <legacy/fog-fs>
      #include <builtin/uniforms/cc-global>
      #include <common/common-define>
      #include <shading-standard-base.chunk>
      #include <cc-forward-light.chunk>
      in vec2 v_uv;
      in vec3 v_position;
      in vec3 v_normal;
      in vec4 v_color;
      uniform sampler2D mainTexture;
      #include
      vec4 frag () {
      vec4 color = mainColor;/vec4(cc_lightPos[0].xyz,1.0)/;
      vec4 col = color * texture(mainTexture, v_uv);
      CC_APPLY_FOG(col, v_position);
      return CCFragOutput(col);
      }
      }%

目前有一个视觉效果折中的方案,就是shader内直接丢弃透明度低于一定值的像素。
这样可以在不启用混合的前提下,满足抠像的同时也具备光照信息。
(缺点:由于缺少混合,透明度只有0和100%,视觉效果一般)