0

I noticed my AR application running very slow. I tried turning off certain rendering options that might influence the speed of the application. This is the script that runs my application:

import UIKit
import RealityKit

class ViewController: UIViewController {
    
    @IBOutlet var arView: ARView!
   // var renderOptions: ARView.RenderOptions {
        struct RenderOptions {
    
    
         let disableCameraGrain: ARView.RenderOptions
            let disableMotionBlur: ARView.RenderOptions
            let disableHDR: ARView.RenderOptions
            let disableGroundingShadows: ARView.RenderOptions
            let disableDepthOfField: ARView.RenderOptions
            let disablePersonOcclusion: ARView.RenderOptions
            let disableAREnvironmentLighting: ARView.RenderOptions
            
        
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        
       

    
        // Load the "Box" scene from the "Experience" Reality File
        let boxAnchor = try! Experience.loadBox()
        
        // Add the box anchor to the scene
        arView.scene.anchors.append(boxAnchor)

    let pointLight = PointLight() // pointLight is an entity
        pointLight.light.intensity = 20000 // pointLight.light is a component
        pointLight.light.color = .white
        pointLight.light.attenuationRadius = 5
        pointLight.position = [0, 2, 2]

        boxAnchor.addChild(pointLight)

    }
}

I am a noob in swift so I don't really know what to do at this point. The application runs like this but there is no visual change nor any performance boost. The application itself uses very low poly 3D objects.

I also tried this code:


import UIKit
import RealityKit

class ViewController: UIViewController {
    
    @IBOutlet var arView: ARView!
    var renderOptions: ARView.RenderOptions {
        //struct RenderOptions {
    
    
        arView.renderOptions.insert(.disableMotionBlur)
        arView.renderOptions.insert(.disableCameraGrain)
        arView.renderOptions.insert(.disableHDR)
        arView.renderOptions.insert(.disableGroundingShadows)
        arView.renderOptions.insert(.disableDepthOfField)
        arView.renderOptions.insert(.disablePersonOcclusion)
        arView.renderOptions.insert(.disableAREnvironmentLighting)
        
        return arView.renderOptions
        
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        
       

    
        // Load the "Box" scene from the "Experience" Reality File
        let boxAnchor = try! Experience.loadBox()
        
        // Add the box anchor to the scene
        arView.scene.anchors.append(boxAnchor)

    let pointLight = PointLight() // pointLight is an entity
        pointLight.light.intensity = 20000 // pointLight.light is a component
        pointLight.light.color = .white
        pointLight.light.attenuationRadius = 5
        pointLight.position = [0, 2, 2]

        boxAnchor.addChild(pointLight)

    }
}
bigchungus23
  • 33
  • 1
  • 5

1 Answers1

0

this code helped me resolve the issue.


import UIKit
import RealityKit

class ViewController: UIViewController {
    
    @IBOutlet var arView: ARView!

    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Disable certain rendering options
        arView.renderOptions = [.disableCameraGrain, .disableMotionBlur, .disableHDR, .disableGroundingShadows, .disableDepthOfField, .disablePersonOcclusion, .disableAREnvironmentLighting]
        
        // Load the "Box" scene from the "Experience" Reality File
        let boxAnchor = try! Experience.loadBox()
        
        // Add the box anchor to the scene
        arView.scene.anchors.append(boxAnchor)

        let pointLight = PointLight() // pointLight is an entity
        pointLight.light.intensity = 20000 // pointLight.light is a component
        pointLight.light.color = .white
        pointLight.light.attenuationRadius = 5
        pointLight.position = [0, 2, 2]

        boxAnchor.addChild(pointLight)
    }
}
bigchungus23
  • 33
  • 1
  • 5