Metalの頂点シェーダ

metal-vertexshader.png

もっとも単純な頂点シェーダ

#include <metal_stdlib>
 
using namespace metal;
 
struct VertexInOut
{
    float4  position [[position]];
    float4  color;
};
 
vertex VertexInOut passThroughVertex(uint vid [[ vertex_id ]],
                                     constant packed_float4* position  [[ buffer(0) ]],
                                     constant packed_float4* color    [[ buffer(1) ]])
{
    VertexInOut outVertex;
 
    outVertex.position = position[vid];
    outVertex.color    = color[vid];
 
    return outVertex;
};

サポートサイト Wikidot.com