Note: Make sure you have a Unity project with version 39 of the Oculus Integration package imported.
Let’s begin by learning how to create a surface projected passthrough. As the name suggests, we can have a surface/geometry that’s defined by us and project the passthrough layer on it.
In this section, we’ll set up our scene to work with passthrough.
With that, we have our scene setup. Next, we’ll see how to add the surface onto which the passthrough layer should get projected upon.
The projection surface can be of any shape i.e it could be a Quad or a Cube or a Sphere, etc. But the important thing we need to keep in mind is that the projection surface should match the surface of the real world. For example, if we have a flat object like a laptop screen in front of us and we project it on a sphere, the screen will be distorted. Similarly, if we have a curved surface in front of us and it’s projected on a plane, the curved surface will look distorted as well. In this blog, we’ll use Quad as a projection surface but feel free to any surface of your choice.
To assign this surface for projecting passthrough, we’ll need to write a simple script and add it to the ProjectionSurface GameObject
With that, we have successfully created a surface projected passthrough. Now, what if we want the passthrough to be projected on more than one surface? We’ll see that in the next section.
Creating another projection surface is simple:
Now, what if we want to distinguish between the two surfaces? For that, we’ll have to create another passthrough layer and tweak its properties like color/brightness/contrast/edge rendering, etc.
With that we have learned to create surface project passthrough. Up next is Selective Passthrough.
Now, we’ll learn to create selective passthrough. Unlike surface projected passthrough, selective passthrough doesn't require a geometry as it will show the reconstructed environment.
In this section, we’ll set up our scene to work with passthrough.
With that, we have our scene setup. Next, we’ll see how to create and use the selective passthrough material onto which the passthrough layer should get projected upon.
To create a material for selective passthrough:
With these settings, the material when applied to an object will subtract that volume of the object from the VR environment and show the passthrough.
Note: Render queue sets the priority/order of the material being rendered at. The higher the number, the later it gets rendered. All the default materials have a render queue of 2000, so by setting the Render Queue of passthrough material to 4000, it will ensure that the passthrough gets rendered after all other materials are done rendering.
We’ll create two spheres enclosing the controllers and add the material we just created. Along with that, we’ll write a script which will enable and disable the spheres on the controller with a button press.
With that, we learned to create selective passthrough experience.
The surface projected passthrough has better depth accuracy when compared to selective passthrough. The only disadvantage is that the geometry of the passthrough should match the physical world surface. However, both of these can be used in apps to enable the user to have a window into their physical world.
Previously, we learnt about Passthrough and how it’s set up, we learned about implementing the passthrough and we saw how to customize the passthrough layer. If you haven’t checked it out yet then we highly recommend reading it first. In this blog post, we’ll learn how to create surface projected passthrough and selective passthrough.
If you've enjoyed the insights shared here, why not spread the word? Share the post with your friends and colleagues who might also find it valuable.
Your support means the world to us and helps us create more content you'll love.