public override void UpdateParameters(ColorTransformContext context)
        {
            // TODO This could be put as part

            double b = BlackPoint;
            double c = CrossOver;
            double w = WhitePoint;
            double t = Toe;
            double s = Shoulder;

            double k = ((1 - t) * (c - b)) / ((1 - s) * (w - c) + (1 - t) * (c - b));

            var toe = new Vector4(
                (float)((k * (1 - t))),
                (float)(-t),
                (float)(k * (1 - t) * (-b)),
                (float)(c - (1 - t) * b));

            var shoulder = new Vector4(
                (float)(((1 - k) + k * s)),
                (float)(s),
                (float)((1 - k) * (-c) + k * ((1 - s) * w - c)),
                (float)((1 - s) * w - c));

            // Don't call base, as we are rewriting all parameters for the shader
            Parameters.Set(ToneMapMikeDayOperatorShaderKeys.ToeCoeffs, toe);
            Parameters.Set(ToneMapMikeDayOperatorShaderKeys.ShoulderCoeffs, shoulder);
            Parameters.Set(ToneMapMikeDayOperatorShaderKeys.MiddleCrossOver, CrossOver);

            // Copy parameters to parent
            base.UpdateParameters(context);
        }
        public override void UpdateParameters(ColorTransformContext context)
        {
            // TODO This could be put as part 

            double b = BlackPoint;
            double c = CrossOver;
            double w = WhitePoint;
            double t = Toe;
            double s = Shoulder;

            double k = ((1 - t) * (c - b)) / ((1 - s) * (w - c) + (1 - t) * (c - b));

            var toe = new Vector4(
                (float)((k * (1 - t))),
                (float)(-t),
                (float)(k * (1 - t) * (-b)),
                (float)(c - (1 - t) * b));

            var shoulder = new Vector4(
                (float)(((1 - k) + k * s)),
                (float)(s),
                (float)((1 - k) * (-c) + k * ((1 - s) * w - c)),
                (float)((1 - s) * w - c));

            // Don't call base, as we are rewriting all parameters for the shader
            Parameters.Set(ToneMapMikeDayOperatorShaderKeys.ToeCoeffs, toe);
            Parameters.Set(ToneMapMikeDayOperatorShaderKeys.ShoulderCoeffs, shoulder);
            Parameters.Set(ToneMapMikeDayOperatorShaderKeys.MiddleCrossOver, CrossOver);
        }
Beispiel #3
0
        public override void UpdateParameters(ColorTransformContext context)
        {
            base.UpdateParameters(context);

            Parameters.Set(VignettingShaderKeys.Amount, Amount);
            Parameters.Set(VignettingShaderKeys.RadiusBegin, Radius);
            Parameters.Set(VignettingShaderKeys.Color, Color.ToColorSpace(context.RenderContext.GraphicsDevice.ColorSpace));
        }
Beispiel #4
0
        public override void UpdateParameters(ColorTransformContext context)
        {
            base.UpdateParameters(context);

            Parameters.Set(VignettingShaderKeys.Amount, Amount);
            Parameters.Set(VignettingShaderKeys.RadiusBegin, Radius);
            Parameters.Set(VignettingShaderKeys.Color, Color.ToColorSpace(context.RenderContext.GraphicsDevice.ColorSpace));
        }
Beispiel #5
0
        /// <summary>
        /// Prepare copy operations for parameters.
        /// </summary>
        public virtual void PrepareParameters(ColorTransformContext context, ParameterCollection parentCollection, string keyRoot)
        {
            // Save Group aside
            Group = context.Group;

            // Compute associated layout ranges
            parameterCompositionCopier = new ParameterCollection.CompositionCopier();
            parameterCompositionCopier.Compile(parentCollection, Parameters, keyRoot);
        }
Beispiel #6
0
        public override void UpdateParameters(ColorTransformContext context)
        {
            base.UpdateParameters(context);

            if (Operator == null)
            {
                throw new InvalidOperationException("Operator cannot be null on this instance");
            }

            // Update the luminance
            var elapsedTime = timer.Elapsed;

            timer.Restart();

            var luminanceResult = context.SharedParameters.Get(LuminanceEffect.LuminanceResult);

            // Get the average luminance
            float adaptedLum = luminanceResult.AverageLuminance;

            if (TemporalAdaptation)
            {
                // Get adapted luminance
                // From "Perceptual effects in real-time tone mapping" by Grzegorz Krawczyk, Karol Myszkowski, Hans-Peter Seidel, p. 3, Equation 5
                adaptedLum        = (float)(previousLuminance + (luminanceResult.AverageLuminance - previousLuminance) * (1.0 - Math.Exp(-elapsedTime.TotalSeconds * AdaptationRate)));
                previousLuminance = adaptedLum;
            }

            if (AutoKeyValue)
            {
                // From "Perceptual effects in real-time tone mapping" by Grzegorz Krawczyk, Karol Myszkowski, Hans-Peter Seidel, p. 4, Equation 11
                KeyValue = 1.03f - (2.0f / (2.0f + (float)Math.Log10(adaptedLum + 1)));
            }

            // Setup parameters
            Parameters.Set(ToneMapShaderKeys.LuminanceTexture, luminanceResult.LocalTexture);
            Parameters.Set(ToneMapShaderKeys.LuminanceAverageGlobal, (float)Math.Log(adaptedLum, 2));
            Parameters.Set(ToneMapShaderKeys.Exposure, (float)Math.Pow(2.0, Exposure));

            // Update operator parameters
            Operator.UpdateParameters(context);

            // Copy sub parameters from composition to this transform
            foreach (var key in Operator.Parameters.Keys)
            {
                ParameterKey tonemapKey;
                if (!tonemapKeys.TryGetValue(key, out tonemapKey))
                {
                    tonemapKey = key.ComposeWith("ToneMapOperator");
                    tonemapKeys.Add(key, tonemapKey);
                }
                Operator.Parameters.CopySharedTo(key, tonemapKey, Parameters);
            }
        }
Beispiel #7
0
        /// <inheritdoc/>
        protected override void InitializeCore()
        {
            base.InitializeCore();

            transformGroupEffect = new ImageEffectShader(colorTransformGroupEffectName);
            transformGroupEffect.SharedParameterCollections.Add(Parameters);
            transformGroupEffect.Initialize(Context);

            // we are adding parameter collections after as transform parameters should override previous parameters
            transformGroupEffect.ParameterCollections.Add(transformsParameters);

            this.transformContext = new ColorTransformContext(this, Context);
        }
Beispiel #8
0
        public override void UpdateParameters(ColorTransformContext context)
        {
            base.UpdateParameters(context);

            Parameters.Set(FilmGrainShaderKeys.Amount, Amount * 4 * 0.02f);
            Parameters.Set(FilmGrainShaderKeys.GrainSize, GrainSize);
            Parameters.Set(FilmGrainShaderKeys.LuminanceFactor, LuminanceFactor);
            if (Animate)
            {
                time += 0.1f;
                if (time > 100f) time = 1f;
            }
            Parameters.Set(FilmGrainShaderKeys.Time, time);
        }
Beispiel #9
0
        public override void UpdateParameters(ColorTransformContext context)
        {
            base.UpdateParameters(context);

            Parameters.Set(FilmGrainShaderKeys.Amount, Amount * 4 * 0.02f);
            Parameters.Set(FilmGrainShaderKeys.GrainSize, GrainSize);
            Parameters.Set(FilmGrainShaderKeys.LuminanceFactor, LuminanceFactor);
            if (Animate)
            {
                time += 0.1f;
                if (time > 100f)
                {
                    time = 1f;
                }
            }
            Parameters.Set(FilmGrainShaderKeys.Time, time);
        }
Beispiel #10
0
        public override void PrepareParameters(ColorTransformContext context, ParameterCollection parentCollection, string keyRoot)
        {
            base.PrepareParameters(context, parentCollection, keyRoot);

            Operator.PrepareParameters(context, Parameters, ".ToneMapOperator");
        }
 /// <summary>
 /// Updates the parameters for this transformation.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <remarks>This method is called just before rendering the ColorTransformGroup that is holding this ColorTransformBase</remarks>
 public virtual void UpdateParameters(ColorTransformContext context)
 {
 }
Beispiel #12
0
        public override void UpdateParameters(ColorTransformContext context)
        {
            base.UpdateParameters(context);

            if (Operator == null)
            {
                throw new InvalidOperationException("Operator cannot be null on this instance");
            }

            // Update the luminance
            var elapsedTime = timer.Elapsed;
            timer.Restart();

            var luminanceResult = context.SharedParameters.Get(LuminanceEffect.LuminanceResult);

            // Get the average luminance
            float adaptedLum = luminanceResult.AverageLuminance;
            if (TemporalAdaptation)
            {
                // Get adapted luminance
                // From "Perceptual effects in real-time tone mapping" by Grzegorz Krawczyk, Karol Myszkowski, Hans-Peter Seidel, p. 3, Equation 5
                adaptedLum = (float)(previousLuminance + (luminanceResult.AverageLuminance - previousLuminance) * (1.0 - Math.Exp(-elapsedTime.TotalSeconds * AdaptationRate)));
                previousLuminance = adaptedLum;
            }

            if (AutoKeyValue)
            {
                // From "Perceptual effects in real-time tone mapping" by Grzegorz Krawczyk, Karol Myszkowski, Hans-Peter Seidel, p. 4, Equation 11
                KeyValue = 1.03f - (2.0f / (2.0f + (float)Math.Log10(adaptedLum + 1)));
            }

            // Setup parameters
            Parameters.Set(ToneMapShaderKeys.LuminanceTexture, luminanceResult.LocalTexture);
            Parameters.Set(ToneMapShaderKeys.LuminanceAverageGlobal, (float)Math.Log(adaptedLum, 2));
            Parameters.Set(ToneMapShaderKeys.Exposure, (float)Math.Pow(2.0, Exposure));

            // Update operator parameters
            Operator.UpdateParameters(context);

            // Copy sub parameters from composition to this transform
            foreach (var key in Operator.Parameters.Keys)
            {
                ParameterKey tonemapKey;
                if (!tonemapKeys.TryGetValue(key, out tonemapKey))
                {
                    tonemapKey = key.ComposeWith("ToneMapOperator");
                    tonemapKeys.Add(key, tonemapKey);
                }
                Operator.Parameters.CopySharedTo(key, tonemapKey, Parameters);
            }
        }
Beispiel #13
0
 /// <summary>
 /// Updates the parameters for this transformation.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <remarks>This method is called just before rendering the ColorTransformGroup that is holding this ColorTransformBase</remarks>
 public virtual void UpdateParameters(ColorTransformContext context)
 {
     parameterCompositionCopier.Copy(Parameters);
 }
 /// <summary>
 /// Updates the parameters for this transformation.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <remarks>This method is called just before rendering the ColorTransformGroup that is holding this ColorTransformBase</remarks>
 public virtual void UpdateParameters(ColorTransformContext context)
 {
     parameterCompositionCopier.Copy(Parameters);
 }
        /// <summary>
        /// Prepare copy operations for parameters.
        /// </summary>
        public virtual void PrepareParameters(ColorTransformContext context, ParameterCollection parentCollection, string keyRoot)
        {
            // Save Group aside
            Group = context.Group;

            // Compute associated layout ranges
            parameterCompositionCopier = new ParameterCollection.CompositionCopier();
            parameterCompositionCopier.Compile(parentCollection, Parameters, keyRoot);
        }
Beispiel #16
0
        public override void PrepareParameters(ColorTransformContext context, ParameterCollection parentCollection, string keyRoot)
        {
            base.PrepareParameters(context, parentCollection, keyRoot);

            Operator.PrepareParameters(context, Parameters, ".ToneMapOperator");
        }
Beispiel #17
0
 /// <summary>
 /// Updates the parameters for this transformation.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <remarks>This method is called just before rendering the ColorTransformGroup that is holding this ColorTransformBase</remarks>
 public virtual void UpdateParameters(ColorTransformContext context)
 {
 }