Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SceneKit: how to reproduce iOS 9 lighting color effect (one directional, one ambient) on iOS 10 without disabling PBR?

As this thread on the Apple forums mentions, lights on iOS 10 are now weaker and change how scenes look.

The thread suggests setting SCNDisableLinearSpaceRendering to YES, but this did not work. Put another way, using SCNDisableLinearSpaceRendering will not make your scene look the same on iOS 10 as on iOS 9 -- at least not in our testing.

We also tried:

floorNode.geometry?.firstMaterial?.lightingModel = SCNMaterial.LightingModel.blinn

Screenshots below show the difference between the same scene. Notice how the floor turns from green to yellow even though the lighting is the same.

The scene contains one directional light and one ambient light.

Files for reproducing scene: https://www.dropbox.com/sh/cg5f7hyf1oonxfu/AAAJef7LhpSxuJyUSjqfGbmca?dl=0.

Even if it did work, setting SCNDisableLinearSpaceRendering to YES seems to disable PBR.

Our app lets users customize the color of a directional light. The goal is to reproduce the same customized, lighting from an iOS 9 scene in an iOS 10 scene while taking advantage of PBR.

1) How can we ensure iOS 10 scenes look identical to iOS 8/9 scenes?

2) How can you achieve #1 while benefiting from PBR?

iOS 8/9 (run on simulator):

enter image description here

iOS 10 (run on user device):

enter image description here

like image 829
Crashalot Avatar asked Nov 09 '22 09:11

Crashalot


1 Answers

You can render your scene on iOS 10 like it is rendered on iOS 9 by changing the lighting model of its materials from SCNLightingModelPhysicallyBased to SCNLightingModelBlinn.

Example: If you have only one 3D model in your scene:

for(SCNMaterial * mt in model.geometry.materials)
    mt.lightingModelName = SCNLightingModelBlinn;

However by doing this you won't be able to take advantage of PBR. If you want to keep using PBR, then you can play with the intensity and temperature properties of SCNLight to achieve different results.

like image 146
fabio914 Avatar answered Nov 14 '22 21:11

fabio914