Occlusion Material or Hold-Out Shader in ARKit and SceneKit

后端 未结 1 2086
不知归路
不知归路 2021-02-09 18:37

I have seen some examples demo of ARKit where material A is blocking material B, kind of creating occlusion effect, or black hole, or masking. But all of them seems to be using

相关标签:
1条回答
  • 2021-02-09 18:55

    Yes, it's definitely possible to use a 3D object as a hold-out mask, a.k.a. Occlusion Material in iOS and macOS apps. An instance property, called .colorBufferWriteMask, actually writes depth channel information when rendering the material. So you need the following value for this property for masking object:

    sphere.geometry?.firstMaterial?.colorBufferWriteMask = []
    

    ...and don't forget to assign an appropriate rendering order (closest to the camera):

    sphere.renderingOrder = -50  
    

    ..and give two values that determine whether SceneKit produces depth information when rendering the material or not:

    sphere.geometry?.firstMaterial?.writesToDepthBuffer = true
    sphere.geometry?.firstMaterial?.readsFromDepthBuffer = true
    

    0 讨论(0)
提交回复
热议问题