Ejemplo n.º 1
0
    void OnBeginCamera(ScriptableRenderContext scriptable, Camera camera)
    {
        if (!RenderingSingleCamera(camera))
        {
            return;
        }
        if (!gotOrig)
        {
            gotOrig     = true;
            origTexture = myCam.targetTexture;
        }
        // Not quite sure why this fixes things, but it does.
        // Idea from https://forum.unity.com/threads/rendering-to-vr-viewport-in-srp.756812/
        var texture = display.GetRenderTextureForRenderPass(0);

        myCam.targetTexture = texture;
    }
Ejemplo n.º 2
0
        void DisplayRenderTextures(XRDisplaySubsystem displaySubsystem)
        {
            RenderTexture rt = displaySubsystem.GetRenderTextureForRenderPass(s_renderPass.renderPassIndex);

            if (rt == null)
            {
                return;
            }

            int           rpc    = s_renderPass.GetRenderParameterCount();
            RenderTexture target = new RenderTexture(rt.width, rt.height, rt.depth);

            Graphics.CopyTexture(rt, 0, target, 0);
            EditorGUILayout.BeginHorizontal();

            Rect r = EditorGUILayout.GetControlRect(false, textureImageHeight,
                                                    GUILayout.MaxWidth(textureImageWidth + textureImageLeftPadding),
                                                    GUILayout.Width(textureImageWidth),
                                                    GUILayout.MaxHeight(textureImageHeight + textureImageSpace));

            EditorGUI.DrawPreviewTexture(r, target);

            if (rpc > 1)
            {
                Graphics.CopyTexture(rt, 1, target, 0);

                r = EditorGUILayout.GetControlRect(false, textureImageHeight,
                                                   GUILayout.MaxWidth(textureImageWidth + textureImageLeftPadding),
                                                   GUILayout.Width(textureImageWidth),
                                                   GUILayout.MaxHeight(textureImageHeight + textureImageSpace));


                EditorGUI.DrawPreviewTexture(r, target);
            }
            target.DiscardContents();
            target.Release();

            EditorGUILayout.EndHorizontal();
        }