首页 > 解决方案 > SCNParticle系统崩溃

问题描述

我将库存烟雾 SCNParticleSystem 添加到 ARSCNView 中场景中的节点。这按预期工作。

我用来ARSCNView.snapshot()在绘制方法之前捕获图像和处理MTKView draw()

然后,我使用粒子系统调用removeAllParticleSystems()节点上的主线程,并使用removeFromParent().

然后我将其他节点添加到场景中,最终,应用程序因错误而崩溃validateFunctionArguments:3469: failed assertion 'Vertex Function(uberparticle_vert): missing buffer binding at index 19 for vertexBuffer.1[0].'

All Exceptions断点通常在调用ARSCNView.snapshot()时停止。

为什么这会崩溃?

错误是什么意思?

我应该如何在 ARSCNView 的场景中添加和删除粒子系统?

更新:我将我从这里使用的 MTKView 子类连接到带有粒子系统的工作 ARKit演示,并且发生了相同的顶点函数崩溃。

这是否意味着问题出在直通顶点着色器功能上?

为什么粒子系统的处理方式不同?

下面是着色器函数。谢谢。

#include <metal_stdlib>
using namespace metal;

// Vertex input/output structure for passing results from vertex shader to fragment shader
struct VertexIO
{
    float4 position [[position]];
    float2 textureCoord [[user(texturecoord)]];
};

// Vertex shader for a textured quad
vertex VertexIO vertexPassThrough(device packed_float4 *pPosition  [[ buffer(0) ]],
                                  device packed_float2 *pTexCoords [[ buffer(1) ]],
                                  uint                  vid        [[ vertex_id ]])
{
    VertexIO outVertex;

    outVertex.position = pPosition[vid];
    outVertex.textureCoord = pTexCoords[vid];

    return outVertex;
}

// Fragment shader for a textured quad
fragment half4 fragmentPassThrough(VertexIO        inputFragment [[ stage_in ]],
                                   texture2d<half> inputTexture  [[ texture(0) ]],
                                   sampler         samplr        [[ sampler(0) ]])
{
    return inputTexture.sample(samplr, inputFragment.textureCoord);
}

标签: iosscenekitarkitmetal

解决方案


推荐阅读