Enabling Accurate Transparency
While you’re probably familiar with how your individual materials calculate their transparency in order to be blended into the scene, you may not be aware of how your scene is accumulating that transparency information, since that accumulation wouldn’t be used on a standard display. With MixCast, this accumulation plays an important role in determining how the virtual and physical layers are blended together, and so can take some special consideration to get right.
Note: Since any changes discussed are to how Unity handles the alpha channel, this process should only impact the mixed reality output and not how graphics appear to the user where the alpha channel isn’t used!
In order to properly handle transparency of foreground objects, your application should use Premultiplied Alpha (PMA) in its transparent materials rather than standard alpha blending (as standard alpha blending operations are not associative).
MixCast supplies an easy solution to produce fully accurate transparency rendering in your project in mixed reality, enabled in two steps:
Flagging PMA Blending in MixCast
- Select the menu item MixCast/Open Project Settings to open the MixCast Project Settings
- Set the Using PMA checkbox to True
Enforce PMA Blending in Project Shaders/Materials
- Select the menu item MixCast/Fix Shaders to open the MixCast Shader Wizard
- Select the Generate Shaders and Update Materials button
- Select the menu item File/Save Project in Unity
Note: The second section need to be completed any time a transparent shader is added, modified, or used with a new material.
MixCast supports rendering the virtual layer(s) with a variety of post-processing effects applied, but sometimes the post-processing effect will discard the alpha channel’s contents, leading to incorrect blending of the virtual scene with the physical one. In this case, ensure that the “Grab Unfiltered Alpha” checkbox in the MixCast Project Settings is enabled if using the Universal Render Pipeline’s post-processing or if seeing incorrect blending when your post-processing effect is applied. This will preserve the alpha channel from before Post-Processing overwrites it.