编译器错误在几何体上使用自定义着色器

时间:2016-08-02 10:27:27

标签: ios scenekit

我想在自定义着色器中进行一些自定义工作,但在运行时会出现内部错误。编译似乎没问题,但运行将收到错误消息:

错误构建着色器:错误域= AGXMetalG4P代码= 1"编译器遇到内部错误" UserInfo = {NSLocalizedDescription =编译器遇到内部错误} [SCNKit ERROR]显示链接线程似乎卡住了

SCNProgram *program = [[SCNProgram alloc] init];

program.fragmentFunctionName = @"myVertex";
program.vertexFunctionName = @"myFragment";

mySceneNode.geometry.program = program

和着色器:

#include <metal_stdlib>
using namespace metal;
#include <SceneKit/scn_metal>

struct MyNodeBuffer {
float4x4 modelTransform;
float4x4 modelViewTransform;
float4x4 normalTransform;
float4x4 modelViewProjectionTransform;
};

typedef struct {
     float3 position [[ attribute(SCNVertexSemanticPosition) ]];
} MyVertexInput;

struct SimpleVertex
{
     float4 position [[position]];
};


vertex SimpleVertex myVertex(MyVertexInput in [[ stage_in ]],
                           constant SCNSceneBuffer& scn_frame [[buffer(0)]],
                         constant MyNodeBuffer& scn_node [[buffer(1)]])

{
    SimpleVertex vert;
   vert.position = scn_node.modelViewProjectionTransform *     float4(in.position, 1.0);

   vert.position = float4(in.position,0);

   return vert;
}

fragment half4 myFragment(SimpleVertex in [[stage_in]])
{
    half4 color;
    color = half4(0.0 ,1.0 ,0.0, 1.0);

    return color;
 }

0 个答案:

没有答案