SceneKit剔除飞机 [英] SceneKit Culling Plane

查看:191
本文介绍了SceneKit剔除飞机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在SCNView中有一个SCNScene渲染。我有一些在场景中渲染/移动的* .dae模型。



我有一个透明的立方体,当我的一个模型落后它时,我想模型不能渲染,因为目前,由于立方体是透明的,你可以通过立方体看到它。



是否有任何属性/设置/着色器可以适用于透明立方体,以便它后面的任何东西都不会被渲染?



示例:

我的眼睛是绿色圆点,立方体是蓝色方形,我的模型是红色圆形,但是立方体隐藏的圆圈部分是紫色的......这实际上是隐形的。蓝色方块也是不可见的。





这位开发者拥有一个遮挡着色器,它可以满足我的需求,但它是Unity: https://youtu.be/MK3D91kCKzM



亲切的问候



克里斯

解决方案

以下是一个解决方案


  1. 对于立方体,使用 常量 lightingModel 。这是最便宜的。

  2. 这份材料将包含 writesToDepthBuffer 设置为 true colorBufferWriteMask 设置为 [] (空选项集)。这样多维数据集将写入深度缓冲区,但不会在屏幕上绘制任何内容。
  3. 设置多维数据集的 renderingOrder to -1 so它在场景中的任何其他节点之前被绘制。这将使多维数据集在任何其他对象之前写入深度缓冲区,防止它们在多维数据集后面被绘制。


I have a SCNScene rendering in a SCNView. I have some *.dae models that are rendered/moving in the scene.

I have a transparent cube, when one of my models goes behind it, I would like the model to not be rendered, because at the moment, as the cube is transparent, you can see it through the cube.

Is there any property/setting/shader I can apply to the transparent cube so that anything behind it is not rendered?

Example:

My eye is the green dot, the cube is the blue square, my model is the red circle, However the part of the circle hidden by the cube is purple...this would actually be invisible. The blue square would be invisible too.

This developer has an occlusion shader which does what I need, but it's Unity: https://youtu.be/MK3D91kCKzM

Kind Regards

Chris

解决方案

Here's a solution

  1. For the cube, use a material with constant as its lightingModel. It's the cheapest one.
  2. This material will have writesToDepthBuffer set to true and colorBufferWriteMask set to [] (empty option set). That way the cube will write in the depth buffer, but won't draw anything on screen.
  3. Set the cube's renderingOrder to -1 so that it's drawn before any other node in the scene. This will make the cube write in the depth buffer before any other object, preventing them from being drawn if they are behind the cube.

这篇关于SceneKit剔除飞机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆