예제 #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;
        }
예제 #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);
        }
예제 #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();
        }
예제 #4
0
파일: SunShafts.cs 프로젝트: zwong91/Titan
        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);
        }
예제 #5
0
파일: WarFog.cs 프로젝트: zwong91/Titan
        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;
            }
        }
예제 #6
0
파일: SSAOPro.cs 프로젝트: zwong91/Titan
        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);
        }
예제 #7
0
 protected void API_AttachCameraRenderFlags(DepthTextureMode mod)
 {
     ImageEffectManager.CameraRenderFlagsNode reslut = ImageEffectManager.API_AttachCameraRenderFlags(m_Camera, mod);
     if (null != reslut)
     {
         flagReferenceList.Add(reslut);
     }
 }
예제 #8
0
파일: FXAA.cs 프로젝트: zwong91/Titan
        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);
        }
예제 #9
0
        public static void API_SetDirty(Camera Cam)
        {
            ImageEffectManager result = GetImageEffectManager(Cam);

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

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

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

            if (result)
            {
                result.Remove <T>();
            }
        }
예제 #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);
            }
        }
예제 #14
0
        private static void API_Refetsh(Camera cam)
        {
            ImageEffectManager result = GetImageEffectManager(cam);

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

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

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

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

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

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

            if (result)
            {
                result.hero = hero;
            }
        }
예제 #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();
        }
예제 #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);
     }
 }
예제 #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);
        }
예제 #24
0
        public static List <ImageEffectNode> API_GetImangeEffectList(Camera cam)
        {
            ImageEffectManager result = GetImageEffectManager(cam);

            if (result)
            {
                return(result.AllImageEffeNodeList);
            }
            return(null);
        }
예제 #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);
        }
예제 #26
0
        private static ImageEffectManager GetImageEffectManager(Camera cam)
        {
            ImageEffectManager result = null;

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

            return(result);
        }
예제 #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);
     }
 }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }