问题
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):
iOS 10 (run on user device):
回答1:
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.
回答2:
This is a confirmed bug in Scene Kit. We filed a report in Bug Reporter under bug number 28459280. The problem is Metal always sets locksAmbientWithDiffuse
to true
on iOS 10.
According to one of the Scene Kit engineers, a workaround is to manually set locksAmbientWithDiffuse
to true
for the nodes in question (in this example, the floor node) then adjust the lighting on iOS 8/9 until the desired appearance is achieved.
This should ensure iOS 10 scenes look the same as iOS 8/9 scenes.
来源:https://stackoverflow.com/questions/39522086/scenekit-how-to-reproduce-ios-9-lighting-color-effect-one-directional-one-amb