MixedRealityToolkit-Unity icon indicating copy to clipboard operation
MixedRealityToolkit-Unity copied to clipboard

Visual Masking Bug

Open Chase-William opened this issue 5 years ago • 6 comments

Visual Masking Bug

This bug involves masking game objects within a unity canvas. Masking a child object of a panel while all being inside a canvas doesn't work on the physical device correctly. To elaborate, the simulator works as expected masking the child object, but when ran on the actual device, the user doesn't see the mask in effect. Now for the confusing part, when you are running on the physical device, take a screenshot I used speak recognition via saying "Cortana, take a picture". You will see that the screenshot shows the mask working correctly.

To reproduce

I have a pre-baked unity project here I highly recommend to use because there is a lot of setup required, check src/

Steps to reproduce the behavior:

  • Create a Unity Project, I am using version 2020.3.13f1
  • Use the MRTK Tool to install packages 2.7.2.0
    • com.microsoft.mixedreality.openxr
    • com.microsoft.mixedreality.toolkit.foundation (this installs com.microsoft.mixedreality.toolkit.standardassets as a dep)
  • Configure to use OpenXR and Add the MRTK configuration to your scene
  • Add a GameObject under the MixedRealitySceneContent and name it MainWindow
    • Add this script to the MainWindow. This ViewFollower script makes the game object follow our camera. image Adding a MeshFilter and a MeshRenderer are just to make visualizing the location of the MainWindow easier. image
    • Add a child of type Canvas to the MainWindow and resize / position it to appear properly sized in front of the camera. Make it's positioning is set to World Space. image image
    • Add a child of type Panel to the Canvas and add the Mask component to the newly added Panel. Make sure to set the Source Image of the mask to some shape. image image
    • Add a child of type Raw Image to the Panel you just added. This Raw Image will be what our mask is masking or cropping. image image As you can see I have set Color to red for example and the Source Image to the Knob shape which is a circle. So essentially we have a circle of red that will be masked to the shape set in the parent Panel's Mask component's Source Image property. As seen below: image Now the masking can be tested on the HoloLens 2.

Expected behavior

Using a Panel with a Mask component inside a Canvas will mask children of that Panel.

Screenshots

Using Camera Screenshot

image

Recreation of what I (the user) sees

image

My Setup

  • Unity Version 2020.3.13f1
  • MRTK Version 2.7.2.0 If I missed anything let me know, otherwise, the repo might have what I missed.

Target Platform(s)

  • HoloLens 2

Chase-William avatar Aug 06 '21 18:08 Chase-William

I have a similar issue. We use the same setup, but as soon we use Unity UI components either taking "screenshots" or while recording videos. The Unity UI components won't be rendered in video/photo although we can see them on the physical device.

Spoon2311 avatar Aug 08 '21 08:08 Spoon2311

I have a similar issue. We use the same setup, but as soon we use Unity UI components either taking "screenshots" or while recording videos. The Unity UI components won't be rendered in video/photo although we can see them on the physical device.

Sounds like you are having the opposite issue of what I am experiencing no? For I, being the user wearing the physical device I cannot see the mask correctly, whereas the camera does... Interesting this is.

-- Edit I just discovered that a video I was watching on the HoloLens 2 that had black bars on either side because of it's width where invisible when watching through the HoloLens 2. I took a video, of the video on the HoloLens 2 and the black bars show up in the recording. Therefore, I wonder if you could use black rectangles (any shape for that matter) to mask things as a hacky work around?

Chase-William avatar Aug 12 '21 12:08 Chase-William

I have a similar issue. We use the same setup, but as soon we use Unity UI components either taking "screenshots" or while recording videos. The Unity UI components won't be rendered in video/photo although we can see them on the physical device.

Sounds like you are having the opposite issue of what I am experiencing no? For I, being the user wearing the physical device I cannot see the mask correctly, whereas the camera does... Interesting this is.

-- Edit I just discovered that a video I was watching on the HoloLens 2 that had black bars on either side because of it's width where invisible when watching through the HoloLens 2. I took a video, of the video on the HoloLens 2 and the black bars show up in the recording. Therefore, I wonder if you could use black rectangles (any shape for that matter) to mask things as a hacky work around?

Thanks for the answer. I think you're right, our issue is not the masking but actually the components not showing in the video.

Therefore I don't think using the black bar would work.

Spoon2311 avatar Aug 12 '21 16:08 Spoon2311

Hi @Chase-William thank you for submitting this beautifully detailed visual masking bug, and creating the supporting reproduction Unity Project repository! I will investigate this issue, and then it will get sorted out.

@Spoon2311 Thank you for the additional insight that you have provided on this issue. It will save me some time during the investigation!

elbuhofantasma avatar Aug 17 '21 03:08 elbuhofantasma

This issue has been marked as stale by an automated process because it has not had any recent activity. It will be automatically closed in 30 days if no further activity occurs. If this is still an issue please add a new comment with more recent details and repro steps.

stale[bot] avatar Apr 17 '22 04:04 stale[bot]

We appreciate your feedback and thank you for reporting this issue.

Microsoft Mixed Reality Toolkit version 2 (MRTK2) is currently in limited support. This means that Microsoft is only fixing high priority security issues. Unfortunately, this issue does not meet the necessary priority and will be closed. If you strongly feel that this issue deserves more attention, please open a new issue and explain why it is important.

Microsoft recommends that all new HoloLens 2 Unity applications use MRTK3 instead of MRTK2.

Please note that MRTK3 was released in August 2023. It features an all new architecture for developing rich mixed reality experiences and has a minimum requirement of Unity 2021.3 LTS. For more information about MRTK3, please visithttps://www.mixedrealitytoolkit.org.

Thank you for your continued support of the Mixed Reality Toolkit!

IssueSyncBot avatar Jan 13 '24 00:01 IssueSyncBot