Example #1
0
 public override void OnDisable()
 {
     GraphicsUtils.Destroy(m_GradingCurves);
     GraphicsUtils.Destroy(model.bakedLut);
     m_GradingCurves = null;
     model.bakedLut  = null;
 }
Example #2
0
        public override void Prepare(Material uberMaterial)
        {
            GrainModel.Settings settings = base.model.settings;
            uberMaterial.EnableKeyword("GRAIN");
            float realtimeSinceStartup = Time.realtimeSinceStartup;
            float value  = Random.value;
            float value2 = Random.value;

            if (this.m_GrainLookupRT == null || !this.m_GrainLookupRT.IsCreated())
            {
                GraphicsUtils.Destroy(this.m_GrainLookupRT);
                this.m_GrainLookupRT = new RenderTexture(192, 192, 0, 2)
                {
                    filterMode = 1,
                    wrapMode   = 0,
                    anisoLevel = 0,
                    name       = "Grain Lookup Texture"
                };
                this.m_GrainLookupRT.Create();
            }
            Material material = this.context.materialFactory.Get("Hidden/Post FX/Grain Generator");

            material.SetFloat(GrainComponent.Uniforms._Phase, realtimeSinceStartup / 20f);
            Graphics.Blit(null, this.m_GrainLookupRT, material, (!settings.colored) ? 0 : 1);
            uberMaterial.SetTexture(GrainComponent.Uniforms._GrainTex, this.m_GrainLookupRT);
            uberMaterial.SetVector(GrainComponent.Uniforms._Grain_Params1, new Vector2(settings.luminanceContribution, settings.intensity * 20f));
            uberMaterial.SetVector(GrainComponent.Uniforms._Grain_Params2, new Vector4((float)this.context.width / (float)this.m_GrainLookupRT.width / settings.size, (float)this.context.height / (float)this.m_GrainLookupRT.height / settings.size, value, value2));
        }
Example #3
0
 // Token: 0x06003AF2 RID: 15090 RVA: 0x001C83DA File Offset: 0x001C67DA
 public override void OnDisable()
 {
     GraphicsUtils.Destroy(this.m_GradingCurves);
     GraphicsUtils.Destroy(base.model.bakedLut);
     this.m_GradingCurves = null;
     base.model.bakedLut  = null;
 }
Example #4
0
        public override void Prepare(Material uberMaterial)
        {
            GrainModel.Settings settings = base.model.settings;
            uberMaterial.EnableKeyword("GRAIN");
            float realtimeSinceStartup = Time.realtimeSinceStartup;
            float z = Random.value;
            float w = Random.value;

            if ((this.m_GrainLookupRT == null) || !this.m_GrainLookupRT.IsCreated())
            {
                GraphicsUtils.Destroy(this.m_GrainLookupRT);
                RenderTexture texture = new RenderTexture(0xc0, 0xc0, 0, RenderTextureFormat.ARGBHalf)
                {
                    filterMode = FilterMode.Bilinear,
                    wrapMode   = TextureWrapMode.Repeat,
                    anisoLevel = 0,
                    name       = "Grain Lookup Texture"
                };
                this.m_GrainLookupRT = texture;
                this.m_GrainLookupRT.Create();
            }
            Material mat = base.context.materialFactory.Get("Hidden/Post FX/Grain Generator");

            mat.SetFloat(Uniforms._Phase, realtimeSinceStartup / 20f);
            Graphics.Blit(null, this.m_GrainLookupRT, mat, !settings.colored ? 0 : 1);
            uberMaterial.SetTexture(Uniforms._GrainTex, this.m_GrainLookupRT);
            uberMaterial.SetVector(Uniforms._Grain_Params1, new Vector2(settings.luminanceContribution, settings.intensity * 20f));
            uberMaterial.SetVector(Uniforms._Grain_Params2, new Vector4((((float)base.context.width) / ((float)this.m_GrainLookupRT.width)) / settings.size, (((float)base.context.height) / ((float)this.m_GrainLookupRT.height)) / settings.size, z, w));
        }
Example #5
0
 public void Dispose()
 {
     foreach (KeyValuePair <string, Material> keyValuePair in this.m_Materials)
     {
         GraphicsUtils.Destroy(keyValuePair.Value);
     }
     this.m_Materials.Clear();
 }
Example #6
0
 public void Dispose()
 {
     Dictionary <string, Material> .Enumerator enumerator = this.m_Materials.GetEnumerator();
     while (enumerator.MoveNext())
     {
         KeyValuePair <string, Material> current = enumerator.Current;
         Material material = current.Value;
         GraphicsUtils.Destroy(material);
     }
     this.m_Materials.Clear();
 }
Example #7
0
        public void Dispose()
        {
            var enumerator = m_Materials.GetEnumerator();

            while (enumerator.MoveNext())
            {
                var material = enumerator.Current.Value;
                GraphicsUtils.Destroy(material);
            }

            m_Materials.Clear();
        }
 // Token: 0x06004070 RID: 16496 RVA: 0x00144E50 File Offset: 0x00143250
 public override void OnDisable()
 {
     foreach (RenderTexture obj in this.m_AutoExposurePool)
     {
         GraphicsUtils.Destroy(obj);
     }
     if (this.m_HistogramBuffer != null)
     {
         this.m_HistogramBuffer.Release();
     }
     this.m_HistogramBuffer = null;
     if (this.m_DebugHistogram != null)
     {
         this.m_DebugHistogram.Release();
     }
     this.m_DebugHistogram = null;
 }
 public override void OnDisable()
 {
     RenderTexture[] autoExposurePool = this.m_AutoExposurePool;
     for (int i = 0; i < autoExposurePool.Length; i++)
     {
         GraphicsUtils.Destroy(autoExposurePool[i]);
     }
     if (this.m_HistogramBuffer != null)
     {
         this.m_HistogramBuffer.Release();
     }
     this.m_HistogramBuffer = null;
     if (this.m_DebugHistogram != null)
     {
         this.m_DebugHistogram.Release();
     }
     this.m_DebugHistogram = null;
 }
        public override void OnDisable()
        {
            foreach (var rt in m_AutoExposurePool)
            {
                GraphicsUtils.Destroy(rt);
            }

            if (m_HistogramBuffer != null)
            {
                m_HistogramBuffer.Release();
            }

            m_HistogramBuffer = null;

            if (m_DebugHistogram != null)
            {
                m_DebugHistogram.Release();
            }

            m_DebugHistogram = null;
        }
Example #11
0
		public static void Dispose()
		{
			GraphicsUtils.Destroy(GraphicsUtils.s_Quad);
		}
Example #12
0
 public override void OnDisable()
 {
     GraphicsUtils.Destroy(this.m_GrainLookupRT);
     this.m_GrainLookupRT = null;
 }
 public void Release()
 {
     GraphicsUtils.Destroy(this.mesh);
     this.mesh = null;
 }
 public void Release()
 {
     GraphicsUtils.Destroy(mesh);
     mesh = null;
 }
 public override void OnDisable()
 {
     GraphicsUtils.Destroy(this.m_SpectrumLut);
     this.m_SpectrumLut = null;
 }
Example #16
0
        void GenerateLut()
        {
            var settings = model.settings;

            if (!IsLogLutValid(model.bakedLut))
            {
                GraphicsUtils.Destroy(model.bakedLut);

                model.bakedLut = new RenderTexture(k_InternalLogLutSize * k_InternalLogLutSize, k_InternalLogLutSize, 0, RenderTextureFormat.ARGBHalf)
                {
                    name       = "Color Grading Log LUT",
                    hideFlags  = HideFlags.DontSave,
                    filterMode = FilterMode.Bilinear,
                    wrapMode   = TextureWrapMode.Clamp,
                    anisoLevel = 0
                };
            }

            var lutMaterial = context.materialFactory.Get("Hidden/Post FX/Lut Generator");

            lutMaterial.SetVector(Uniforms._LutParams, new Vector4(
                                      k_InternalLogLutSize,
                                      0.5f / (k_InternalLogLutSize * k_InternalLogLutSize),
                                      0.5f / k_InternalLogLutSize,
                                      k_InternalLogLutSize / (k_InternalLogLutSize - 1f))
                                  );

            // Tonemapping
            lutMaterial.shaderKeywords = null;

            var tonemapping = settings.tonemapping;

            switch (tonemapping.tonemapper)
            {
            case ColorGradingModel.Tonemapper.Neutral:
            {
                lutMaterial.EnableKeyword("TONEMAPPING_NEUTRAL");

                const float scaleFactor     = 20f;
                const float scaleFactorHalf = scaleFactor * 0.5f;

                float inBlack    = tonemapping.neutralBlackIn * scaleFactor + 1f;
                float outBlack   = tonemapping.neutralBlackOut * scaleFactorHalf + 1f;
                float inWhite    = tonemapping.neutralWhiteIn / scaleFactor;
                float outWhite   = 1f - tonemapping.neutralWhiteOut / scaleFactor;
                float blackRatio = inBlack / outBlack;
                float whiteRatio = inWhite / outWhite;

                const float a = 0.2f;
                float       b = Mathf.Max(0f, Mathf.LerpUnclamped(0.57f, 0.37f, blackRatio));
                float       c = Mathf.LerpUnclamped(0.01f, 0.24f, whiteRatio);
                float       d = Mathf.Max(0f, Mathf.LerpUnclamped(0.02f, 0.20f, blackRatio));
                const float e = 0.02f;
                const float f = 0.30f;

                lutMaterial.SetVector(Uniforms._NeutralTonemapperParams1, new Vector4(a, b, c, d));
                lutMaterial.SetVector(Uniforms._NeutralTonemapperParams2, new Vector4(e, f, tonemapping.neutralWhiteLevel, tonemapping.neutralWhiteClip / scaleFactorHalf));
                break;
            }

            case ColorGradingModel.Tonemapper.ACES:
            {
                lutMaterial.EnableKeyword("TONEMAPPING_FILMIC");
                break;
            }
            }

            // Color balance & basic grading settings
            lutMaterial.SetFloat(Uniforms._HueShift, settings.basic.hueShift / 360f);
            lutMaterial.SetFloat(Uniforms._Saturation, settings.basic.saturation);
            lutMaterial.SetFloat(Uniforms._Contrast, settings.basic.contrast);
            lutMaterial.SetVector(Uniforms._Balance, CalculateColorBalance(settings.basic.temperature, settings.basic.tint));

            // Lift / Gamma / Gain
            Vector3 lift, gamma, gain;

            CalculateLiftGammaGain(
                settings.colorWheels.linear.lift,
                settings.colorWheels.linear.gamma,
                settings.colorWheels.linear.gain,
                out lift, out gamma, out gain
                );

            lutMaterial.SetVector(Uniforms._Lift, lift);
            lutMaterial.SetVector(Uniforms._InvGamma, gamma);
            lutMaterial.SetVector(Uniforms._Gain, gain);

            // Slope / Power / Offset
            Vector3 slope, power, offset;

            CalculateSlopePowerOffset(
                settings.colorWheels.log.slope,
                settings.colorWheels.log.power,
                settings.colorWheels.log.offset,
                out slope, out power, out offset
                );

            lutMaterial.SetVector(Uniforms._Slope, slope);
            lutMaterial.SetVector(Uniforms._Power, power);
            lutMaterial.SetVector(Uniforms._Offset, offset);

            // Channel mixer
            lutMaterial.SetVector(Uniforms._ChannelMixerRed, settings.channelMixer.red);
            lutMaterial.SetVector(Uniforms._ChannelMixerGreen, settings.channelMixer.green);
            lutMaterial.SetVector(Uniforms._ChannelMixerBlue, settings.channelMixer.blue);

            // Selective grading & YRGB curves
            lutMaterial.SetTexture(Uniforms._Curves, GetCurveTexture());

            // Generate the lut
            Graphics.Blit(null, model.bakedLut, lutMaterial, 0);
        }
Example #17
0
        // Token: 0x06003AEF RID: 15087 RVA: 0x001C7EB0 File Offset: 0x001C62B0
        private void GenerateLut()
        {
            ColorGradingModel.Settings settings = base.model.settings;
            if (!this.IsLogLutValid(base.model.bakedLut))
            {
                GraphicsUtils.Destroy(base.model.bakedLut);
                base.model.bakedLut = new RenderTexture(1024, 32, 0, RenderTextureFormat.ARGBHalf)
                {
                    name       = "Color Grading Log LUT",
                    hideFlags  = HideFlags.DontSave,
                    filterMode = FilterMode.Bilinear,
                    wrapMode   = TextureWrapMode.Clamp,
                    anisoLevel = 0
                };
            }
            Material material = this.context.materialFactory.Get("Hidden/Post FX/Lut Generator");

            material.SetVector(ColorGradingComponent.Uniforms._LutParams, new Vector4(32f, 0.00048828125f, 0.015625f, 1.032258f));
            material.shaderKeywords = null;
            ColorGradingModel.TonemappingSettings tonemapping = settings.tonemapping;
            ColorGradingModel.Tonemapper          tonemapper  = tonemapping.tonemapper;
            if (tonemapper != ColorGradingModel.Tonemapper.Neutral)
            {
                if (tonemapper == ColorGradingModel.Tonemapper.ACES)
                {
                    material.EnableKeyword("TONEMAPPING_FILMIC");
                }
            }
            else
            {
                material.EnableKeyword("TONEMAPPING_NEUTRAL");
                float num  = tonemapping.neutralBlackIn * 20f + 1f;
                float num2 = tonemapping.neutralBlackOut * 10f + 1f;
                float num3 = tonemapping.neutralWhiteIn / 20f;
                float num4 = 1f - tonemapping.neutralWhiteOut / 20f;
                float t    = num / num2;
                float t2   = num3 / num4;
                float y    = Mathf.Max(0f, Mathf.LerpUnclamped(0.57f, 0.37f, t));
                float z    = Mathf.LerpUnclamped(0.01f, 0.24f, t2);
                float w    = Mathf.Max(0f, Mathf.LerpUnclamped(0.02f, 0.2f, t));
                material.SetVector(ColorGradingComponent.Uniforms._NeutralTonemapperParams1, new Vector4(0.2f, y, z, w));
                material.SetVector(ColorGradingComponent.Uniforms._NeutralTonemapperParams2, new Vector4(0.02f, 0.3f, tonemapping.neutralWhiteLevel, tonemapping.neutralWhiteClip / 10f));
            }
            material.SetFloat(ColorGradingComponent.Uniforms._HueShift, settings.basic.hueShift / 360f);
            material.SetFloat(ColorGradingComponent.Uniforms._Saturation, settings.basic.saturation);
            material.SetFloat(ColorGradingComponent.Uniforms._Contrast, settings.basic.contrast);
            material.SetVector(ColorGradingComponent.Uniforms._Balance, this.CalculateColorBalance(settings.basic.temperature, settings.basic.tint));
            Vector3 v;
            Vector3 v2;
            Vector3 v3;

            ColorGradingComponent.CalculateLiftGammaGain(settings.colorWheels.linear.lift, settings.colorWheels.linear.gamma, settings.colorWheels.linear.gain, out v, out v2, out v3);
            material.SetVector(ColorGradingComponent.Uniforms._Lift, v);
            material.SetVector(ColorGradingComponent.Uniforms._InvGamma, v2);
            material.SetVector(ColorGradingComponent.Uniforms._Gain, v3);
            Vector3 v4;
            Vector3 v5;
            Vector3 v6;

            ColorGradingComponent.CalculateSlopePowerOffset(settings.colorWheels.log.slope, settings.colorWheels.log.power, settings.colorWheels.log.offset, out v4, out v5, out v6);
            material.SetVector(ColorGradingComponent.Uniforms._Slope, v4);
            material.SetVector(ColorGradingComponent.Uniforms._Power, v5);
            material.SetVector(ColorGradingComponent.Uniforms._Offset, v6);
            material.SetVector(ColorGradingComponent.Uniforms._ChannelMixerRed, settings.channelMixer.red);
            material.SetVector(ColorGradingComponent.Uniforms._ChannelMixerGreen, settings.channelMixer.green);
            material.SetVector(ColorGradingComponent.Uniforms._ChannelMixerBlue, settings.channelMixer.blue);
            material.SetTexture(ColorGradingComponent.Uniforms._Curves, this.GetCurveTexture());
            Graphics.Blit(null, base.model.bakedLut, material, 0);
        }