用Alpha颜色绘制金属三角形时,颜色不正确。例如(0.9,0.6,0,0.4)

时间:2019-04-28 09:08:24

标签: ios metal

vertex Vertex
line_vertex_main(device Vertex *vertices [[buffer(0)]],
                 constant Uniforms &uniforms [[buffer(1)]],
                 uint vid [[vertex_id]])
{
  float4x4 matrix = uniforms.matrix;
  Vertex in = vertices[vid];
  Vertex out;
  out.position = matrix * float4(in.position);
  out.color = in.color;
  return out;
}

fragment float4
line_fragment_main(Vertex inVertex [[stage_in]])
{
  return inVertex.color;
}

颜色不正确。金属中的color(0.9,0.6,0,0.4)会变成奇怪的颜色: 左边是正确的,右边是金属画 enter image description here

当绘制没有alpha颜色的金属三角形时,颜色是正确的, 右侧为金属制图enter image description here

1 个答案:

答案 0 :(得分:0)

未配置您的混合模式。您可以在MTLRenderPipelineDescriptor上配置混合。