Exemplo n.º 1
0
        private void Awake()
        {
            bool flag = SystemInfo.graphicsDeviceType == GraphicsDeviceType.Null;

            if (flag)
            {
                AmplifyUtils.DebugLog("Null graphics device detected. Skipping effect silently.", LogType.Error);
                this.silentError = true;
                return;
            }
            if (!AmplifyUtils.IsInitialized)
            {
                AmplifyUtils.InitializeIds();
            }
            for (int i = 0; i < 6; i++)
            {
                this.m_tempDownsamplesSizes[i] = new Vector2(0f, 0f);
            }
            this.m_cameraTransform  = base.transform;
            this.m_tempFilterBuffer = null;
            this.m_starburstMat     = Matrix4x4.identity;
            if (this.m_temporalFilteringCurve == null)
            {
                this.m_temporalFilteringCurve = new AnimationCurve(new Keyframe[]
                {
                    new Keyframe(0f, 0f),
                    new Keyframe(1f, 0.999f)
                });
            }
            this.m_bloomShader = Shader.Find("Hidden/AmplifyBloom");
            if (this.m_bloomShader != null)
            {
                this.m_bloomMaterial           = new Material(this.m_bloomShader);
                this.m_bloomMaterial.hideFlags = HideFlags.DontSave;
            }
            else
            {
                AmplifyUtils.DebugLog("Main Bloom shader not found", LogType.Error);
                base.gameObject.SetActive(false);
            }
            this.m_finalCompositionShader = Shader.Find("Hidden/BloomFinal");
            if (this.m_finalCompositionShader != null)
            {
                this.m_finalCompositionMaterial = new Material(this.m_finalCompositionShader);
                if (!this.m_finalCompositionMaterial.GetTag(AmplifyUtils.ShaderModeTag, false).Equals(AmplifyUtils.ShaderModeValue))
                {
                    if (this.m_showDebugMessages)
                    {
                        AmplifyUtils.DebugLog("Amplify Bloom is running on a limited hardware and may lead to a decrease on its visual quality.", LogType.Warning);
                    }
                }
                else
                {
                    this.m_softMaxdownscales = 6;
                }
                this.m_finalCompositionMaterial.hideFlags = HideFlags.DontSave;
                if (this.m_lensDirtTexture == null)
                {
                    this.m_lensDirtTexture = this.m_finalCompositionMaterial.GetTexture(AmplifyUtils.LensDirtRTId);
                }
                if (this.m_lensStardurstTex == null)
                {
                    this.m_lensStardurstTex = this.m_finalCompositionMaterial.GetTexture(AmplifyUtils.LensStarburstRTId);
                }
            }
            else
            {
                AmplifyUtils.DebugLog("Bloom Composition shader not found", LogType.Error);
                base.gameObject.SetActive(false);
            }
            this.m_camera = base.GetComponent <Camera>();
            this.m_camera.depthTextureMode |= DepthTextureMode.Depth;
            this.m_lensFlare.CreateLUTexture();
        }
Exemplo n.º 2
0
        void Awake()
        {
            bool nullDev = (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Null);

            if (nullDev)
            {
                AmplifyUtils.DebugLog("Null graphics device detected. Skipping effect silently.", LogType.Error);
                silentError = true;
                return;
            }

            if (!AmplifyUtils.IsInitialized)
            {
                AmplifyUtils.InitializeIds();
            }

            m_anamorphicGlare.Init();
            m_lensFlare.Init();

            for (int i = 0; i < MaxDownscales; i++)
            {
                m_tempDownsamplesSizes[i] = new Vector2(0, 0);
            }
            m_cameraTransform  = transform;
            m_tempFilterBuffer = null;
            m_starburstMat     = Matrix4x4.identity;

            if (m_temporalFilteringCurve == null)
            {
                m_temporalFilteringCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(1, 0.999f));
            }

            m_bloomShader = Shader.Find("Hidden/AmplifyBloom");
            if (m_bloomShader != null)
            {
                m_bloomMaterial           = new Material(m_bloomShader);
                m_bloomMaterial.hideFlags = HideFlags.DontSave;
            }
            else
            {
                AmplifyUtils.DebugLog("Main Bloom shader not found", LogType.Error);
                gameObject.SetActive(false);
            }

            m_finalCompositionShader = Shader.Find("Hidden/BloomFinal");
            if (m_finalCompositionShader != null)
            {
                m_finalCompositionMaterial = new Material(m_finalCompositionShader);
                if (!m_finalCompositionMaterial.GetTag(AmplifyUtils.ShaderModeTag, false).Equals(AmplifyUtils.ShaderModeValue))
                {
                    if (m_showDebugMessages)
                    {
                        AmplifyUtils.DebugLog("Amplify Bloom is running on a limited hardware and may lead to a decrease on its visual quality.", LogType.Warning);
                    }
                }
                else
                {
                    m_softMaxdownscales = MaxDownscales;
                }

                m_finalCompositionMaterial.hideFlags = HideFlags.DontSave;
                if (m_lensDirtTexture == null)
                {
                    m_lensDirtTexture = m_finalCompositionMaterial.GetTexture(AmplifyUtils.LensDirtRTId);
                }

                if (m_lensStardurstTex == null)
                {
                    m_lensStardurstTex = m_finalCompositionMaterial.GetTexture(AmplifyUtils.LensStarburstRTId);
                }
            }
            else
            {
                AmplifyUtils.DebugLog("Bloom Composition shader not found", LogType.Error);
                gameObject.SetActive(false);
            }

            m_camera = GetComponent <Camera>();
            m_camera.depthTextureMode |= DepthTextureMode.Depth;
            m_lensFlare.CreateLUTexture();

#if TRIAL
            watermark = new Texture2D(4, 4)
            {
                hideFlags = HideFlags.HideAndDontSave
            };
            watermark.LoadImage(AmplifyBloom.Watermark.ImageData);
#endif
        }