ios - 使用 alpha 颜色绘制 Metal 三角形时颜色不正确。例如 (0.9,0.6,0,0.4)

标签 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;
}

颜色不正确。 Metal 中的 color(0.9,0.6,0,0.4) 转换为一种奇怪的颜色: 左边是正确的,右边是用 Metal 画的 enter image description here

绘制没有 alpha 颜色的 Metal 三角形时,颜色是正确的, 右边是用 Metal 画的enter image description here

最佳答案

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

关于ios - 使用 alpha 颜色绘制 Metal 三角形时颜色不正确。例如 (0.9,0.6,0,0.4),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55888709/

相关文章:

ios - MVC : Is it a "good practice" to pass a model from a ViewController to another?

ios - 在 iOS 中使用大量动画绘制 View 的最佳 CPU 效率最高的方法是什么?

shader - 在 Swift Playgrounds 中将 SCNTechnique 与 Metal 着色器结合使用

swift2 - 为什么我没有得到这个 Metal 内核的结果

opengl - 如何将现有的 OpenGL 纹理转换为 Metal 纹理

ios - 为什么我会收到无法识别的选择器?

ios - 已处理的构建文件大小超过 100 MB 应用程序文件限制

ios - 使用 "Pause"和 "Resume"功能从服务器下载数据

swift - 复制 Metal 帧缓冲区纹理以供读取

metal - 显性释放 Metal 质感