[RealityKit使我的iPhone ThermalStatus毫无理由地发疯

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

我有以下演示应用程序,在其中我通过RealityKit设置了ARWorldTrackingConfiguration。

我也使用平面检测。

[当检测到飞机时,我添加了使用简单的方形碰撞盒将矩形“发射”到飞机上的功能。

大约100平方之后,应用程序thermalStatus更改为serious,我的帧频降低到30fps。

[对于我的一生,我不明白为什么RealityKit世界中有100个简单形状,没有特殊纹理甚至碰撞事件都会导致这种情况。

有人有什么想法吗?

PS1:在iPhone XS上运行,根据硬件规格,它应该能够表现得更好。

PS2:在下面添加代码


import UIKit
import RealityKit
import ARKit

let material = SimpleMaterial(color: .systemPink, isMetallic: false)
var sphere: MeshResource = MeshResource.generatePlane(width: 0.1, depth: 0.1)
var box = ShapeResource.generateBox(width: 0.1, height: 0.03, depth: 0.1)
var ballEntity = ModelEntity(mesh: sphere, materials: [material])
let collider = CollisionComponent(
  shapes: [box],
  mode: .trigger
)

class ViewController: UIViewController {

  @IBOutlet var arView: ARView!

  @IBOutlet weak var button: UIButton!

  override func viewDidLoad() {
    super.viewDidLoad()

    let configuration = ARWorldTrackingConfiguration()
    configuration.planeDetection = [.vertical]
    configuration.worldAlignment = .camera

    // Add the box anchor to the scene
    configuration.frameSemantics.remove(.bodyDetection)
    configuration.frameSemantics.remove(.personSegmentation)
    configuration.frameSemantics.remove(.personSegmentationWithDepth)

    arView.renderOptions.insert(.disableCameraGrain)
    arView.renderOptions.insert(.disableGroundingShadows)
    arView.renderOptions.insert(.disableHDR)
    arView.renderOptions.insert(.disableMotionBlur)
    arView.renderOptions.insert(.disableFaceOcclusions)
    arView.renderOptions.insert(.disableDepthOfField)
    arView.renderOptions.insert(.disablePersonOcclusion)

    configuration.planeDetection = [.vertical, .horizontal]

    arView.debugOptions = [.showAnchorGeometry, .showStatistics]

    let gesture = UITapGestureRecognizer(target: self,
                                         action: #selector(self.tap(_:)))
    arView.addGestureRecognizer(gesture)

    arView.session.run(configuration, options: [ .resetSceneReconstruction ])
  }

  @objc func tap(_ sender: UITapGestureRecognizer) {
    let point: CGPoint = sender.location(in: arView)

    guard let query = arView.makeRaycastQuery(from: point,
                                          allowing: .existingPlaneGeometry,
                                          alignment: .vertical) else {
      return
    }

    let result = arView.session.raycast(query)
    guard let raycastResult = result.first else { return }


    let anchor = AnchorEntity(raycastResult: raycastResult)
    var ballEntity = ModelEntity(mesh: sphere, materials: [material])
    ballEntity.collision = collider
    anchor.addChild(ballEntity)


    arView.scene.anchors.append(anchor)
  }


  @IBAction func removePlaneDebugging(_ sender: Any) {
    if arView.debugOptions.contains(.showAnchorGeometry) {
      arView.debugOptions.remove(.showAnchorGeometry)
      button.setTitle("Display planes", for: .normal)
      return
    }

    button.setTitle("Remove planes", for: .normal)
    arView.debugOptions.insert(.showAnchorGeometry)
  }
}

谁能帮忙吗?

ios swift augmented-reality arkit realitykit
1个回答
0
投票

[当您使用ARKit或RealityKit时,iPhone的热状态并不完全取决于100个基元的实时渲染。关键是以60 fps运行的6自由度世界跟踪。平面检测是设备的另一个hard core功能。因此,“世界跟踪和平面检测”操作非常消耗CPU / GPU(以及图像/对象检测或人员遮挡)。它们还会很快耗尽您的电池电量。

CPU / GPU的另一个沉重负担是阴影和反射性金属着色器。实时60 fps软阴影是任何设备(甚至使用A12处理器)的附加任务,并且使用环境反射子的金属纹理是在神经引擎上计算的。

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