Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
466 views
in Technique[技术] by (71.8m points)

ios - SceneKit Culling Plane

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.

Cull

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

Kind Regards

Chris

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...