【发布时间】:2019-04-28 09:08:24
【问题描述】:
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;
}
【问题讨论】:
-
你是如何确定左边的图是“正确的”而右边的是“不正确的”?因为你有一个非 1.0 的 alpha,我假设你正在混合。 “源过度”混合将使用 (source.r * source.a + dest.r * (1 - source.a)) 表示红色。对于在不透明的白色背景上混合的颜色,这将是 (0.9 * 0.4 + 1.0 * (1 - 0.4)) -> (0.9 * 0.4 + 1.0 * 0.6) -> (0.36 + 0.6) -> 0.96。对其他颜色分量执行相同操作会得到 (0.96, 0.84, 0.6, 1.0)。将其输入任何 RGB 颜色查看器,它与右侧的颜色非常接近,具体取决于配置文件。
-
您的颜色没有预乘。我相信您需要先对它们进行预乘。