/// <summary>
        /// Called by the capture task.
        /// This is where the window is captured and copied to the render image.
        /// </summary>
        private void CaptureWindow()
        {
            var token      = m_cancellationTokenSource.Token;
            var dispatcher = Application.Current.Dispatcher;

            var updateViewport = new UpdateViewport((data) =>
            {
                RenderImage.Source = data;
            });

            var captureHandle = m_captureWindowHandle;

            using (var captureWindow = new GdiWindowCapture(captureHandle))
            {
                while (!token.IsCancellationRequested)
                {
                    var startTime = DateTime.Now;

                    captureWindow.CaptureWindow(
                        windowImage =>
                    {
                        // Jump back to the application dispatcher to set the actual image source
                        dispatcher.BeginInvoke(DispatcherPriority.Render, updateViewport, windowImage);
                    }
                        );

                    var captureTime = DateTime.Now - startTime;

                    // Offset wait time with the amount of time it took to capture.
                    // This means we are limited to the update rate, but if capturing
                    // takes longer than a 'single frame' we don't stall.
                    var wait = m_updateRate - captureTime.Milliseconds;
                    while ((--wait) >= 0)
                    {
                        Thread.Sleep(1);
                        if (token.IsCancellationRequested)
                        {
                            return;
                        }
                    }
                }
            }
        }
    void SetMatProperties()
    {
        updateViewportRef = camerasGO[0].GetComponent<RefHelper>().ldRendTex.gameObject.GetComponent<UpdateViewport>();
        for (int i = 0; i < 8; i++)     //supply all the required information to the shader
        {
            foveatedMultiscopyMat.SetTexture("_ViewTex" + (i + 1), camerasGO[i].GetComponent<RefHelper>().screenRendTex.rendTex);
            foveatedMultiscopyMat.SetTexture("_LDViewTex" + (i + 1), camerasGO[i].GetComponent<RefHelper>().ldRendTex.rendTex);
        }
        foveatedMultiscopyMat.SetInt("_WidthRes", Screen.width);
        foveatedMultiscopyMat.SetInt("_HeightRes", Screen.height);
        foveatedMultiscopyMat.SetInt("_LDWidthRes", (int)(updateViewportRef.highPolyCamDimensions.x));
        foveatedMultiscopyMat.SetInt("_LDHeightRes", (int)(updateViewportRef.highPolyCamDimensions.y));

        foveatedMultiscopyMat.SetFloat("_multiplX", 1.0f / (float)((Screen.width * 3) / 8));
        foveatedMultiscopyMat.SetFloat("_multiplY", 1.0f / (float)(Screen.height));
        foveatedMultiscopyMat.SetFloat("_LDmultiplX", 1.0f / (float)((updateViewportRef.highPolyCamDimensions.x * 3) / 8));
        foveatedMultiscopyMat.SetFloat("_LDmultiplY", 1.0f / (float)(updateViewportRef.highPolyCamDimensions.y));

        foveatedMultiscopyMat.SetFloat("_LDRegionResolutionMultiplier", updateViewportRef.regionResolutionMultiplier);
        RefreshCameras();   // it sets the cameras appropriately
    }
    void SetMatProperties()
    {
        updateViewportRef = camerasGO[0].GetComponent <RefHelper>().ldRendTex.gameObject.GetComponent <UpdateViewport>();
        for (int i = 0; i < 8; i++)     //supply all the required information to the shader
        {
            foveatedMultiscopyMat.SetTexture("_ViewTex" + (i + 1), camerasGO[i].GetComponent <RefHelper>().screenRendTex.rendTex);
            foveatedMultiscopyMat.SetTexture("_LDViewTex" + (i + 1), camerasGO[i].GetComponent <RefHelper>().ldRendTex.rendTex);
        }
        foveatedMultiscopyMat.SetInt("_WidthRes", Screen.width);
        foveatedMultiscopyMat.SetInt("_HeightRes", Screen.height);
        foveatedMultiscopyMat.SetInt("_LDWidthRes", (int)(updateViewportRef.highPolyCamDimensions.x));
        foveatedMultiscopyMat.SetInt("_LDHeightRes", (int)(updateViewportRef.highPolyCamDimensions.y));

        foveatedMultiscopyMat.SetFloat("_multiplX", 1.0f / (float)((Screen.width * 3) / 8));
        foveatedMultiscopyMat.SetFloat("_multiplY", 1.0f / (float)(Screen.height));
        foveatedMultiscopyMat.SetFloat("_LDmultiplX", 1.0f / (float)((updateViewportRef.highPolyCamDimensions.x * 3) / 8));
        foveatedMultiscopyMat.SetFloat("_LDmultiplY", 1.0f / (float)(updateViewportRef.highPolyCamDimensions.y));

        foveatedMultiscopyMat.SetFloat("_LDRegionResolutionMultiplier", updateViewportRef.regionResolutionMultiplier);
        RefreshCameras();   // it sets the cameras appropriately
    }
Beispiel #4
0
    void SetMatProperties()
    {
        stereoscopicInterlacedMat.SetTexture("_ViewTexLeft", leftCam.GetComponent <RefHelper>().screenRendTex.rendTex); //supply all the required information to the shader
        stereoscopicInterlacedMat.SetTexture("_ViewTexRight", rightCam.GetComponent <RefHelper>().screenRendTex.rendTex);

        stereoscopicInterlacedMat.SetTexture("_LDViewTexLeft", leftCam.GetComponent <RefHelper>().ldRendTex.rendTex);
        stereoscopicInterlacedMat.SetTexture("_LDViewTexRight", rightCam.GetComponent <RefHelper>().ldRendTex.rendTex);

        stereoscopicInterlacedMat.SetInt("_WidthRes", Screen.width);
        stereoscopicInterlacedMat.SetInt("_HeightRes", Screen.height);
        stereoscopicInterlacedMat.SetInt("_LDWidthRes", (int)(leftCam.GetComponent <RefHelper>().ldRendTex.gameObject.GetComponent <UpdateViewport>().highPolyCamDimensions.x));
        stereoscopicInterlacedMat.SetInt("_LDHeightRes", (int)(leftCam.GetComponent <RefHelper>().ldRendTex.gameObject.GetComponent <UpdateViewport>().highPolyCamDimensions.y));

        stereoscopicInterlacedMat.SetFloat("_multiplX", 1.0f / (float)((Screen.width / 2)));
        stereoscopicInterlacedMat.SetFloat("_multiplY", 1.0f / (float)(Screen.height));
        stereoscopicInterlacedMat.SetFloat("_LDmultiplX", 1.0f / (float)((leftCam.GetComponent <RefHelper>().ldRendTex.gameObject.GetComponent <UpdateViewport>().highPolyCamDimensions.x)));
        stereoscopicInterlacedMat.SetFloat("_LDmultiplY", 1.0f / (float)(leftCam.GetComponent <RefHelper>().ldRendTex.gameObject.GetComponent <UpdateViewport>().highPolyCamDimensions.y));

        stereoscopicInterlacedMat.SetFloat("_LDRegionResolutionMultiplier", leftCam.GetComponent <RefHelper>().ldRendTex.gameObject.GetComponent <UpdateViewport>().regionResolutionMultiplier);

        updateViewportRef = leftCam.GetComponent <RefHelper>().ldRendTex.gameObject.GetComponent <UpdateViewport>();
        RefreshCameras();
        GetComponent <Camera>().enabled = true;
    }
    void SetMatProperties()
    {
        stereoscopicInterlacedMat.SetTexture("_ViewTexLeft", leftCam.GetComponent<RefHelper>().screenRendTex.rendTex); //supply all the required information to the shader
        stereoscopicInterlacedMat.SetTexture("_ViewTexRight", rightCam.GetComponent<RefHelper>().screenRendTex.rendTex);

        stereoscopicInterlacedMat.SetTexture("_LDViewTexLeft", leftCam.GetComponent<RefHelper>().ldRendTex.rendTex);
        stereoscopicInterlacedMat.SetTexture("_LDViewTexRight", rightCam.GetComponent<RefHelper>().ldRendTex.rendTex);

        stereoscopicInterlacedMat.SetInt("_WidthRes", Screen.width);
        stereoscopicInterlacedMat.SetInt("_HeightRes", Screen.height);
        stereoscopicInterlacedMat.SetInt("_LDWidthRes", (int)(leftCam.GetComponent<RefHelper>().ldRendTex.gameObject.GetComponent<UpdateViewport>().highPolyCamDimensions.x));
        stereoscopicInterlacedMat.SetInt("_LDHeightRes", (int)(leftCam.GetComponent<RefHelper>().ldRendTex.gameObject.GetComponent<UpdateViewport>().highPolyCamDimensions.y));

        stereoscopicInterlacedMat.SetFloat("_multiplX", 1.0f / (float)((Screen.width / 2)));
        stereoscopicInterlacedMat.SetFloat("_multiplY", 1.0f / (float)(Screen.height));
        stereoscopicInterlacedMat.SetFloat("_LDmultiplX", 1.0f / (float)((leftCam.GetComponent<RefHelper>().ldRendTex.gameObject.GetComponent<UpdateViewport>().highPolyCamDimensions.x)));
        stereoscopicInterlacedMat.SetFloat("_LDmultiplY", 1.0f / (float)(leftCam.GetComponent<RefHelper>().ldRendTex.gameObject.GetComponent<UpdateViewport>().highPolyCamDimensions.y));

        stereoscopicInterlacedMat.SetFloat("_LDRegionResolutionMultiplier", leftCam.GetComponent<RefHelper>().ldRendTex.gameObject.GetComponent<UpdateViewport>().regionResolutionMultiplier);

        updateViewportRef = leftCam.GetComponent<RefHelper>().ldRendTex.gameObject.GetComponent<UpdateViewport>();
        RefreshCameras();
        GetComponent<Camera>().enabled = true;
    }