arkit-by-example icon indicating copy to clipboard operation
arkit-by-example copied to clipboard

Swift version

Open noais opened this issue 8 years ago • 6 comments

Hi @markdaws ,

I have done every parts on swift, if you want you can create branches for all parts to push the code to them.

noais avatar Jun 30 '17 16:06 noais

@markdaws Thanks for putting this together. Would love to see a Swift version.

timothyrchew avatar Jun 30 '17 19:06 timothyrchew

Hi @markdaws I did the swift versions of part1, part2, part3 and part4 branches. Can you create the new branch part1_swift based on the "Initial commit" to allow me to make a pull request? Then based on the part1_swift make a part2_swift etc... so that people would be able to follow the different commits ;)

My repo is here if you want to see https://github.com/OxyFlax/arkit-by-example

OxyFlax avatar Jul 05 '17 11:07 OxyFlax

Thanks for Swift example and also Mark for nice articles! Studying now~

enzyme69 avatar Jul 19 '17 12:07 enzyme69

@OxyFlax I tried recreating your setup (Swift) from scratch, actually more like copy pasting code by code trying to understand the setup. Since you make it so tidy, I get 70% of the setup. Even the setting is very neatly coded.

One thing: Somewhat I am not able to get the "estimate" to affect lighting.

Questions:

  1. Do we need some kind of existing lighting in the scene for estimate to work?
  2. If we are not using PBR, will this estimate works? Is it a matter of passing the value into light?
  3. I am pretty new with PBR, I think I manage to get it working, but not quite sure if the Spherical or the IBL has any effect on the AR Objects. Wonder if we can have object being lit with just PBR, just like in Blender, when using environment light. Currently I am just getting black.

It might, but then again back to first question: I do not seem to get any light to happen, without turning on Default Light.

With Swift version, I am not seeing any light in the scene, but somewhat your cube is reacting to estimate light.

enzyme69 avatar Jul 20 '17 08:07 enzyme69

Ok, too many almost whole day, but I think the reason I am getting black is that because this thing needs to be at the very bottom! 💯

Also, intensity and image path is crucial. No error give even if we provide wrong path.

// MARK: - ARSCNViewDelegate


func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval) {
    guard let estimate = self.sceneView.session.currentFrame?.lightEstimate else {
        return
    }
    
    // A value of 1000 is considered neutral, lighting environment intensity normalizes
    // 1.0 to neutral so we need to scale the ambientIntensity value
    let intensity = estimate.ambientIntensity / 1000.0
    self.sceneView.scene.lightingEnvironment.intensity = intensity
}

enzyme69 avatar Jul 20 '17 09:07 enzyme69

@markdaws I didn't realize someone else already put together a Swift version and I ended up doing it as well. Here's my version: https://github.com/canbal/arkit-by-example. If interested I'm happy to create a pull request for a swift branch.

Regardless, thanks for the tutorial, it's been very helpful!

canbal avatar Aug 07 '17 02:08 canbal