Virtual Windows in Passthrough Mode | Selective Passthrough Shader & Stencil Shader

  • 9 March 2024
  • 16 March 2024
  • 4 min read

Hello XR Developers! Today, we’re diving deep into creating those mesmerizing virtual windows that have captivated viewers in viral videos like Ocean Rift. Ready to transform your room into a portal to the underwater world? Letโ€™s embark on this immersive journey together.

๐Ÿ’ฅ Get the exclusive Mesh Destruction project here: https://www.patreon.com/posts/exclusive-mesh-99965227

๐Ÿš€ Starting with the Basics

Begin by setting up a new Unity project with the Universal Render-Pipeline, incorporating the Meta XR SDK and the Mixed Reality Utility Kit. These tools are your gateway to crafting an immersive experience on your Meta Quest device. Ensure your project is Android-ready with Metaโ€™s Project Setup Tool for seamless testing later on.

๐ŸŒ Skybox Creation: Your Underwater Canvas

Transform a captivating underwater video into a panoramic skybox, enveloping your virtual space with the ocean’s allure. By adjusting the video player settings and creating a custom material, you can immerse your scene in the depths of the sea, setting the stage for your virtual windows.

๐ŸชŸ Crafting Virtual Windows: A Glimpse into Another World

The magic happens with the OVR Camera Rig and OVR Passthrough Layer, allowing you to blend virtual elements with real-world surroundings. Utilize the Mixed Reality Utility Kit and a custom “Passthrough” material to selectively render the real world where desired, laying the groundwork for your virtual windows.

๐Ÿ” Cutting Through Reality: The Stencil Shader

Develop a stencil shader to “cut” virtual windows into your walls, enabling a peek into the virtual underwater realm. This shader cleverly manipulates the stencil buffer to create transparent areas in solid objects, offering a glimpse of the oceanic skybox beyond.

๐Ÿ›  Window Placement: Bringing the Ocean to Your Room

With your stencil shader ready, apply it to objects that will serve as your windows. A script, “Layer Applier,” ensures that your room’s walls and furniture are prepared to interact with the shader, making the virtual windows possible.

๐Ÿ–ผ Final Touches: Adding Life to Your Windows

Design your window frame, perhaps a porthole, to anchor the ocean view in your room. Incorporate lighting to enhance the underwater ambiance and use a cylinder with the stencil material to define the window’s shape.

๐Ÿง™โ€โ™‚๏ธ Window-Maker Script: An Interactive Installation

Create a script, “Window-Maker,” to dynamically place windows on your walls with a simple controller gesture. This script allows for interactive placement, giving you the freedom to customize your space with various windows into the underwater world.

๐ŸŽ‰ Testing and Enjoyment

With everything set up, dive into your headset and start placing virtual windows. Watch as your room transforms, offering stunning views of the oceanic depths. Adjust the passthrough color for added immersion, and enjoy the serene underwater landscape from the comfort of your home.

๐Ÿš€ Take It Further with Patreon Exclusive Content

For those eager to push the boundaries of XR development, check out my Patreon for an exclusive tutorial on creating dynamic wall and ceiling breaches, reminiscent of Metaโ€™s “First Encounters” experience. This advanced guide will elevate your virtual window concept to new, interactive heights.

Conclusion: A Portal to New Realities

Creating virtual windows in XR opens up endless possibilities for immersive experiences. Whether youโ€™re simulating underwater vistas or other fantastical landscapes, these techniques offer a gateway to explore the limits of imagination and technology. Dive in, experiment, and let the virtual world expand beyond the screen.

Support Black Whale๐Ÿ‹

Thank you for following this article. Stay tuned for more in-depth and insightful content in the realm of XR development! ๐ŸŒ

Did this article help you out? Consider supporting me on Patreon, where you can find all the source code, or simply subscribe to my YouTube channel!

Leave a Reply

Your email address will not be published. Required fields are marked *