mobfishgmbh / Cardboard-VR-Unity-SDK

Apache License 2.0
56 stars 11 forks source link

Scriptable render pipeline support #63

Closed Handicap closed 4 years ago

Handicap commented 4 years ago

Thanks for the great plugin while the main cardboard plugin project has features still in development (mainly GLES3/Vulkan/Metal support)!

I tested the plugin with different setups and with scriptable rendering pipeline in use, there is no call for OnPostRender() function. This means that the plugin doesn't work out-of-the-box with SRP. This is however was easy to remedy by modifying the following to replace the OnPostRender() in CardboardPostCamera.cs:

    void OnEnable()
    {
        RenderPipelineManager.endFrameRendering += RenderEnd;
    }

    // removing the callbacks makes it more convinient and safer, 
    // they might still be called in editor or after object destruction
    private void OnDisable()         {
        RenderPipelineManager.endFrameRendering -= RenderEnd;
    }

    private void RenderEnd(ScriptableRenderContext arg1, Camera[] arg2)
    {
        if (!CardboardManager.profileAvailable)
            return;

        eyeMaterialLeft.SetPass(0);
        Graphics.DrawMeshNow(CardboardManager.viewMeshLeft, transform.position, transform.rotation);
        eyeMaterialRight.SetPass(0);
        Graphics.DrawMeshNow(CardboardManager.viewMeshRight, transform.position, transform.rotation);
    }

This could be somehow incorporated to the plugin so there would be no need to change the contents manually, however the fix is quite simple to do if the developer knows about the differences between calls with old Unity pipeline and SRP.

hawkwood commented 4 years ago

Here is from my fork which automatically checks if SRP is used.

https://github.com/hawkwood/Cardboard-VR-Unity-SDK/blob/public_dev/Assets/Cardboard/Scripts/Behaviours/CardboardPostCamera.cs

cdytoby commented 4 years ago

Note for me, android ndk:

https://forum.unity.com/threads/android-ndk-missing.689122/

cdytoby commented 4 years ago

@hawkwood Thank you for the code

@Handicap I merged it to branch public_dev, you can check it out and give me feedback if it works for you.

cdytoby commented 4 years ago

Forget about the branch. I just released a new pre-release version, you can use the unitypackage to test if it works.

cdytoby commented 4 years ago

I released Version 1.0 and URP is supported.

I'm going to close this ticket. If issue still persists, you can reopen this ticket, or create a new one.