如何解决RealityKit / ARKit中的“ MakeRenderPipelineState失败”错误?

问题描述 投票:0回答:1

我正在尝试学习世界锚,但无法在水龙头上放置物体。我在启动时遇到以下错误:

2020-02-12 11:06:20.027274+0000 Project[8336:1778069] Metal GPU Frame Capture Enabled
2020-02-12 11:06:20.027756+0000 Project[8336:1778069] Metal API Validation Enabled
2020-02-12 11:06:20.428611+0000 Project[8336:1778069] Compiler failed to build request
2020-02-12 11:06:20.428933+0000 Project[8336:1778069] [Graphics] makeRenderPipelineState failed [output of type ushort is not compatible with a MTLPixelFormatR16Float color attachement.].
2020-02-12 11:06:20.428995+0000 Project[8336:1778069] [Graphics] makeRenderPipelineState failed.

该应用程序加载正常,但我认为makeRenderPipelineState故障可能会阻止我前进。我尝试过在线查找错误,但是似乎没有一个与我的代码有关。关于如何解决此问题的任何想法,或者可能是什么问题?干杯。

代码:

//
//  ViewController.swift
//  Project
//
//  Created by Callum King on 11/02/2020.
//  Copyright © 2020 Callum King. All rights reserved.
//

import UIKit
import RealityKit
import ARKit

class ViewController: UIViewController {

    @IBOutlet var arView: ARView!

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)



        setupARView()

        arView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(handleTap(recognizer:))))


    }

    //MARK: Setup Methods

    func setupARView(){
        arView.automaticallyConfigureSession = false
        let configuration = ARWorldTrackingConfiguration()
        configuration.planeDetection = [.horizontal, .vertical]
        configuration.environmentTexturing = .automatic
        arView.session.run(configuration)

    }

    //MARK: Object Placement

    @objc
    func handleTap(recognizer: UITapGestureRecognizer) {
        let location = recognizer.location(in: arView)

        let results = arView.raycast(from: location, allowing: .estimatedPlane, alignment: .any)

        if let firstResult = results.first {
            let anchor = ARAnchor(name: "toy_robot_vintage", transform: firstResult.worldTransform)
            arView.session.add(anchor: anchor)
        } else {
            print("ERROR: SURFACE NOT FOUND")
        }
    }

    func placeObject(named entityName: String, for anchor: ARAnchor) {
        let entity = try! ModelEntity.loadModel(named: entityName)

        entity.generateCollisionShapes(recursive: true)
        arView.installGestures([.rotation, .translation], for: entity)

        let anchorEntity = AnchorEntity(anchor: anchor)
        anchorEntity.addChild(entity)
        arView.scene.addAnchor(anchorEntity)
    }
}

extension ViewController: ARSessionDelegate {
    func session(_ session: ARSession, didAdd anchors: [ARAnchor]) {
        for anchor in anchors {
            if let anchorName = anchor.name, anchorName == "toy_robot_vintage" {
                placeObject(named: anchorName, for: anchor)
            }
        }
    }
}
swift anchor augmented-reality arkit realitykit
1个回答
0
投票

您是否在方案中启用了“ AR重放数据”?当尝试从Reality Composer重放内容并且仅实例化ARView时,出现了同样的错误。

© www.soinside.com 2019 - 2024. All rights reserved.