Пример #1
0
        public InterlaceSample(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            var effect = ContentManager.Load <Effect>("PostProcessing/Interlace");

            var postProcessor = new EffectPostProcessor(GraphicsService, effect);

            GraphicsScreen.PostProcessors.Add(postProcessor);

            _strengthParameterBinding       = (ConstParameterBinding <float>)postProcessor.EffectBinding.ParameterBindings["Strength"];
            _strengthParameterBinding.Value = 1;
        }
        public LensDistortionSample(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            var effect = ContentManager.Load <Effect>("PostProcessing/LensDistortion");

            var postProcessor = new EffectPostProcessor(GraphicsService, effect);

            GraphicsScreen.PostProcessors.Add(postProcessor);

            var powerParameterBinding = (ConstParameterBinding <float>)postProcessor.EffectBinding.ParameterBindings["Power"];

            powerParameterBinding.Value = 1f;

            _distortionParameterBinding       = (ConstParameterBinding <Vector3>)postProcessor.EffectBinding.ParameterBindings["Distortion"];
            _distortionParameterBinding.Value = new Vector3(
                _distortion,
                _distortion + _chromaticDistortion,
                _distortion + 2 * _chromaticDistortion);
        }
Пример #3
0
        public VignetteSample(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            var effect = ContentManager.Load <Effect>("PostProcessing/Vignette");

            var postProcessor = new EffectPostProcessor(GraphicsService, effect);

            GraphicsScreen.PostProcessors.Add(postProcessor);

            // "Scale" defines the vignette size and shape.
            _scaleParameterBinding = (ConstParameterBinding <Vector2>)postProcessor.EffectBinding.ParameterBindings["Scale"];
            // Elliptic vignette.
            _scaleParameterBinding.Value = new Vector2(2.0f, 2.0f);
            // Circular vignette.
            //_scaleParameterBinding.Value = new Vector2(2.0f, 2.0f * 1280 / 720);

            // "Power" defines the vignette curve.
            // 1 .... linear brightness falloff
            // >1 ... non-linear brightness falloff
            _powerParameterBinding       = (ConstParameterBinding <float>)postProcessor.EffectBinding.ParameterBindings["Power"];
            _powerParameterBinding.Value = 2;
        }
Пример #4
0
    public CustomProcessorSample2(Microsoft.Xna.Framework.Game game)
      : base(game)
    {
      // Load effect.
      var effect = ContentManager.Load<Effect>("PostProcessing/NegativeFilter");

      // Create an EffectPostProcessor that uses the effect and controls the effect parameters
      // using automatically generated effect parameter bindings.
      _negativeFilter = new EffectPostProcessor(GraphicsService, effect);
      GraphicsScreen.PostProcessors.Add(_negativeFilter);

      // An EffectBinding wraps an Effect and automatically creates effect parameter bindings 
      // based on the names, semantics and/or annotations specified in the fx file. 
      // The effect parameters "ViewportSize" and "SourceTexture" have names which are known
      // by the graphics service (see IDs in class DefaultEffectParameterUsages), those effect 
      // parameters will automatically be set by the graphics engine. 
      // The effect parameter "Strength" is not a known name and does not have a semantic, 
      // therefore InitializeBindings() has created a ConstParameterBinding for this parameter 
      // with the default value that was specified in the fx file. We can get this parameter 
      // binding and change the value in Update().
      _strengthParameterBinding = (ConstParameterBinding<float>)_negativeFilter.EffectBinding.ParameterBindings["Strength"];
      _strengthParameterBinding.Value = 1;
    }