Post

Replies

Boosts

Views

Activity

SCNRenderer does not produce depth texture with SCNLight inside scene
I use SCNRenderer to render SCNScene in my custom rendering pipeline. Also, I need to retrieve scene depth texture during rendering. I do it with: passDescriptor.depthAttachment.texture = depthTexture passDescriptor.depthAttachment.clearDepth = 1.0 passDescriptor.depthAttachment.loadAction = .clear passDescriptor.depthAttachment.storeAction = .store Everything works as expected, I do receive scene depth texture. But when I add a directional SCNLight with .castsShadow = true property into my scene, SCNRenderer writes zeros into depth texture. let lightNode = SCNNode() lightNode.light = SCNLight() lightNode.light?.type = .directional lightNode.light?.castsShadow = true //... After adding .castsShadow = true entire depth texture is filled up with zeros. But when I comment out .castsShadow = true line, depth texture works as expected. I can't understand why does it happen. My current solution: I now use 2 scenes: with and without light. The first one I use to retrieve the picture of my scene and the second one I use to retrieve the depth of my scene. But I think it's not the best solution and there must be a better way to deal with this problem. Are there any ideas where I should be looking? I use MetalKit only (no OpenGL) in my project. Device: iPhone 12 Pro OS: iOS 14.2 Xcode: 12.1
0
0
563
Nov ’20