Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UV flips up and down on HoloLens2 real device in magnifier function. #147

Open
HoloMoto opened this issue Jan 19, 2023 · 2 comments
Open
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@HoloMoto
Copy link
Collaborator

Describe the bug

While playing with the new feature while working on other MRGT issues, I encountered a problem with the screen of the magnifier function flipping upside down on the actual HoloLens2 device.

https://youtu.be/C5aYusFA_tM

I was able to get it working on the actual device by inverting the Y component of the UV in Graphics Tools/Magnifier.

            half4 frag(v2f i) : SV_Target
            {               
                float2 normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(i.vertex);

                float2 normalizedScreenSpaceUVStereo = UnityStereoTransformScreenSpaceTex(normalizedScreenSpaceUV);              

                normalizedScreenSpaceUVStereo.y *=-1; //Add!!
                float2 zoomedUv = zoomIn(normalizedScreenSpaceUVStereo, MagnifierMagnification, Center);
               
                float4 output = SAMPLE_TEXTURE2D_X(MagnifierTexture, samplerMagnifierTexture, zoomedUv);
                                
                return output;
            }

https://youtu.be/-tDxe4X7AnQ

 I have previously encountered the same UV upside down phenomenon when using CameraOpaqueTexture in a URP environment to create my own lightweight Bloom post effect.
 This only occurred on the actual HoloLens device, not on the Editor, and seems to be the same as this time.

 Maybe there is something going on with the HoloLens rendering or deploying from Untiy, but I don't understand it and am very curious.

To reproduce

I deployed to HoloLens2 in Unity2021.3.5f1 with MRTKv2.8.2 using OpenXR platform.

Expected behavior

It needs to be rendered correctly in HoloLens as well as VR without tampering with the code itself.

Screenshots

Please refer to the above Youtube video.

Your setup (please complete the following information)

Unity Version 2021.3.5f1 (URP)
Graphics Tools Version 0.5.0(Introduced from MixedRealityFeatureTools)

Target platform (please complete the following information)

Only HoloLens 2

Additional context

I would like to understand the cause of the problem as I am curious about the causes in this area.

@Cameron-Micka
Copy link
Member

Thank you for reporting this @HoloMoto. We likely need to key off of the UNITY_UV_STARTS_AT_TOP keyword like so:

// Flip vertical UV for orthographic projections (if not already flipped) to ensure the image is not upside down.

@Cameron-Micka Cameron-Micka added bug Something isn't working good first issue Good for newcomers labels Jan 19, 2023
@Cameron-Micka
Copy link
Member

Looked at this briefly, it's not as simple as UNITY_UV_STARTS_AT_TOP. Something else is going on for HoloLens (works fine on Quest 2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants