mob-sakai / SoftMaskForUGUI

Enhance Unity UI (uGUI) with advanced soft-masking features to create more visually appealing effects!
https://github.com/mob-sakai/SoftMaskForUGUI
MIT License
1.97k stars 261 forks source link

[v1] Support single pass instancing for VR #85

Closed mob-sakai closed 1 month ago

mob-sakai commented 4 years ago

ref: #48 #79

https://docs.unity3d.com/Manual/SinglePassInstancing.html

maskedmouse commented 4 years ago

How's the progress of this issue? If you want me to test the functionality, let me know. I've got an Oculus GO.

mob-sakai commented 4 years ago

@maskedmouse Thanks! So far no progress has been made...

mob-sakai commented 4 years ago

SoftMask_VRTest.zip

WIP: Experimental version with support for multi-pass, single-pass and single-pass instancing.

Open Assets/VRTest.unity and build it.

To change render mode, select VR menu.

maskedmouse commented 4 years ago

I've tested it with Unity 2019.3.15 without success.

Just a few remarks:

I've made a screen capture of the result: Oculus GO 2019 3 15

I noticed the stereo rendering mode for Oculus is Single Pass Multiview. In the future 2020.1+ the XR Management package must be used. Which also has 2 options, Multipass or Multiview. Which in our case would be Single Pass Multiview. I have tried the new XR Management package. But the result is the same.

For PC Oculus I cannot test right now (which can be Single Pass Instanced). I could test this later if you want.

mob-sakai commented 4 years ago

I don't know why Unity-chan are not displayed. Instead, gray rectangles are displayed... Are Unity-chans displayed in editor?

mob-sakai commented 4 years ago

Yes, the XR Management package should be supported in the future.

XR configuration in my environment:

BTW, does multi pass render mode work well?

mob-sakai commented 4 years ago

It seems to be working fine on my android device.

image image

maskedmouse commented 4 years ago

I don't know why Unity-chan are not displayed. Instead, gray rectangles are displayed... Are Unity-chans displayed in editor?

Yes they are displayed in the editor.

BTW, does multi pass render mode work well?

I've used the new XR Management SDK with Multipass and that seems to work.

If you need me to debug some specific values let me know.

Oculus GO 2019 3 15 XR Management

mob-sakai commented 4 years ago

Please try this. SoftMaskUGUI-VR-2.zip

Open Assets/VRTest.unity and build it. The scene contains a non-soft-maskable image.

maskedmouse commented 4 years ago

Please try this. SoftMaskUGUI-VR-2.zip

Open Assets/VRTest.unity and build it. The scene contains a non-soft-maskable image.

The result is that the soft masked items are still gray squares. The regular non-soft-maskable image is displayed fine.

Oculus GO 2019 3 15 (2)

mob-sakai commented 4 years ago

Please try this. SoftMaskUGUI-VR-3.zip

maskedmouse commented 4 years ago

I've updated to the LTS release 2019.4.0f1 The image is now totally gone.

Oculus GO 2019 4 0f1

I'm using the Android Logcat 1.2.0-preview package to read out the output logs. I notice there is an OpenGL error. Not sure if it is related to this. But it is worth mentioning. 2020/06/10 10:25:36.777 31818 31833 Error Unity OPENGL NATIVE PLUG-IN ERROR: GL_INVALID_OPERATION: Operation illegal in current state It might be a thing of 2019.4 though.

mob-sakai commented 4 years ago

Wow!

mob-sakai commented 4 years ago

OK, let's test another shader...

mob-sakai commented 4 years ago

SoftMaskUGUI-VR-4.zip

maskedmouse commented 4 years ago

I'm getting the exact same result as before. Image is not showing.

In editor it indeed shows the RGB values but on the Oculus GO nothing

mob-sakai commented 4 years ago

Oh, I was making a mistake! Please fix UI-Default-SoftMaskable.shader as following:

// line 101
//UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex); // Comment out
sampler2D _MainTex; // ADD

If you comment out the same file in SoftMaskUGUI-VR-3.zip, it may work.

maskedmouse commented 4 years ago

That seems to do the trick!

Oculus GO 2019 4 0f1 removed Screenspace Declaration

I'll change it to the third iteration and test that one as well.

maskedmouse commented 4 years ago

Yeah awesome!

Oculus GO 2019 4 0f1 Fixed

mob-sakai commented 4 years ago

👏👏👏👏

mob-sakai commented 4 years ago

OK, VR support is the next step:

maskedmouse commented 4 years ago

I've received news about the Oculus GO no longer being supported after 4 december 2020. I've tested the Oculus Quest with the solution you've made and it works there as well. All that remains is the actual implementation of the solution into the package.

mob-sakai commented 4 years ago

:+1:

maskedmouse commented 4 years ago

I'm trying to get an Oculus Quest build ready but I'm uncertain whether the package could be used in the last state you've posted. It think it could be used, because it works in a release build. It is just not in an optimal state yet right? As you've listed you want to create a singular Buffer for both eyes (I guess to preserve memory as you require double the texture memory now) and optimizing the scripts.

The only bug that I can find is that the Game View without VR enabled the softmask is broken. Not a big issue for me since I have VR enabled all the time but might be worth noting. I'll be looking forward to the release of the feature. In the meanwhile, I guess I'll use the solution as is since it seems to work.

mob-sakai commented 4 years ago

:+1: :+1: :+1: :+1: :+1: :+1: :+1:

mob-sakai commented 3 years ago

WIP

ruben-ivre commented 3 years ago

I'm very interested on this too, any updates? I have access to plenty of VR devices, so let me know if you want to test anything.

mob-sakai commented 3 years ago

@ruben-ivre :+1:

maskedmouse commented 3 years ago

It seems like in Unity 2020.2.1 the SoftMask is broken again. Perhaps this is due to an Universal Render Pipeline update. Reverting back to Unity 2020.1.x and it works again.

mob-sakai commented 3 years ago

OMG😇

maskedmouse commented 3 years ago

Update: When creating a small reproduction project, it seems to work fine in the editor with the latest SoftMasking package (1.0.0-preview.14) & Universal Render Pipeline (10.2.2). But once it is built for the Oculus Quest (Android) it fails, same as before the fix. With the package version from here, in 2020.2 it doesn't work in either editor nor Quest.

nagoya0 commented 2 months ago

Do you have any updates on this?

mob-sakai commented 1 month ago

Please try v2: https://github.com/mob-sakai/SoftMaskForUGUI/releases/tag/v2.0.0