I'm trying to wrap my head around how to use SCNTechnique with Scenekit.
The effect I'm trying to create can easily be achieved in Unity by adding a custom shader to two materials, making objects with the "filtered" shader to only be visible when it is seen through the other shader (the portal). I've followed this tutorial to create this in Unity: https://www.youtube.com/watch?v=b9xUO0zHNXw
I'm trying to achieve the same effect in SceneKit, but I'm not sure how to apply the passes. I'm looking at SCNTechnique because it has options for stencilStates
, but I'm not sure if this will work.
There are very little resources and tutorials on SCNTechnique
As mentioned in the comments above, I am not sure how to achieve an
occlusion
effect usingStencil Tests
which as we know are fairly (and I use that term very loosely) easy to do inUnity
.Having said this, we can achieve a similar effect in
Swift
using transparency
, andrendering order
.Rendering Order
simply refers to:Whereby
SCNNodes
with a larger rendering order are rendered last and vice versa.In order to make an object virtually invisible to the naked eye we would need to set the
transparency
value of anSCNMaterial
to a value such as0.0000001
.So how would we go about this?
In this very basic example which is simply a portal door, and two walls we can do something like this (which is easy enough to adapt into something more substantial and aesthetically pleasing):
The example is fully commented so it should be easy to understand what we are doing.
Which can be tested like so:
Hope it points you in the right direction...
FYI there is a good tutorial here from Ray Wenderlich which will also be of use to you...