【问题标题】:How do I fix the 'MakeRenderPipelineState failed' error in RealityKit/ARKit?如何修复 RealityKit/ARKit 中的“MakeRenderPipelineState failed”错误?
【发布时间】:2020-02-12 11:26:17
【问题描述】:

我正在尝试学习世界锚点,但无法将对象放在水龙头上。我在启动时收到以下错误:

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】:

    您是否在方案中启用了“AR Replay Data”?尝试从 Reality Composer 重播内容并仅实例化 ARView 时,我遇到了同样的错误。

    【讨论】:

    • 探索评论作为询问有价值信息的一种方式。这样一来,其他人就可以参与进来并与之联系,但我们会帮助问题尽可能简洁。
    猜你喜欢
    • 1970-01-01
    • 2023-04-11
    • 2022-11-29
    • 2011-09-05
    • 2017-01-12
    • 2019-09-04
    • 2021-09-13
    • 1970-01-01
    相关资源
    最近更新 更多