Passthrough layered ontop of transparent materials

Hi,

Since we updated to VisionOS SDK 1.3.9 we can see the passthrough of the cameras faintly layered ontop of our transparent UI materials and object materials.

Since we are creating a fully immersive app, I thought this would not even be possible?

Did I forget to configure something to avoid this effect?

Thanks

I believe this is a new behavior introduced with visionOS 2. Even if you’re building with the old SDK, passthrough is enabled by default for all apps. In theory, you shouldn’t be seeing through an opaque background, anyway, so there’s some sort of bug. I don’t think anything has changed on our end, but it looks like we need to give you a way to specify a Full immersion style in our old plugin version to prevent this.

If you don’t mind, could you file a bug Help > Report a Bug... in Unity so that we can track this? I’ll update this ticket with more information as I have it.

Something else I forgot to ask:

  • What version of Xcode are you using?
  • What version of visionOS is running on your device?

I assumed that you had updated your device(s) to visionOS 2, but I want to confirm. I don’t think it makes a difference what Xcode version you are using, either, but you need Xcode 16 for the visionOS 2 SDK, so I’m curious to know if the issue is present in builds made with Xcode 15.

Hm… actually if I build our sample scene on the latest v1.3.9 packages I don’t see this issue. I only see it when building with 2.x packages.

I’ll probably need to see your specific project to debug this.

Sorry for the delay.

I am building with XCode 16 and the Vision Pro is running VisionOS 2.1 22N5558e.

Unity is 2022.3.49f1
ā€œcom.unity.xr.handsā€: ā€œ1.5.0ā€,
ā€œcom.unity.xr.managementā€: ā€œ4.5.0ā€,
ā€œcom.unity.xr.openxrā€: ā€œ1.12.1ā€,
ā€œcom.unity.xr.visionosā€: ā€œ1.3.9ā€,
ā€œcom.unity.modules.xrā€: ā€œ1.0.0ā€
ā€œcom.unity.render-pipelines.universalā€: ā€œ14.0.11ā€,

The working project is to big for archiving. I have to see if I find the time to create a sample project.

I don’t think this is specific to visionOS.

It’s happening in my Quest 3 build as well. Translucent materials show passthrough instead of the thing I expected to see…

This is a BIG problem for when you’re trying to implement a screen fader by attaching a plane to the headset then try to fade it in/out.

Ah that’s good information, thanks! I think it’s happening because the transparent objects are writing alpha values <1 if they are the last object to be drawn for a given fragment. This is a bug on our end. If you haven’t already, please submit a bug report with a project that replicates the issue.

Hey there! I have some good news to share on this issue. I was able to fix this in the visionOS sample scene by modifying line 12 of Shaders/UnlitTransparentColor.shader like so:

Blend SrcAlpha OneMinusSrcAlpha, SrcAlpha DstAlpha

It was previously just:

Blend SrcAlpha OneMinusSrcAlpha

According to the docs, just one pair of blend factors will apply the same blending operation to all RGBA values, where we really just want to blend RGB and leave A alone. By adding , SrcAlpha DstAlpha telling the shader not to alter the alpha value of framebuffer when it draws this fragment.

It appears to be a simple mistake in the custom shader we use in the visionOS sample scene, and something that is easy to overlook, so may be an issue in other shaders. In general, most Unity apps don’t care about final alpha because when the content is rendered to a screen, alpha has no effect. But one way or another when you’re seeing this issue of passthrough bleeding through transparent objects, check the shader for what the blend operation looks like, and try making the same fix.

I’ll try to get this fix into the sample for our next package release. Thanks for reporting the issue!

1 Like

Very cool you found a fix!

So if I’m understanding this correctly, this is an issue in a default Unity shader? If we wanted this fix on a Quest 3 build, we’d need to stop using this shader and create a copy for ourselves with this one line fix?

It’s at least an issue in the Create > Shader template that you get when you create a new shader in the Editor. I checked the URP/Lit shader as a one-off, and it does not have this issue, so I wouldn’t just assume every shader has the same issue. It’s just easily overlooked, so I wouldn’t be surprised to see it elsewhere.

Yes. In order to fix the issue, you need to modify the shader. If it is in a read-only package you will need to copy the shader. It might actually be easier to just copy the whole package into Packages/com.unity.package-name and modify the original shader, so you don’t have to go chasing down every reference to it and replace it with the new one.

And please, if you don’t mind, let us know which ones in Unity packages need to be fixed! I’ve done a basic search through URP shaders and haven’t found any that need fixing, but it certainly wasn’t exhaustive.

Thanks for reporting the issue, and good luck!

1 Like

Pardon the noob question. Can you provide more details on how to find other places this shader might be. We replaced line 12 in the one Shader files called ā€œShaders/UnlitTransparentColor.shaderā€ that didn’t have the full text.

But the transparency still persists in the dark areas of our scene.
Unity 6
Xcode 16
VR/full immersive

Hey there! No need to beg pardon. This is the right place for questions, noob or otherwise. :slight_smile:

I think the Shaders/UnlitTransparentColor.shader you’re referring to came from the visionOS XR Plugin package samples? That will account for the AR planes and meshes that use that shader, but likely isn’t used in the ā€œdark areasā€ that you’re talking about.

Can you figure out what shader is drawing over the dark parts? Can you include a screen shot? It’s possible that what you’re seeing is a built-in OS behavior where VR content begins to fade out if you get too far away from the session origin. If you move more than 1.5 meters from where you started, the immersive space will fully disappear and the app is replaced by an icon hovering over the session origin. Is it possible that this is what you are seeing?

Otherwise, we’ll have to narrow down which shader is drawing that dark area and causing the passthrough feed to bleed through. Are you able to submit a bug report with your project attached? That way we can replicate the issue on our end and use tools like the Frame Debugger or Metal Frame Capture to determine which shader is responsible for drawing that area of the scene. You can also use these tools on your end, but there’s a bit of a learning curve.

Hello @mtschoen, I still have exactly the same issue with transparent unlit materials that render the Meta Quest passthrough and as said @BlackPete

" This is a BIG problem for when you’re trying to implement a screen fader by attaching a plane to the headset then try to fade it in/out."

I had also the same issue on VisionPro

I’m also using a lot of custom differents Transparent materials at various places when it’s needed. The main part of my custom shaders are Opaque.

I need to precise that all my custom shaders Opaque and Transparent are Shader Graphs shaders.

I replace this, as you mention earlier, but i doubt that is very usefull because i’m using custom shaders.

Blend SrcAlpha OneMinusSrcAlpha, SrcAlpha DstAlpha

Do you have any ideas how can I update this code in Shader Graph shaders ?

Thanks

Good question! I’m not sure that you can set this particular blend mode on Shader Graphs. I’ll ask around and see what the best solution is here.

Hey again! I checked with our graphics team and unfortunately there isn’t a way to set this blend mode in the ShaderGraph itself. We’re considering some options for how to support this in the future, but in the meantime you will have to implement these shaders with ShaderLab code. You can export the code from the shader graph’s asset inspector and then modify it from there.

Let us know if you’re still having trouble here, and I’ll try to help however I can.

Humm I see ok, I’m not really into HLSL, this is the header of my custom shader that is rendering Passthrough where it should not.
Can you spot something ? Maybe the ā€œBlendā€ line at 45 ?


Unlit_SphereFade.shadergraph.zip (6.5 KB)

Yep! You should be able to replace Blend [_SrcBlend] [_DstBlend] with the magic Blend SrcAlpha OneMinusSrcAlpha, SrcAlpha DstAlpha and your shader will blend properly with opaque objects. The current code is set up to allow material properties to set the blend mode.

Okay i’ll love the try this.

It’s again a noob question but when I click on compile and show code in the Inspector of my shader graph; I modify the lign but I can’t save the file. I mean the file can be saved, but when I close/ reopen the shader, the file get back to the " Blend [_SrcBlend] [_DstBlend]" version.

I also try to copy/paste the code to create a new shader file including your modification, but now I have an import error …

Unlit_SphereFade_TEST.shader.zip (82.0 KB)

Thanks for your help

Hi again! I should have been a little more clear about the process here. I think you’re using the Generate Shader/View Generated Shader buttons which I also tried at first. This gives you a lower-level description of the compiled shader, but for our purposes, we want the code.

For this, you’ll want Copy Shader, which copies the code to the clipboard. Simply create a new Shader asset in your project, open it up, click Copy Shader, and then paste the code into the new shader asset, replacing its contents completely. That should give you a valid shader that compiles, and that you can modify to your heart’s content!

Bear in mind that your shadergraph will probably be broken into multiple sub-shaders, each with their own blend properties. You probably want to change all of them to Blend SrcAlpha OneMinusSrcAlpha, SrcAlpha DstAlpha, but it depends on what the shader is doing.

Hope this helps!

Ok, awesome — your solution works perfectly in my case. I had three different transparent shaders and it worked flawlessly; I no longer see passthrough showing up on my transparent objects.
That said, the method isn’t very clean or scalable. I’d even say this looks like a Unity bug.
If you ever hear about it getting fixed, please drop a note here.

Thanks again!

1 Like