cancel
Showing results for 
Search instead for 
Did you mean: 

Bug report - Half transparent materials leak Passthrough layer over solid objects

ShivekXR
Explorer

I am kindly asking the community for the help and Meta staff to take care of this bug report or redirect me to the better place to submit the bug report.

Possible duplicate of: https://communityforums.atmeta.com/t5/Unity-VR-Development/Transparent-Materials-render-Passthrough-... My setup is pretty much similar.

Transparency Bug 3.png

Description:
Semi-transparent unlit objects leak passthrough layer over the other objects in the scene. Most of the built-in transparent shaders (or similar like fade mode) are affected by the bug.
Bonus: UI (and Sprite) shaders also have their own problems with passthrough and transparency - they leak the clear flags color instead.
Bonus 2: I saw that the standard material with transparent mode is rendered over other objects as intended but invisible over the passthrough...

Video link: https://drive.google.com/file/d/1IY28LuH17AACvX-IhW4aKclZlq_M-aix/view?usp=sharing

Environment:
- Meta Quest Pro
- Unity 2021.3.25f1
- Oculus Integration SDK 54.1 (Package Manager - June 15, 2023)

Steps to reproduce the bug:
(0. You can fast-forward by downloading the scene I have created: https://github.com/ShivekXR/Passthrough-Transparency-Bug)
1. Follow the guide to create the basic scene (setup for Quest Pro): Tutorial - Create Your First VR App on Meta Quest Headset | Oculus Developers
2. Follow the guide to add the passthrough to the basic scene: Get Started with Passthrough | Oculus Developers
3. Add a semi-transparent object over another one using (standard / generic / built-in) unlit material.
Transparency Bug 1.png
Transparency Bug 2.png
4. Build and run the app and see the result (bug).

Expected Result:
Semi-transparent materials should be rendered over other objects in the scene. The solid objects behind them should block passthrough.

Severity:
Personally - I think 4 out 5. It doesn't crash the app, but makes passthrough visually unpleasant, confusing, not convincing effect.
Any particle effect with opacity look bad by default.

8 REPLIES 8

ShivekXR
Explorer

I think I found solution, thanks to @TheDaddis 
The current solution is on the repo. Later I'll add another repository with fix for standard particle shaders.
cc: @ElasticSea 

nickw545
Explorer

Hi ShivekXR, glad you found a solution to this problem. What exactly is the fix for this? I've been playing around with the shader settings but haven't been able to solve it yet.

Steven.Yang
Honored Guest

did anyone fixed this problem?

FelixDG.Trebuchet
Honored Guest

Since no one gave any solutions yet I'll add mine.

My solution was to use Premultiplied Alpha instead of typical Alpha Blend. I believe since Alpha Blend applies itself to the source image it overwrites the pixel's alpha. If that's right, the Passthrough then might think that these pixels are completely transparent.

Since Premultiplied alpha just adds itself to the image while checking the source on the side, the only thing it can really do is "add" more than 1 to the alpha which doesn't happen.

This is all conjecture though to be completely honest. The important part is that it works.

This is a fix for conventional blending only though. I've been using Alpha to coverage for a bunch of my shaders and I had to completely trash that in favor of premultiplied alpha with another depth pass on the side which is a real bummer. Meta should still find a fix for this so that Alpha to coverage is still usable in mixed reality.

One thing that' I'd love to have as a feature is to be able to just input the passthrough into the clear flag of the camera, since that would give all the control I personally would ever need over it.

ShivekXR
Explorer

@nickw545 @Steven.Yang  The posted solution was not perfect. Later I found out the blending should look like this (for unlit transparency):
Blend SrcAlpha OneMinusSrcAlpha, SrcAlphaSaturate OneMinusSrcAlpha

I'll try to make a repo for unlit transparency shader + particles soon. Sorry for the late reply.

@FelixDG.Trebuchet please check if the blending above corresponds with your observation. I don't really know much about premultiplied alpha issues.

markeahogan
Explorer

The blend mode should be

Blend SrcAlpha OneMinusSrcAlpha, OneMinusDstAlpha One for alpha blend

Blend One OneMinusSrcAlpha, OneMinusDstAlpha One for premultiplied alpha

Only the separate alpha blend mode is really important here

Basically when blending the alpha channel, the dst alpha should only get more and more opaque, which is why the alpha dst blend is One. Then the src alpha can only fill up whatever transparency space not taken already on dst, so OneMinusDstAlpha

The passthrough is always blended with the game layer using premultiplied alpha, so one neat trick I've yet to find a use for is you can do additive blending between the passthrough and the game by writing 0 to alpha and whatever you want to RGB

@markeahoganThank you so much for sharing this! Setting the blend mode to

Blend SrcAlpha OneMinusSrcAlpha, OneMinusDstAlpha One

fixed the passthrough transparent rendering bug for my own transparent materials. If the issue still exists for any default Unity transparent materials though, then Meta should see what they can do to fix it... I had to duplicate and modify their 'OculusHand' shader in order to properly render their 'stylized hand' model with no passthrough rendering bug.

abebkoFV
Explorer

I'm getting this error with GLTFast - imported semitransparent materials