SceneKit re-visited part 2: lights, action, meshes
I am fairly happy with the 3D models in use & now for some more work to be done on the scene (SCN) file.
I want to be able to use the SCN file with ARKit at some point. Apple has some guidlines on creating virtual content for use in augmented reality.
Providing 3D Virtual Content with SceneKit | Apple Developer Documentation
Because ARKit automatically matches SceneKit space to the real world, placing a virtual object so that it appears to…
Do I create multiple variations of the scene (SCN) file? Actually, I am able to use scene file references to keep the project more easily maintainable. This is a very powerful feature in Scene Kit (Sprite Kit also supports references). You can split a scene into multiple files. This feature has been available with view controllers using storyboard files for a few years now.
You can see the scenes in the media library table and drag them to the scene graph window or the main scene kit editor view. You can also drag & drop SCN files from the file navigator.
I shall elaborate; I have a 3D food object & I want to use the model in the following scenarios:
- a demonstration scene with lights and some animation referencing the chesee burger
- the cheese burger with a plane with a shadow texture for use with AR Kit
Ultimately, I created 3 scene files:
burger.scn — the basic hamburger scene file
burger_arkit.scn — this file referecnes the burger.scn file with the additional 3D elements: a plane with a shadow texture map as a material.
burger_dressed.scn — this file references the burger.scn file & includes lighting and SceneKit actions.
A brief aside: the SceneKit editor in Xcode has a timeline feature that will you let you apply actions to a scene. I added an infinitely looping rotation action to continually spin the burger around. You can set up elaborate actions entirely in the Scene Kit editor without having to write any code.
One thing that I personally find irking is that you cannot just double tap on the action in the timeline view to edit an action’s value. You edit the the action’s setting in the “attributes” tab in the inspector (I would write this on a sticky note somewhere for future reference).
You use actions most often to change the structure and content of the object to which they are attached, but you can…
I also needed to edit the burger scene file and adjust some material settings as I started to light the scene in the burgrer dressed scene file. The defualt specular settings were such that the burger buns were reflecting light. I changed the specular values to black to indicate the buns do not really reflect light. Yes, I am going a bit fast & loose with the materials settings 😊 — it something I am continally learning about as I work with various 3d engines & frameworks.
Declaration Specular shading describes the amount and color of light reflected by the material directly toward the…
The burger is looking better but as you can see the patty does not look that realistic; ideally, I would be working with an expert in materials & lighting. The burger patty mesh could use a normal map to make it look more like the real thing.
If you want to see some great real-time 3D rendered food check out Final Fantasy XV.
The Food in 'Final Fantasy XV' Is Insanely Realistic
In 2006, video game developer Square Enix announced a game called Final Fantasy Versus XIII, intended to be a spinoff…
Now what about physically based rendering (PBR)? Considering the cheese burger model that is being used is not that realistic looking in Scene Kit — I think I will leave this for now.
Update Aug, 2017
The Watch app was not working with the Watch OS beta; I am happy to say it is working again as of the Watch OS 4 beta 5. There were additional adjustemts to the project to use the SCN file with actions to rotate the burger.
It is in this branch on GitHub: