Ejemplo n.º 1
0
        /// <summary>
        /// Function called before a pass is rendered.
        /// </summary>
        /// <param name="pass">Pass to render.</param>
        /// <returns>
        /// TRUE to continue rendering, FALSE to stop.
        /// </returns>
        protected override bool OnBeforePassRender(GorgonEffectPass pass)
        {
            if ((_displacementTarget == null) || (_backgroundTarget == null))
            {
                return(false);
            }

            if (pass.PassIndex == 0)
            {
                base.OnBeforePassRender(pass);

                Gorgon2D.PixelShader.Current      = null;
                Gorgon2D.VertexShader.Current     = null;
                Gorgon2D.PixelShader.Resources[1] = null;

                _displacementTarget.Clear(GorgonColor.Transparent);
                Gorgon2D.Target = _displacementTarget;
                return(true);
            }

            Gorgon2D.PixelShader.Current      = pass.PixelShader;
            Gorgon2D.VertexShader.Current     = pass.VertexShader;
            Gorgon2D.PixelShader.Resources[1] = _displacementTarget;

            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Function called after a pass has been rendered.
        /// </summary>
        /// <param name="pass">Pass that was rendered.</param>
        protected override void OnAfterPassRender(GorgonEffectPass pass)
        {
            if (pass.PassIndex == 0)
            {
                Gorgon2D.Target = CurrentTarget;
                return;
            }

            base.OnAfterPassRender(pass);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Function called before a pass is rendered.
        /// </summary>
        /// <param name="pass">Pass to render.</param>
        /// <returns>
        /// TRUE to continue rendering, FALSE to stop.
        /// </returns>
        protected override bool OnBeforePassRender(GorgonEffectPass pass)
        {
            if (pass.RenderAction == null)
            {
                return(false);
            }

            _prevPixelShader  = Gorgon2D.PixelShader.Current;
            _prevVertexShader = Gorgon2D.VertexShader.Current;

            Gorgon2D.PixelShader.Current  = pass.PixelShader;
            Gorgon2D.VertexShader.Current = pass.VertexShader;

            return(true);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Function to render a pass.
        /// </summary>
        /// <param name="pass">Pass that is to be rendered.</param>
        protected override void OnRenderPass(GorgonEffectPass pass)
        {
            Gorgon2D.Target = _hTarget;

            // Render horizontal pass.
            _hTarget.Clear(GorgonColor.Transparent);
            _blurBuffer.Update(_xOffsets);

            // Render the scene.
            pass.RenderAction(pass);

            // Render vertical pass.
            Gorgon2D.Target = _vTarget;
            _blurBuffer.Update(_yOffsets);

            _blurSprite.Draw();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Function called before a pass is rendered.
        /// </summary>
        /// <param name="pass">Pass to render.</param>
        /// <returns>
        /// TRUE to continue rendering, FALSE to stop.
        /// </returns>
        protected override bool OnBeforePassRender(GorgonEffectPass pass)
        {
            float renderTime = Time;

            if (_isScratchUpdated)
            {
                _scratchBuffer.Update(ref _scratchSettings);
                _isScratchUpdated = false;
            }

            if (_isSepiaUpdated)
            {
                _sepiaBuffer.Update(ref _sepiaSettings);
                _isSepiaUpdated = false;
            }

            _timingBuffer.Update(ref renderTime);

            return(base.OnBeforePassRender(pass));
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Function called before a pass is rendered.
 /// </summary>
 /// <param name="pass">Pass to render.</param>
 /// <returns>
 /// TRUE to continue rendering, FALSE to stop.
 /// </returns>
 protected override bool OnBeforePassRender(GorgonEffectPass pass)
 {
     pass.PixelShader = UseEmbossing ? _embossShader : _sharpenShader;
     return(base.OnBeforePassRender(pass));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Function called after a pass has been rendered.
 /// </summary>
 /// <param name="pass">Pass that was rendered.</param>
 protected override void OnAfterPassRender(GorgonEffectPass pass)
 {
     Gorgon2D.PixelShader.Current  = _prevPixelShader;
     Gorgon2D.VertexShader.Current = _prevVertexShader;
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Function called after a pass has been rendered.
        /// </summary>
        /// <param name="pass">Pass that was rendered.</param>
        protected override void OnAfterPassRender(GorgonEffectPass pass)
        {
            // We must set the pixel shader back to the default here.
            // Otherwise our current shader may not like that we're trying to
            // render lines and points with no textures attached.

            // If this shader is nested with another (e.g. gauss blur), then
            // this situation can throw warnings up in the debug spew.

            // Setting the pixel shader to the proper shader when rendering
            // primitives with no textures is the best way to correct this.
            Gorgon2D.PixelShader.Current = null;

            var blend = Gorgon2D.Drawing.Blending;

            // Render dust and dirt.
            for (int i = 0; i < DirtAmount; ++i)
            {
                float grayDust  = GorgonRandom.RandomSingle(0.1f, 0.25f);
                var   dustColor = new GorgonColor(grayDust, grayDust, grayDust, GorgonRandom.RandomSingle(0.25f, 0.95f));

                // Render dust points.
                _point.Color          = dustColor;
                _point.PointThickness = new Vector2(1);
                _point.Position       = new Vector2(GorgonRandom.RandomSingle(0, _currentTargetSize.X - 1),
                                                    GorgonRandom.RandomSingle(0, _currentTargetSize.Y - 1));
                _point.Draw();

                if (GorgonRandom.RandomInt32(100) >= DirtPercent)
                {
                    continue;
                }

                // Render dirt/hair lines.
                var dirtStart = new Vector2(GorgonRandom.RandomSingle(0, _currentTargetSize.X - 1),
                                            GorgonRandom.RandomSingle(0, _currentTargetSize.Y - 1));

                float dirtWidth      = GorgonRandom.RandomSingle(1.0f, 3.0f);
                bool  isHair         = GorgonRandom.RandomInt32(100) > 50;
                bool  isHairVertical = isHair && GorgonRandom.RandomInt32(100) > 50;

                grayDust  = GorgonRandom.RandomSingle(0.1f, 0.15f);
                dustColor = new GorgonColor(grayDust, grayDust, grayDust, GorgonRandom.RandomSingle(0.25f, 0.95f));

                for (int j = 0; j < GorgonRandom.RandomInt32(4, (int)_currentTargetSize.X / 4); j++)
                {
                    _point.Color          = dustColor;
                    _point.Position       = new Vector2(dirtStart.X, dirtStart.Y);
                    _point.PointThickness = isHair ? new Vector2(1) : new Vector2(dirtWidth, dirtWidth);
                    _point.Draw();

                    if ((!isHair) || (isHairVertical))
                    {
                        if (GorgonRandom.RandomInt32(100) > 50)
                        {
                            dirtStart.X++;
                        }
                        else
                        {
                            dirtStart.X--;
                        }
                    }
                    else
                    {
                        if (grayDust < 0.25f)
                        {
                            dirtStart.X++;
                        }
                        else
                        {
                            dirtStart.X--;
                        }
                    }

                    if ((!isHair) || (!isHairVertical))
                    {
                        if (GorgonRandom.RandomInt32(100) > 50)
                        {
                            dirtStart.Y++;
                        }
                        else
                        {
                            dirtStart.Y--;
                        }
                    }
                    else
                    {
                        if (dirtWidth < 1.5f)
                        {
                            dirtStart.Y++;
                        }
                        else
                        {
                            dirtStart.Y--;
                        }
                    }
                }
            }

            // Restore the previous blend state.
            Gorgon2D.Drawing.Blending = blend;

            base.OnAfterPassRender(pass);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Function called before a pass is rendered.
 /// </summary>
 /// <param name="pass">Pass to render.</param>
 /// <returns>
 /// TRUE to continue rendering, FALSE to stop.
 /// </returns>
 protected override bool OnBeforePassRender(GorgonEffectPass pass)
 {
     Passes[0].PixelShader = UseLinear ? _linearDodgeBurn : _dodgeBurn;
     return(base.OnBeforePassRender(pass));
 }