コード例 #1
0
        private void OnEnable()
        {
#if UNITY_EDITOR
            if (!UnityEditor.EditorApplication.isPlaying)
            {
                return;
            }
#endif

            if (dbgData == null)
            {
                dbgData = new DebugData(this);
            }

            Init();

            StartCoroutine(AdaptiveTask());
#if UNITY_2019_1_OR_NEWER && UNITY_POST_PROCESSING_STACK_V2 && (SSAA_HDRP || SSAA_LWRP)
            // only on SRP
            if (!MadGoatSSAA_Utils.DetectSRP())
            {
                return;
            }
            //UnityEngine.Experimental.Rendering.RenderPipeline.BeginCameraRendering(GetComponent<Camera>());
            UnityEngine.Experimental.Rendering.RenderPipeline.beginCameraRendering += OnBeginCameraRender;
#elif UNITY_2018_1_OR_NEWER && UNITY_POST_PROCESSING_STACK_V2 && (SSAA_HDRP || SSAA_LWRP)
            // only on SRP
            if (!MadGoatSSAA_Utils.DetectSRP())
            {
                return;
            }
            RenderPipeline.BeginCameraRendering(GetComponent <Camera>());
            RenderPipeline.beginCameraRendering += OnBeginCameraRender;
#endif
        }
コード例 #2
0
 public void OnMainDisable()
 {
     if (!MadGoatSSAA_Utils.DetectSRP())
     {
         ClearCommand(CompositionCommand, CameraEvent.AfterImageEffects);
     }
 }
コード例 #3
0
        //private RenderTexture buff2;

        protected override void Init()
        {
            if (currentCamera == null)
            {
                currentCamera = GetComponent <Camera>();
            }

#if UNITY_2017_2_OR_NEWER
            UnityEngine.XR.XRSettings.eyeTextureResolutionScale = multiplier;
#else
            UnityEngine.VR.VRSettings.renderScale = multiplier;
#endif
            material_bl  = new Material(bilinearshader);
            material_bc  = new Material(bicubicshader);
            material_nn  = new Material(neighborshader);
            material_def = new Material(defaultshader);

            Material_current = material_def;
            Material_old     = Material_current;

            if (MadGoatSSAA_Utils.DetectSRP())
            {
                SetupSRPCB();
            }
            else
            {
                SetupStandardCB();
            }
        }
コード例 #4
0
        // Events from main renderer
        public void OnMainRender()
        {
            // Set up camera for hdrp
#if UNITY_2018_1_OR_NEWER && UNITY_POST_PROCESSING_STACK_V2 && SSAA_HDRP
            if (MadGoatSSAA_Utils.DetectSRP())
            {
                HDAdditionalCameraData data     = GetComponent <HDAdditionalCameraData>();
                HDAdditionalCameraData dataMain = Main.GetComponent <HDAdditionalCameraData>();
                if (data == null)
                {
                    data = Current.gameObject.AddComponent <HDAdditionalCameraData>();
                }
                data.clearColorMode  = HDAdditionalCameraData.ClearColorMode.None;
                data.clearDepth      = true;
                data.volumeLayerMask = 0;
            }
#endif


            // set up command buffers
            if (MadGoatSSAA_Utils.DetectSRP())
            {
                // for SRP
                UpdateCBSRP();
            }
            else
            {
                // for legacy
                UpdateCB();
            }
        }
コード例 #5
0
        // Command buffer setup
        private void SetupCommand(CommandBuffer cb, CameraEvent evt)
        {
            // setup command
            cb.Clear();
            cb.name = "SSAA_COMPOSITION";

            // setup pass and blit
            RenderTargetIdentifier idBuff = new RenderTargetIdentifier(Main.targetTexture);

            cb.SetRenderTarget(BuiltinRenderTextureType.CameraTarget);
            cb.Blit(idBuff, BuiltinRenderTextureType.CameraTarget, MaterialCurrent, 0);

            // add to camera - todo hdrp
            var commands = new List <CommandBuffer>(Current.GetCommandBuffers(evt));

            if (commands.Find(x => x.name == "SSAA_COMPOSITION") == null)
            {
                if (!MadGoatSSAA_Utils.DetectSRP())
                {
                    Current.AddCommandBuffer(evt, cb);
                }
                else
                {
                    // --- Prep for v2 native HDRP support
                    // Injection into render context goes here
                }
            }
        }
コード例 #6
0
        public override void OnInspectorGUI()
        {
            SetupStyles();
            // Update the serializedProperty - always do this in the beginning of OnInspectorGUI.
            serObj.Update();

            EditorGUILayout.Separator();

            GUI.backgroundColor = new Color(.4f, .4f, .4f, 1);
            GUILayout.Label("MadGoat SuperSampling", accent_style);
            GUI.backgroundColor = new Color(1, 1, 1, 1);
            //GUILayout.Label(Title, accent_style);
            //EditorGUILayout.Separator();

            if (MadGoatSSAA_Utils.DetectSRP())
            {
                EditorGUILayout.HelpBox("SRP support is currently in beta, and will stay so until Unity SRP system releases as a \"stable\" version. Please read the notes below first!!!", MessageType.Error);
                if (GUILayout.Button("SSAA on SRP Readme"))
                {
                    Application.OpenURL("https://drive.google.com/open?id=1gSpTziE5woQ53tTmlailiukkNZIej1CAqWA43yjJ_LY");
                }
                //EditorGUILayout.Separator();
                //EditorGUILayout.Separator();
                //EditorGUILayout.HelpBox("(HDRP BETA) \nEnable this if the image gets flipped upside down when using HDRP pipeline. The issues is currently investigated", MessageType.Error);
                //flipImageFix.boolValue = EditorGUILayout.Toggle("Fix HDRP image flipping", flipImageFix.boolValue);
                EditorGUILayout.Separator();
                EditorGUILayout.Separator();
            }
            samplingTab = GUILayout.Toolbar(samplingTab, new string[] { "SSAA", "Screenshot", "Misc" });
            EditorGUILayout.Separator();
            DrawHeader(new string[] { "Super Sampling Settings", "Screenshot Settings", "Misc Settings" }[samplingTab]);
            EditorGUILayout.Separator();
            EditorGUILayout.Separator();
            switch (samplingTab)
            {
            case 0:
                DrawTab1();
                break;

            case 1:
                DrawTab2();
                break;

            case 2:
                DrawTab3();
                break;
            }
            normal_style.fontSize = 9;
            EditorGUILayout.Separator();
            GUILayout.Label("Version: " + MadGoatSSAA_Utils.ssaa_version, normal_style);
            normal_style.fontSize = 16;
            // Apply modifications
            serObj.ApplyModifiedProperties();
        }
コード例 #7
0
 public void OnMainDisable()
 {
     if (!MadGoatSSAA_Utils.DetectSRP())
     {
         if ((new List <CommandBuffer>(Current.GetCommandBuffers(CameraEvent.AfterEverything))).Find(x => x.name == "SSAA_COMPOSITION") != null)
         {
             Current.RemoveCommandBuffer(CameraEvent.AfterEverything, CopyCB);
         }
         copyCB.Clear();
     }
 }
コード例 #8
0
        protected override void OnBeginCameraRender(Camera cam)
        {
            if (cam != currentCamera || !enabled)
            {
                return;
            }

#if UNITY_EDITOR
            if (!UnityEditor.EditorApplication.isPlaying)
            {
                return;
            }
#endif

            try
            {
                // Handle the resolution multiplier
#if UNITY_2017_2_OR_NEWER
                if (!UnityEngine.XR.XRDevice.isPresent)
                {
                    throw new Exception("VRDevice not present or not detected");
                }
                UnityEngine.XR.XRSettings.eyeTextureResolutionScale = multiplier;
#else
                if (!UnityEngine.VR.VRDevice.isPresent)
                {
                    throw new Exception("VRDevice not present or not detected");
                }
                UnityEngine.VR.VRSettings.renderScale = multiplier;
#endif

                // Change the material by the filter type
                ChangeMaterial(filterType);

                // Update the materials properties
                if (MadGoatSSAA_Utils.DetectSRP())
                {
                    UpdateSRPCB();
                }
                else
                {
                    UpdateSdanrdardCB();
                }
            }
            catch (Exception ex)
            {
                Debug.LogError("Something went wrong. SSAA has been set to off and the plugin was disabled");
                Debug.LogError(ex);
                SetAsSSAA(SSAAMode.SSAA_OFF);
                enabled = false;
            }
        }
コード例 #9
0
        // Events from main behaviour
        public void OnMainEnable()
        {
            mainComponent   = Main.GetComponent <MadGoatSSAA>();
            MaterialCurrent = materialDefault;

            if (MadGoatSSAA_Utils.DetectSRP())
            {
                SetupCBSRP();
            }
            else
            {
                SetupCommand(CompositionCommand, CameraEvent.AfterImageEffects);
            }
        }
コード例 #10
0
        // Events from main behaviour
        public void OnMainEnable()
        {
            mainComponent    = Main.GetComponent <MadGoatSSAA>();
            material_bl      = new Material(bilinearshader);
            material_bc      = new Material(bicubicshader);
            material_nn      = new Material(neighborshader);
            material_def     = new Material(defaultshader);
            Material_current = material_def;

            if (MadGoatSSAA_Utils.DetectSRP())
            {
                SetupCBSRP();
            }
            else
            {
                SetupCB();
            }
        }
コード例 #11
0
        private void OnDisable()
        {
#if UNITY_EDITOR
            if (!UnityEditor.EditorApplication.isPlaying)
            {
                return;
            }
#endif
            // Handle VR device cleaning
#if UNITY_2017_2_OR_NEWER
            UnityEngine.XR.XRSettings.eyeTextureResolutionScale = 1f;
#else
            UnityEngine.VR.VRSettings.renderScale = 1f;
#endif
            // Handle cleaning
            if (MadGoatSSAA_Utils.DetectSRP())
            {
                ClearSRPCB();
            }
            else
            {
                ClearStandardCB();
            }

            // Handle SRP render event cleaning
#if UNITY_2019_1_OR_NEWER && UNITY_POST_PROCESSING_STACK_V2 && (SSAA_HDRP || SSAA_LWRP)
            // only on SRP
            if (!MadGoatSSAA_Utils.DetectSRP())
            {
                return;
            }
            UnityEngine.Experimental.Rendering.RenderPipeline.beginCameraRendering -= OnBeginCameraRender;
#elif UNITY_2018_1_OR_NEWER && UNITY_POST_PROCESSING_STACK_V2 && (SSAA_HDRP || SSAA_LWRP)
            // only on SRP
            if (!MadGoatSSAA_Utils.DetectSRP())
            {
                return;
            }
            RenderPipeline.beginCameraRendering -= OnBeginCameraRender;
#endif
        }
コード例 #12
0
        private void ClearCommand(CommandBuffer cb, CameraEvent evt)
        {
            // clear command
            cb.Clear();

            // remove from camera
            var commands = new List <CommandBuffer>(Current.GetCommandBuffers(evt));

            if (commands.Find(x => x.name == "SSAA_COMPOSITION") != null)
            {
                if (!MadGoatSSAA_Utils.DetectSRP())
                {
                    Current.RemoveCommandBuffer(evt, cb);
                }
                else
                {
                    // --- Prep for v2 native HDRP support
                    // Injection into render context goes here
                }
            }
        }