microsoft / MixedRealityToolkit-Unity

This repository is for the legacy Mixed Reality Toolkit (MRTK) v2. For the latest version of the MRTK please visit https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity
https://aka.ms/mrtkdocs
MIT License
6.02k stars 2.12k forks source link

Android rendering problem #5845

Closed Alexees closed 4 years ago

Alexees commented 5 years ago

Describe the bug

Activating the BoundingBox on an Oculus Quest instantly turns this:

de holospaces helios-20190901-225026

into this:

de holospaces helios-20190901-225036

To reproduce

Steps to reproduce the behavior:

  1. Build a BoundingBox to the Oculus Quest somehow

Expected behavior

Normal rendering

Your Setup (please complete the following information)

Target Platform (please complete the following information)

SimonDarksideJ commented 5 years ago

Two things, MRTK doesn't support the Oculus Quest atm. Additionally, the Bounding Box requires a Wireframe shader that uses Geometry shaders at present. The Quest GPU does not support Geometry shaders at this time.

Alexees commented 5 years ago

@SimonDarksideJ I should have mentioned, that I'm working with @davidkline-ms on making 3rd party platform integration possible. I am working on integrating the Quest. Do you have a suggestion on how I can use the BoundingBox wihout the use of GeometryShaders?

SimonDarksideJ commented 5 years ago

That is the 10 million $$$ question. Might be worth reaching out to @wassx and @Cameron-Micka our resident shader bobbins

Cameron-Micka commented 5 years ago

Hi @alexees, that is an interesting bug! Is there anything interesting in the Unity log file when this occurs? It looks to me like a potential GPU driver issue, but it's hard to tell with these things. (Sounds like I need to pick up an Oculus Quest).

Also, the current bounding box shaders only rely on vertex and pixel shaders. So, they should work on a platform that doesn't support geometry shaders.

SimonDarksideJ commented 5 years ago

That's curious @Cameron-Micka as I was under the impression the bounding box renderer used the wireframe shader. The current wireframe shader isn't supported on Quest.

Cameron-Micka commented 5 years ago

It does look like it does, but it's just using the opaque border option on the MRTK/Standard shader. AFAIC the only gemoetry shaders in the MRTK are _MRTKWireframe and HandTriangles.

Alexees commented 5 years ago

@Cameron-Micka This is the log I receive from logcat:

09-05 12:11:23.038 10941 10989 E Unity   : The given primitive topology does not match with the topology expected by the geometry shader
09-05 12:11:23.038 10941 10989 E Unity   :
09-05 12:11:23.038 10941 10989 E Unity   : (Filename:  Line: 0)
09-05 12:11:23.038 10941 10989 E Unity   :
09-05 12:11:23.058 10941 10989 E Unity   : OPENGL NATIVE PLUG-IN ERROR: GL_INVALID_OPERATION: Operation illegal in current state
09-05 12:11:23.058 10941 10989 E Unity   :
09-05 12:11:23.058 10941 10989 E Unity   : (Filename: /Users/builduser/buildslave/unity/build/Runtime/GfxDevice/opengles/GfxDeviceGLES.cpp Line: 340)

I guess my mistake was, to reduce runtime performance the moment I activate the BoundingBox the first time, I was under the impression, the Wireframe material from the Toolkit would go into the Wireframe slot of the BoundingBox. I was not aware that it was using a different shader. So @SimonDarksideJ was right about the usage of geometry shaders afterall

Cameron-Micka commented 5 years ago

Oh! Yeah that property name might be misleading. The wireframe material property usually takes another non traditional wireframe material (you can see which one in the BondingBox example scene).

This might be a good bug to send to Unity they should gracefully handle the loading of shader’s not available for the current platform.

Alexees commented 5 years ago

Funny enough, when running just the wireframe shader on a cube in an empty project/ scene, the error is different:

09-06 09:06:19.434  4427  4444 D Unity   : WARNING: Shader
09-06 09:06:19.434  4427  4444 D Unity   : Unsupported: 'Mixed Reality Toolkit/Wireframe' - Pass '' has no vertex shader
Cameron-Micka commented 5 years ago

Ha, weird. Does this built-in geometry shader cause the same issue? https://github.com/TwoTailsGames/Unity-Built-in-Shaders/blob/master/DefaultResourcesExtra/VR/Shaders/SpatialMappingWireframe.shader

SimonDarksideJ commented 5 years ago

Yes, that is the base shader we were using in the XRTK too, it also fails. Any geometry shader will fail on Oculus

Alexees commented 5 years ago

Just to round up, what's the solution here? Is there a way of providing a Android specific shader pass, or is this a problem Unity needs to fix? I'd gladly report a bug if I knew what bug it actually is, in detail.

Cameron-Micka commented 5 years ago

I would recommend trying to solve this issue from two directions. First try using just the HoloLens2 bounding box materials (they can be seen used in the BoundingBox and HandInteraction example scenes). Since they don’t use a geometry shader they “should work.” I would also recommend notifying Unity of a bug where the engine doesn’t seem to gracefully handle when loading an unsupported shader type (geometry shader) on Oculus Quest. I can also try to repo this locally next week.

Alexees commented 5 years ago

Guys, the shader works. With #5908 applied errors are gone and a cube the shader is applied to, shows the wireframe properly. Since the fallback shader is the default diffuse, seeing the triangles makes this clear. The above screenshot ahows the instantiated the shader at runtime since I wasn't using any ShaderVariantCollection and maybe broke because if this.

Bottom line, Oculus Quest supports geometry shaders

SimonDarksideJ commented 5 years ago

That would be awesome if it does indeed work. Gonna grab it and begin testing.

Curious if you say the Quest supports geometry shaders as Oculus says it doesn't :P But if it works, I'm certainly not going to argue :D

Alexees commented 5 years ago

If it doesn't then I completely lost my mind on this stuff. I had a wireframed cube on the quest and unless it's the diffuse shader, a hidden pass, UnityMagicShaderCrossCompiler or whatnot, the geometry shader did that.

Cameron-Micka commented 5 years ago

That’s great to hear! Do you have a screenshot of the wireframe cube? Just curious since the default bounding box materials aren’t usually configured to be wireframe.

Alexees commented 5 years ago

It's really just the MRKT_Wireframe.shader that I accidentially plugged into the BoundingBox, which kicked off the whole "does not work" process, but I think this Oculus Quest screenshot is proof, that it really works despite all assumptions about geometry shader support:

image

P.S.: i cranked the line width up quite a bit.

Cameron-Micka commented 5 years ago

Awesome! That does appear to be working on Quest. Thanks for taking a look at this.

SimonDarksideJ commented 5 years ago

I've just tested the exact same shader in a clean project, and no joy. Object with the shader material on it does not render. Can you share the rest of your Android project setup @Alexees please.

P.S. the shader we already had in the XRTK was already using the keyword that was added to the MRTK shader.

SimonDarksideJ commented 5 years ago

Check the PR, after a LOT of testing, this fix only works in a non-MRTK solution. Once you have MRTK active in your scene, it breaks. SO it must be something to do with the camera settings the MRTK is applying. The same effect is in XRTK, so likely something common.

xtr33me commented 4 years ago

Found this trying to research a similar issue to that with which the OP stated and just wanted to add a bit more info regarding the Quest hardware. It is running the Adreno 540 GPU which supports GLES 3.2 and therefore does support geometry shaders. I have seen some that have had no issues running certain geometry shaders, but there is definitely still an issue as I'm dealing with the black screen and neon colored objects in one eye. Should I figure out what part of the GS is causing this I will post here.

stale[bot] commented 4 years ago

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] commented 4 years ago

This issue has been closed by an automated process because it is stale. If this is still an issue please add a new comment with more recent details and repro steps.

keveleigh commented 4 years ago

@RogPodge, could be worth validating this now that #8088 has gone in

RogPodge commented 4 years ago

Confirmed to be working now :)