我已经在Scenekit中设置了逼真的灯光,但是当相机远离灯光打开的对象时,灯光会逐渐消失,最终完全消失。
// LIGHTING
let floorPlane = SCNFloor()
let groundPlane = SCNNode()
let groundMaterial = SCNMaterial()
groundMaterial.lightingModel = .constant
groundMaterial.writesToDepthBuffer = true
groundMaterial.colorBufferWriteMask = []
groundMaterial.isDoubleSided = true
floorPlane.materials = [groundMaterial]
groundPlane.geometry = floorPlane
//
charNode.addChildNode(groundPlane)
// Create a ambient light
ambientLight.light = SCNLight()
ambientLight.light?.shadowMode = .deferred
ambientLight.light?.color = UIColor.white
ambientLight.light?.type = SCNLight.LightType.ambient
ambientLight.position = SCNVector3(x: 0,y: 5,z: 0)
// Create a directional light node with shadow
directLight.light = SCNLight()
directLight.light?.type = SCNLight.LightType.directional
directLight.light?.color = UIColor.white
directLight.light?.castsShadow = true
directLight.light?.automaticallyAdjustsShadowProjection = true
directLight.light?.shadowSampleCount = 64
directLight.light?.shadowRadius = 16
directLight.light?.shadowMode = .deferred
directLight.light?.shadowMapSize = CGSize(width: 2048, height: 2048)
directLight.light?.shadowColor = UIColor.black.withAlphaComponent(0.75)
directLight.position = SCNVector3(x: 0,y: 5,z: 0)
directLight.eulerAngles = SCNVector3(-Float.pi / 2, 0, 0)
// Add the lights to the container
charNode.addChildNode(ambientLight)
charNode.addChildNode(directLight)
1条答案
按热度按时间pokxtpni1#
您可能需要增加
SCNLight.maximumShadowDistance
值: