Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

326
Views
Problema con Shadow Plane invisible en SceneKit / ARKit

Desde hace un tiempo busco respuestas a mi problema, pero no puedo encontrar nada que realmente ayude o explique lo que está sucediendo. También revisé una y otra vez todo lo que encontré en SO, pero no pude encontrar la respuesta.

El problema ocurre continuamente cuando se muestran objetos en AR World. iEx Coloco un objeto en un Plano en el suelo, que es mi Plano de Sombra invisible. Entonces todo depende del ángulo de visión desde el dispositivo. Para aclarar, agregué a las imágenes, que tiene un ángulo de visión ligeramente diferente. Echa un vistazo a lo que está pasando con las sombras:

ingrese la descripción de la imagen aquí

Me gustaría tener una buena sombra todo el tiempo y no artefactos como los que puedes ver.

Nota: Ya jugué con shadowSampleCount , Bias y todas las demás opciones, que deberían ayudar a obtener una sombra adecuada y de bajo costo de renderizado.

Aquí está el extracto del código relevante para Iluminación y Plano, Material, etc.

Para SCNLight :

 class func directionalLight() -> SCNLight { let light = SCNLight() light.type = .directional light.castsShadow = true light.color = UIColor.white light.shadowMode = .deferred light.shadowSampleCount = 8 light.shadowRadius = 1 // light.automaticallyAdjustsShadowProjection = false light.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.75) light.categoryBitMask = -1 return light }

y como lo agrego:

 func setupLights() { lightDirectionNode.light = Lighting.directionalLight() // lightDirectionNode.eulerAngles = SCNVector3(-66.degreesToRadians, 0, 0) lightDirectionNode.eulerAngles = SCNVector3(0, 90.degreesToRadians, 45.degreesToRadians) sceneView.scene.rootNode.addChildNode(lightDirectionNode) }

Para el SCNPlan :

 class func shadowPlane() -> SCNNode { let objectShape = SCNPlane(width: 200, height: 200) objectShape.heightSegmentCount = 2 objectShape.widthSegmentCount = 2 objectShape.cornerRadius = 100 objectShape.cornerSegmentCount = 16 let objectNode = SCNNode(geometry: objectShape) objectNode.geometry?.firstMaterial?.diffuse.contents = UIColor(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0) objectNode.geometry?.firstMaterial?.colorBufferWriteMask = SCNColorMask(rawValue: 0) objectNode.physicsBody = Physics.floorPhysicsBody(shape: objectShape) objectNode.name = "floor" objectNode.renderingOrder = -10 // renderingOrder // 0 return objectNode }

y como lo agrego:

 func setupShadowPlane() { let shadowPlane = NodeFactory.shadowPlane() // Set the Node's properties shadowPlane.position = SCNVector3(x: (focusSquare.lastPosition?.x)!, y: (focusSquare.lastPosition?.y)!, z: (focusSquare.lastPosition?.z)!) shadowPlane.eulerAngles = SCNVector3(-90.degreesToRadians, 0.0, 0.0) sceneView.scene.rootNode.addChildNode(shadowPlane) }

¿Qué estoy haciendo mal? ¿Alguien puede ayudar?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Hay 3 propiedades de instancia más a tener en cuenta:

 var shadowRadius: CGFloat { get set } var shadowCascadeCount: Int { get set } var shadowCascadeSplittingFactor: CGFloat { get set }

Si no configura estos, definitivamente causan artefactos de renderizado.

 let lightNode = SCNNode() lightNode.light = SCNLight() // POSITION OF DIRECTIONAL LIGHT ISN'T IMPORTANT. // ONLY DIRECTION IS CRUCIAL FOR DIRECTIONAL LIGHTS. lightNode.rotation = SCNVector4(x: 0, y: 0, z: 0, w: 1) lightNode.light!.type = .directional lightNode.light!.castsShadow = true lightNode.light?.shadowMode = .deferred /* THREE INSTANCE PROPERTIES TO SETUP */ lightNode.light?.shadowRadius = 3.25 lightNode.light?.shadowCascadeCount = 3 lightNode.light?.shadowCascadeSplittingFactor = 0.09 lightNode.light?.shadowColor = UIColor(white: 0, alpha: 0.75) scene.rootNode.addChildNode(lightNode)

Y una cosa más : cuando Auto Adjust está desactivado :

La luz, como una cámara, tiene planos de recorte near y far para su configuración.

 lightNode.light?.zNear = 0 lightNode.light?.zFar = 1000000 // Far Clipping Plane is important

ingrese la descripción de la imagen aquí

Espero que esto ayude.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!