SceneKit:如何为相同的OBJ文件从Google Poly重新创建照明? [英] SceneKit: how to recreate lighting from Google Poly for same OBJ file?
问题描述
目标是为该OBJ文件重新创建照明:
屏幕截图2:
代码:
//创建环境光
让environmentLightNode = SCNNode()
ambientLightNode.light = SCNLight()
environmentalLightNode.light!.type = .ambient
EnvironmentalLightNode.light!.color = UIColor(white:0.50,alpha:1.0)
//将环境光添加到场景
scene.rootNode.addChildNode(ambientLightNode)
//克雷亚te定向光
让directionalLight = SCNNode()
directionalLight.light = SCNLight()
directionalLight.light!.type = .directional
directionalLight.light!.color = UIColor(白色:0.40,alpha:1.0)
directionalLight.eulerAngles = SCNVector3(x:Float.pi,y:0,z:0)
//添加定向光
场景.rootNode.addChildNode(directionLight)
OBJ文件通过默认情况下,模型I / O使用基于物理的照明。该模型具有卡通般的外观,并使用了许多带有镜面反射高光的环境照明。
您应该首先将所有材料转换为 lambert
照明模型。 p>
然后添加 环境
照亮您的场景。这个场景中有很多环境照明,物体的每个部分都被照亮。 颜色
百分之75%的白人愿意。
最后附加一个向照相机照亮定向
以突出显示面向用户的多边形。 颜色
50%的白色听起来是对的。
The goal is to recreate the lighting for this OBJ file: https://poly.google.com/view/cKryD9VnDEZ
Code to load OBJ file into SceneKit (can download file from above link):
let modelPath = "model.obj"
let url = NSURL(string: modelPath)
let scene = SCNScene(named: modelPath)!
sceneView.autoenablesDefaultLighting = true
sceneView.allowsCameraControl = true
sceneView.scene = scene
sceneView.backgroundColor = UIColor.white
Options tried so far:
1) The default ambient lighting is much harsher than the Google Poly lighting. Removing the ambient lighting rendered everything too flat.
2) Using four directional lights: one in front, one behind, one below, and one above the model. All lights are angled to point at the model. This was the best, but still left some shadows and harsher areas not seen on Google Polymer.
3) Added two more lights to option #2, this time adding lights to the left and right. This one was worse than option #2 since the extra lights combined with the four existing lights and whitewashed the model.
UPDATE AFTER FOLLOWING SUGGESTIONS:
The code now implements an ambient light and a directional light.
Adding the directional light to the camera node, versus the scene root node, made no difference for some reason.
The light code is below.
There are two problems:
1) In Screenshot 1, the right side of the chest is too bright and shows no edges. The far left face of the chest is too dark. The face with the best lighting is in the center. How can you get the lighting to be like this for all faces (or better match the Google Poly lighting)?
2) In Screenshot 2, the directional light appears to have no effect. How can you ensure the back of the model is as light as the front with the suggested architecture of one ambient light and one directional light?
SCREENSHOT 1:
SCREENSHOT 2:
CODE:
// Create ambient light
let ambientLightNode = SCNNode()
ambientLightNode.light = SCNLight()
ambientLightNode.light!.type = .ambient
ambientLightNode.light!.color = UIColor(white: 0.50, alpha: 1.0)
// Add ambient light to scene
scene.rootNode.addChildNode(ambientLightNode)
// Create directional light
let directionalLight = SCNNode()
directionalLight.light = SCNLight()
directionalLight.light!.type = .directional
directionalLight.light!.color = UIColor(white: 0.40, alpha: 1.0)
directionalLight.eulerAngles = SCNVector3(x: Float.pi, y: 0, z: 0)
// Add directional light
scene.rootNode.addChildNode(directionalLight)
OBJ files loaded through Model I/O use physically based lighting by default. This model has a cartoonish look and uses a lot of ambient lighting with a few specular highlights.
You should start by converting all your materials to the lambert
lighting model.
Then add an ambient
light to you scene. There's a lot of ambient lighting in this scene, every part of the object is lit. A color
of 75% white will do.
Finally attach a directional
light to the camera to highlight the polygons facing the user. A color
of 50% white sounds about right.
这篇关于SceneKit:如何为相同的OBJ文件从Google Poly重新创建照明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!