Пример #1
0
        private void UpdateSdanrdardCB()
        {
            // fix for VR black screen
            Material_current.SetOverrideTag("RenderType", "Opaque");
            Material_current.SetInt("_SrcBlend", (int)BlendMode.One);
            Material_current.SetInt("_DstBlend", (int)BlendMode.Zero);
            Material_current.SetInt("_ZWrite", 1);
            Material_current.renderQueue = -1;

#if UNITY_2017_2_OR_NEWER
            Material_current.SetFloat("_ResizeWidth", UnityEngine.XR.XRSettings.eyeTextureWidth);
            Material_current.SetFloat("_ResizeHeight", UnityEngine.XR.XRSettings.eyeTextureHeight);
#else
            Material_current.SetFloat("_ResizeWidth", UnityEngine.VR.VRSettings.eyeTextureWidth);
            Material_current.SetFloat("_ResizeHeight", UnityEngine.VR.VRSettings.eyeTextureHeight);
#endif
            Material_current.SetFloat("_Sharpness", sharpness);
            Material_current.SetFloat("_SampleDistance", sampleDistance);

            FXAA_FSS_Mat.SetVector("_QualitySettings", new Vector3(1.0f, 0.063f, 0.0312f));
            FXAA_FSS_Mat.SetVector("_ConsoleSettings", new Vector4(0.5f, 2.0f, 0.125f, 0.04f));
            FXAA_FSS_Mat.SetFloat("_Intensity", fssaaIntensity);

            //Debug.Log(Material_current.shader.name);
        }
Пример #2
0
        private void SetupStandardCB()
        {
            processBuffer = new CommandBuffer();
            if ((new List <CommandBuffer>(currentCamera.GetCommandBuffers(CameraEvent.AfterEverything))).Find(x => x.name == "SSAA_VR_APPLY") == null)     // fix for VR black screen

            // fix for VR black screen
            {
                Material_current.SetOverrideTag("RenderType", "Opaque");
                Material_current.SetInt("_SrcBlend", (int)BlendMode.One);
                Material_current.SetInt("_DstBlend", (int)BlendMode.Zero);
                Material_current.SetInt("_ZWrite", 1);
                Material_current.renderQueue = -1;

                // set up buffer rt
                if (buff)
                {
                    buff.Release();
                }
                //if (buff2)
                //    buff2.Release();
#if UNITY_2017_2_OR_NEWER
                buff = new RenderTexture(UnityEngine.XR.XRSettings.eyeTextureWidth * 2, UnityEngine.XR.XRSettings.eyeTextureHeight, 24, RenderTextureFormat.ARGBHalf);
                //buff2 = new RenderTexture(UnityEngine.XR.XRSettings.eyeTextureWidth*2, UnityEngine.XR.XRSettings.eyeTextureHeight, 24, RenderTextureFormat.ARGBHalf);
#else
                buff = new RenderTexture(UnityEngine.VR.VRSettings.eyeTextureWidth, UnityEngine.VR.VRSettings.eyeTextureHeight, 24, RenderTextureFormat.ARGBHalf);
                //buff2 = new RenderTexture(UnityEngine.VR.VRSettings.eyeTextureWidth, UnityEngine.VR.VRSettings.eyeTextureHeight, 24, RenderTextureFormat.ARGBHalf);
#endif
                RenderTargetIdentifier buffId = new RenderTargetIdentifier(buff);
                //RenderTargetIdentifier buff2Id = new RenderTargetIdentifier(buff2);

                // fix for singlepass issue in u2018
#if UNITY_2017_2_OR_NEWER
                buff.vrUsage = UnityEngine.XR.XRSettings.eyeTextureDesc.vrUsage;
#endif
                // Setup Standard CB
                processBuffer.Clear();
                processBuffer.name = "SSAA_VR_APPLY";
                processBuffer.SetRenderTarget(BuiltinRenderTextureType.CameraTarget);

                // Downsampling
                processBuffer.Blit(BuiltinRenderTextureType.CameraTarget, buffId, Material_current, 0);

                // Final
                processBuffer.Blit(buffId, BuiltinRenderTextureType.CameraTarget, multiplier > 1 && ssaaUltra && renderMode != Mode.AdaptiveResolution ? FXAA_FSS_Mat : Material_def, 0);

                // Register cb to camera
                currentCamera.AddCommandBuffer(CameraEvent.AfterEverything, processBuffer);
            }
        }