swiftsceneview

How to Take a Snapshot of a Sceneview with the Sceneviews Autolighting


For anybody who has worked with snapshotting sceneview screens, you would know what I mean when I say the photo output appears much darker then the screen you are capturing. How can I capture photo output of the sceneview that shows the sceneviews brightness. Im not sure how to ask this question better but essentially this is how I am capturing the sceneview.

    @IBAction func ARSnapTapped(_ sender: Any) {
    if !draw {
        let newImg: UIImage = self.sceneView.snapshot()
        DispatchQueue.main.async {
            self.imageTaken.image = newImg
            self.imageTakenView.isHidden = false
        }
        self.image = newImg
    }
}

Solution

  • This is the solution for anybody looking to enhance the snapshot output lighting when taking snapshots of sceneview in swift.

    if let camera = sceneView.pointOfView?.camera {
            camera.wantsHDR = true
            camera.wantsExposureAdaptation = true
            camera.whitePoint = 1.0
            camera.exposureOffset = 1
            camera.minimumExposure = 1
            camera.maximumExposure = 1
        }
    

    Adjusting the values for exposureOffset and min/max will brighten/darken the output from the screenshot.