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?
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.
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.
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:
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!
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.
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.
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.
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 ?
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.
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 ā¦
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.
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.