Example #1
0
        void SetCameraFlag()
        {
            if (mode == oldMode)
            {
                return;
            }

            if (oldMode == EdgeDetectMode.SobelDepth || oldMode == EdgeDetectMode.SobelDepthThin)
            {
                ImageEffectManager.API_DeAttachCameraRenderFlags(m_Camera, ref flagReference);
            }
            else if (oldMode == EdgeDetectMode.TriangleDepthNormals || oldMode == EdgeDetectMode.RobertsCrossDepthNormals)
            {
                ImageEffectManager.API_DeAttachCameraRenderFlags(m_Camera, ref flagReference);
            }


            if (mode == EdgeDetectMode.SobelDepth || mode == EdgeDetectMode.SobelDepthThin)
            {
                flagReference = ImageEffectManager.API_AttachCameraRenderFlags(m_Camera, DepthTextureMode.Depth);
            }
            else if (mode == EdgeDetectMode.TriangleDepthNormals || mode == EdgeDetectMode.RobertsCrossDepthNormals)
            {
                flagReference = ImageEffectManager.API_AttachCameraRenderFlags(m_Camera, DepthTextureMode.DepthNormals);
            }

            oldMode = mode;
        }
Example #2
0
        public override bool CheckResources()
        {
            CheckSupport(false, true);

            Shader tonemapper = null;

            if (!tonemapper)
            {
                tonemapper = ImageEffectManager.API_GetShader("Hidden/Tonemapper");
            }

            tonemapMaterial = CheckShaderAndCreateMaterial(tonemapper, tonemapMaterial);
            if (!curveTex && type == TonemapperType.UserCurve)
            {
                curveTex            = new Texture2D(256, 1, TextureFormat.ARGB32, false, true);
                curveTex.filterMode = FilterMode.Bilinear;
                curveTex.wrapMode   = TextureWrapMode.Clamp;
                curveTex.hideFlags  = HideFlags.DontSave;
                curveTex.name       = "curveTex";
            }

            if (!isSupported)
            {
                ReportAutoDisable();
            }
            return(isSupported);
        }
Example #3
0
        public override void Awake()
        {
            InstanceList.Add(this);
            DissloveObj             = new GameObject();
            DissloveObj.name        = "DissloveGlowCamera";
            DissloveObj.hideFlags   = HideFlags.HideAndDontSave;
            DissloveCam             = DissloveObj.AddComponent <Camera>();
            DissloveCam.cullingMask = (1 << LayerMask.NameToLayer("LightingEffectOnly"));
            DissloveCam.enabled     = false;
            if (settings == null)
            {
                settings = new GlowSettings();
            }
            settings.baseResolution  = Resolution.Half;
            settings.boostStrength   = 3;
            settings.downsampleSteps = 1;

            HostCamera    = GetComponent <Camera>();
            highPrecision = _highPrecsion;

            if (Application.isPlaying)
            {
                Shader shader = ImageEffectManager.API_GetShader("ImageEffect/DissloveGlowMask");
                if (mat)
                {
                    Destroy(mat);
                    mat = null;
                }
                mat = new Material(shader);
            }

            base.Awake();
            InitRender();
            InitCamera();
        }
Example #4
0
        public override bool CheckResources()
        {
            CheckSupport(true);

            if (null == sunShaftsShader)
            {
                sunShaftsShader = ImageEffectManager.API_GetShader("ImageEffect/SunShaft/SunShaftsComposite");
            }
            if (null == simpleClearShader)
            {
                simpleClearShader = ImageEffectManager.API_GetShader("ImageEffect/Common/SimpleClear");
            }
            sunShaftsMaterial   = CheckShaderAndCreateMaterial(sunShaftsShader, sunShaftsMaterial);
            simpleClearMaterial = CheckShaderAndCreateMaterial(simpleClearShader, simpleClearMaterial);

            if (!isSupported)
            {
                ReportAutoDisable();
            }
            canUseMask = false;
            var skybox = RenderSettings.skybox;

            if (skybox)
            {
                if (skybox.HasProperty("_Tint"))
                {
                    canUseMask = true;
                }
            }
            return(isSupported);
        }
Example #5
0
        public void Init()
        {
            if (FogShader == null)
            {
                FogShader = ImageEffectManager.API_GetShader("ImageEffect/WarFog");
            }

            if (FogShader)
            {
                if (FogShader.isSupported)
                {
                    if (mat)
                    {
                        Destroy(mat);
                        mat = null;
                    }
                    mat = new Material(FogShader);
                    //mat.hideFlags = HideFlags.HideAndDontSave;
                }
                else
                {
                    enabled = false;
                }
            }
            else
            {
                enabled = false;
            }
        }
Example #6
0
        public bool prepareMaterials()
        {
            if (mAOShader == null)
            {
                mAOShader = ImageEffectManager.API_GetShader(k_ShaderString);

                if (mAOShader != null)
                {
                    if (mAOMat == null)
                    {
                        mAOMat           = new Material(mAOShader);
                        mAOMat.hideFlags = HideFlags.HideAndDontSave;
                    }
                }
            }

            if (mBlitShader == null)
            {
                mBlitShader = ImageEffectManager.API_GetShader(k_BlitShaderString);

                if (mBlitShader != null)
                {
                    if (mBlitMat == null)
                    {
                        mBlitMat           = new Material(mBlitShader);
                        mBlitMat.hideFlags = HideFlags.HideAndDontSave;
                    }
                }
            }

            return(mAOMat != null && mBlitMat != null);
        }
Example #7
0
 protected void API_AttachCameraRenderFlags(DepthTextureMode mod)
 {
     ImageEffectManager.CameraRenderFlagsNode reslut = ImageEffectManager.API_AttachCameraRenderFlags(m_Camera, mod);
     if (null != reslut)
     {
         flagReferenceList.Add(reslut);
     }
 }
Example #8
0
        public override bool CheckResources()
        {
            if (!shader)
            {
                shader = ImageEffectManager.API_GetShader("Hidden/FXAA Preset 2");
            }
            CheckSupport(true);

            if (mat == null)
            {
                mat = CheckShaderAndCreateMaterial(shader, mat);
            }

            if (!isSupported)
            {
                ReportAutoDisable();
            }

            //新的支持头顶文字不反锯齿
            if (topNameShader == null)
            {
                topNameShader = ImageEffectManager.API_GetShader("Effect/BillBoradFXAA");
            }

            if (blendShader == null)
            {
                blendShader = ImageEffectManager.API_GetShader("Hidden/BlendNameShader");
                blendMat    = CheckShaderAndCreateMaterial(blendShader, blendMat);
            }

            if (topNameCam == null)
            {
                obj        = new GameObject("CpyCam");
                topNameCam = obj.AddComponent <Camera>();
            }

            if (updateCamera)
            {
                obj.transform.position = gameObject.transform.position;
                obj.transform.rotation = gameObject.transform.rotation;

                topNameCam.CopyFrom(GetComponent <Camera>());
                topNameCam.renderingPath = RenderingPath.VertexLit;

                topNameCam.clearFlags      = CameraClearFlags.Color;
                topNameCam.backgroundColor = new Color(0, 0, 0, 0);
                topNameCam.enabled         = false;
                topNameCam.cullingMask     = LayerMask.GetMask("TopName"); //1 << 21;;
            }

            if (topNameShader == null)
            {
                Debug.Log("头顶文字Shader没有!!");
            }
            //end新的支持头顶文字不反锯齿

            return(isSupported);
        }
Example #9
0
        public static void API_SetDirty(Camera Cam)
        {
            ImageEffectManager result = GetImageEffectManager(Cam);

            if (result)
            {
                result.dirty = true;
            }
        }
Example #10
0
        public static void API_UnResigiterFoucusChage(Camera Cam, System.Action <bool> call)
        {
            ImageEffectManager result = GetImageEffectManager(Cam);

            if (result)
            {
                result.OnFoucusChange -= call;
            }
        }
Example #11
0
        public static void API_DeAttachCameraRenderFlags(Camera Cam, ref CameraRenderFlagsNode flags)
        {
            ImageEffectManager res = GetImageEffectManager(Cam);

            if (res)
            {
                res.DeAttachCameraRenderFlags(ref flags);
            }
        }
Example #12
0
        public static void API_Remove <T>(Camera Cam) where T : ImageEffectNode
        {
            ImageEffectManager result = GetImageEffectManager(Cam);

            if (result)
            {
                result.Remove <T>();
            }
        }
Example #13
0
        public static void API_SetImagEffectParam <T>(Camera cam, string paramName, float Val) where T : ImageEffectNode
        {
            ImageEffectManager result = GetImageEffectManager(cam);

            if (result)
            {
                result.SetImagEffectParam <T>(paramName, Val);
            }
        }
Example #14
0
        private static void API_Refetsh(Camera cam)
        {
            ImageEffectManager result = GetImageEffectManager(cam);

            if (result)
            {
                result.Refresh();
            }
        }
Example #15
0
        public static void API_InitSceneCamera(Camera Cam)
        {
            ImageEffectManager ime = Cam.GetComponent <ImageEffectManager>();

            if (ime)
            {
                ime.InitSceneCamera();
            }
        }
Example #16
0
        public static void API_ApplicationFocusChanged(Camera cam, bool value)
        {
            ImageEffectManager result = GetImageEffectManager(cam);

            if (result)
            {
                result.ApplicationFocusChanged(value);
            }
        }
Example #17
0
        public static void API_ClearSceneCamera(Camera Cam)
        {
            ImageEffectManager res = GetImageEffectManager(Cam);

            if (res)
            {
                res.ClearSceneCamera();
            }
        }
Example #18
0
        public static void API_EnableImageEffect(Camera Cam, Type t)
        {
            ImageEffectManager result = GetImageEffectManager(Cam);

            if (result)
            {
                result.EnableImageEffect(t);
            }
        }
Example #19
0
        public static void API_DisableImageEffect <T>(Camera Cam) where T : ImageEffectNode
        {
            ImageEffectManager result = GetImageEffectManager(Cam);

            if (result)
            {
                result.DisableImageEffect <T>();
            }
        }
Example #20
0
        public static void API_UpdatePlayer(Camera cam, GameObject hero)
        {
            ImageEffectManager result = GetImageEffectManager(cam);

            if (result)
            {
                result.hero = hero;
            }
        }
Example #21
0
        protected void DeAttachAllCameraRenderFlags()
        {
            for (int i = 0; i < flagReferenceList.Count; i++)
            {
                ImageEffectManager.CameraRenderFlagsNode nod = flagReferenceList[i];
                ImageEffectManager.API_DeAttachCameraRenderFlags(m_Camera, ref nod);
            }

            flagReferenceList.Clear();
        }
Example #22
0
 public void InitRender()
 {
     m_CommandBuffer      = new CommandBuffer();
     m_CommandBuffer.name = "GlowOutLineCommandBuffer";
     if (Application.isPlaying)
     {
         Shader s = ImageEffectManager.API_GetShader("Effect/Glow/GlowOutLineObjects");
         GlowOutLineMaterial = new Material(s);
     }
 }
Example #23
0
        public static T API_Add <T>(Camera Cam) where T : ImageEffectNode
        {
            ImageEffectManager result = GetImageEffectManager(Cam);

            if (result)
            {
                return(result.Add <T>());
            }
            return(null);
        }
Example #24
0
        public static List <ImageEffectNode> API_GetImangeEffectList(Camera cam)
        {
            ImageEffectManager result = GetImageEffectManager(cam);

            if (result)
            {
                return(result.AllImageEffeNodeList);
            }
            return(null);
        }
Example #25
0
        public override bool ImageEffect_RenderImage(RenderTexture source, RenderTexture destination, RenderBuffer depthBuffer)
        {
            if (!ImageEffects.ImageEffectManager.AdvanceImangeEffectEnabled)
            {
                return(false);
            }
            if (!CheckResources() || !IsOnValidLOD())
            {
                return(false);
            }

            // clamp & prepare values so they make sense

            if (aperture < 0.0f)
            {
                aperture = 0.0f;
            }
            if (maxBlurSize < 0.1f)
            {
                maxBlurSize = 0.1f;
            }
            focalSize         = Mathf.Clamp(focalSize, 0.0f, 2.0f);
            internalBlurWidth = Mathf.Max(maxBlurSize, 0.0f);

            // focal & coc calculations

            ImageEffectManager result = null;

            ImageEffectManager.ImageEffectManagerTable.TryGetValue(m_Camera, out result);

            if (result != null)
            {
                if (result.hero != null)
                {
                    focalTransform = result.hero.transform;
                }
            }
            focalDistance01 = (focalTransform) ? (m_Camera.WorldToViewportPoint(focalTransform.position)).z / (m_Camera.farClipPlane) : FocalDistance01(focalLength);
            dofHdrMaterial.SetVector("_CurveParams", new Vector4(1.0f, focalSize, aperture / 10.0f, focalDistance01));

            if (ShowFocus)
            {
                WriteCoc(source, true);
                Graphics.Blit(source, destination, dofHdrMaterial, 2);
            }
            else
            {
                source.filterMode = FilterMode.Bilinear;
                WriteCoc(source, true);
                dofHdrMaterial.SetTexture("_FgOverlap", null);
                dofHdrMaterial.SetVector("_Offsets", Vector4.one * (2 * internalBlurWidth));
                Graphics.Blit(source, destination, dofHdrMaterial, 1);
            }
            return(true);
        }
Example #26
0
        private static ImageEffectManager GetImageEffectManager(Camera cam)
        {
            ImageEffectManager result = null;

            if (cam)
            {
                ImageEffectManagerTable.TryGetValue(cam, out result);
            }

            return(result);
        }
Example #27
0
 public override void OnActive()
 {
     if (mode == EdgeDetectMode.SobelDepth || mode == EdgeDetectMode.SobelDepthThin)
     {
         flagReference = ImageEffectManager.API_AttachCameraRenderFlags(m_Camera, DepthTextureMode.Depth);
     }
     else if (mode == EdgeDetectMode.TriangleDepthNormals || mode == EdgeDetectMode.RobertsCrossDepthNormals)
     {
         flagReference = ImageEffectManager.API_AttachCameraRenderFlags(m_Camera, DepthTextureMode.DepthNormals);
     }
 }
Example #28
0
        private static Material CreateMaterial(string shadername)
        {
            if (string.IsNullOrEmpty(shadername))
            {
                return(null);
            }
            Material material = new Material(ImageEffectManager.API_GetShader(shadername));

            //material.hideFlags = HideFlags.HideAndDontSave;
            return(material);
        }
Example #29
0
        public static CameraRenderFlagsNode API_AttachCameraRenderFlags(Camera cam, DepthTextureMode mod)
        {
            CameraRenderFlagsNode reslut = null;
            ImageEffectManager    res    = GetImageEffectManager(cam);

            if (res)
            {
                reslut = res.AttachCameraRenderFlags(mod);
            }

            return(reslut);
        }
Example #30
0
        public override bool CheckResources()
        {
            CheckSupport(true);      // only requires depth, not HDR

            dofHdrMaterial = CheckShaderAndCreateMaterial(ImageEffectManager.API_GetShader("ImageEffect/DepthOfField"), dofHdrMaterial);

            if (!isSupported)
            {
                ReportAutoDisable();
            }

            return(isSupported);
        }