Ejemplo n.º 1
0
        private void OnPreRender()
        {
            if (!gameObject.activeSelf || !enabled)
            {
                return;
            }

            if (glowTexture != null)
            {
                RenderTexture.ReleaseTemporary(glowTexture);
                glowTexture = null;
            }

            if (GlowType == MKGlowType.Selective)
            {
                glowTexture = RenderTexture.GetTemporary((int)((GetComponent <Camera>().pixelWidth) / samples), (int)((GetComponent <Camera>().pixelHeight) / samples), 16, RenderTextureFormat.Default);
                SetupGlowCamera();
                SetupKeywords();
                GlowCamera.RenderWithShader(glowRenderShader, "RenderType");
            }
            else
            {
                if (GlowCamera)
                {
                    DestroyImmediate(GlowCamera);
                }
                if (GlowCameraObject)
                {
                    DestroyImmediate(GlowCameraObject);
                }
            }

            BlurMaterial.color = new Color(fullScreenGlowTint.r, fullScreenGlowTint.g, fullScreenGlowTint.b, glowIntensity);
        }
Ejemplo n.º 2
0
        private void OnPreRender()
        {
            if (!gameObject.activeSelf || !this.enabled)
            {
                return;
            }

            if (m_GlowTexture != null)
            {
                RenderTexture.ReleaseTemporary(m_GlowTexture);
                m_GlowTexture = null;
            }

            if (GlowType == MKGlowType.Selective)
            {
                m_GlowTexture = RenderTexture.GetTemporary((int)((this.GetComponent <Camera>().pixelWidth) / CalculateSamples(ref m_GlowResolution)), (int)((this.GetComponent <Camera>().pixelHeight) / CalculateSamples(ref m_GlowResolution)), 16);
                SetupGlowCamera();
                SetupKeywords();
                if (GlowCamera.actualRenderingPath != RenderingPath.VertexLit)
                {
                    GlowCamera.renderingPath = RenderingPath.VertexLit;
                }
                GlowCamera.RenderWithShader(this.m_GlowRenderShader, "RenderType");
            }
            else
            {
                if (GlowCamera)
                {
                    DestroyImmediate(GlowCamera);
                }
                if (GlowCameraObject)
                {
                    DestroyImmediate(GlowCameraObject);
                }
            }

            Mathf.Clamp(BlurSpread, 0.2f, 2f);
            Mathf.Clamp(BlurIterations, 0, 11);
            Mathf.Clamp(BlurOffset, 0.0f, 4.0f);
            Mathf.Clamp(Samples, 2, 16);
            Mathf.Clamp(GlowIntensity, 0f, 1f);
        }