菜鸟教程小白 发表于 2022-12-11 22:43:40

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


                                            <p><pre><code>vertex Vertex
line_vertex_main(device Vertex *vertices [],
               constant Uniforms &amp;uniforms [],
               uint vid [])
{
float4x4 matrix = uniforms.matrix;
Vertex in = vertices;
Vertex out;
out.position = matrix * float4(in.position);
out.color = in.color;
return out;
}

fragment float4
line_fragment_main(Vertex inVertex [])
{
return inVertex.color;
}
</code></pre>

<p>颜色不正确。 <code>color(0.9,0.6,0,0.4)</code> 在 metal 中转换为一种奇怪的颜色:
<strong>左边是正确的,右边是用 Metal 画的</strong>
<a href="/image/43tyN.jpg" rel="noreferrer noopener nofollow"><img src="/image/43tyN.jpg" alt="enter image description here"/></a> </p>

<p>绘制没有 alpha 颜色的 Metal 三角形时颜色正确,
<strong>右边是用 Metal 画</strong>。
<a href="/image/nj9eh.jpg" rel="noreferrer noopener nofollow"><img src="/image/nj9eh.jpg" alt="enter image description here"/></a> </p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>您的混合模式未配置。您可以在 <a href="https://developer.apple.com/documentation/metal/mtlrenderpipelinedescriptor" rel="noreferrer noopener nofollow">MTLRenderPipelineDescriptor</a> 上配置混合.</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 使用 Alpha 颜色绘制 Metal 三角形时颜色不正确。如 (0.9,0.6,0,0.4),我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/55888709/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/55888709/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 使用 Alpha 颜色绘制 Metal 三角形时颜色不正确。如 (0.9,0.6,0,0.4)