Пример #1
0
        /// <summary>
        /// Function to render a scene that does not use an effect.
        /// </summary>
        /// <param name="pass">The current pass.</param>
        /// <param name="currentTarget">The currently active render target.</param>
        /// <param name="currentTexture">The texture for the previously active render target.</param>
        private void RenderNoEffectPass(Gorgon2DCompositionPass pass, GorgonRenderTargetView currentTarget, GorgonTexture2DView currentTexture)
        {
            if (pass.RenderMethod == null)
            {
                return;
            }

            // If we changed the states, then apply them now.
            if ((_noEffectBatchState.BlendState != pass.BlendOverride) ||
                (_noEffectBatchState.RasterState != pass.RasterOverride) ||
                (_noEffectBatchState.DepthStencilState != pass.DepthStencilOverride))
            {
                _noEffectBatchState = _noEffectBatchStateBuilder.BlendState(pass.BlendOverride)
                                      .DepthStencilState(pass.DepthStencilOverride)
                                      .RasterState(pass.RasterOverride)
                                      .Build();
            }

            if (Graphics.RenderTargets[0] != currentTarget)
            {
                Graphics.SetRenderTarget(currentTarget, Graphics.DepthStencilView);
            }

            Renderer.Begin(_noEffectBatchState, pass.Camera);
            pass.RenderMethod(currentTexture, 0, 0, new DX.Size2(currentTarget.Width, currentTarget.Height));
            Renderer.End();
        }
Пример #2
0
        /// <summary>
        /// Function to render a scene that does use an effect.
        /// </summary>
        /// <param name="pass">The current pass.</param>
        /// <param name="currentTarget">The currently active render target.</param>
        /// <param name="currentTexture">The texture for the previously active render target.</param>
        private void RenderEffectPass(Gorgon2DCompositionPass pass, GorgonRenderTargetView currentTarget, GorgonTexture2DView currentTexture)
        {
            // The callback method for rendering the effect.
            void RenderAction(int passIndex, int passCount, DX.Size2 size)
            {
                if (pass.RenderMethod != null)
                {
                    pass.RenderMethod(currentTexture, passIndex, passCount, size);
                }
                else
                {
                    DX.RectangleF destRegion = pass.DestinationRegion ?? new DX.RectangleF(0, 0, size.Width, size.Height);
                    DX.RectangleF srcCoords  = pass.SourceCoordinates ?? new DX.RectangleF(0, 0, 1, 1);

                    Renderer.DrawFilledRectangle(destRegion,
                                                 GorgonColor.White,
                                                 currentTexture,
                                                 srcCoords,
                                                 textureSampler: DefaultActionSampler);
                }
            }

            pass.Effect.Render(RenderAction,
                               currentTarget,
                               pass.BlendOverride ?? GorgonBlendState.NoBlending,
                               pass.DepthStencilOverride,
                               pass.RasterOverride,
                               pass.Camera);
        }