microsoft / MixedReality-SpectatorView

Mixed reality spectator experiences
MIT License
193 stars 114 forks source link

Support LWRP/URP #328

Open Helco opened 4 years ago

Helco commented 4 years ago

I did not find an issue regarding Leightweight Render Pipeline, for the camera scenario at least it did not work for me. I debugged this issue down to two problems:

  1. TextureManager uses the OnPreRender/OnPostRender events by Unity which are not supported in LWRP. It seems to work when adding these lines in the Start method:
            RenderPipelineManager.beginCameraRendering += (_, cam) =>
            {
                if (cam == spectatorViewCamera)
                    OnPreRender();
            };
            RenderPipelineManager.endCameraRendering += (_, cam) =>
            {
                if (cam == spectatorViewCamera)
                    OnPostRender();
            };
  1. After that the output is mostly black because the alpha channel in the renderTexture is ignored in the HoloAlpha shader. I fixed it by modifying the blending to:
fixed4 composite = backCol * (1 - _Alpha * frontCol.a) + frontCol * _Alpha * frontCol.a;
chrisfromwork commented 4 years ago

With these two changes were you able to get yourself unblocked? Thank you for piecing together this in depth overview of the changes that are needed.

Helco commented 4 years ago

Yes with these changes I could use the SpectatorView in a LWRP project. I did not test LWRP to its full extent though.

Helco commented 4 years ago

Quick update as #327 and its beautiful! occlusion support broke my LWRP fix, these are the additional steps to take: