Nez.Portable/ECS/Scene.cs
/// <summary>
/// any PostProcessors present get to do their processing then we do the final render of the RenderTarget to the screen
/// </summary>
/// <returns>The render.</returns>
any PostProcessors present get to do their processing then we do the final render of the RenderTarget to the screen
any PostProcessors present get to do their processing then we do the final render of the RenderTarget to the screen
internal void postRender(RenderTarget2D finalRenderTarget = null)
        {
            var enabledCounter = 0;
            if (enablePostProcessing)
            {
                for (var i = 0; i < _postProcessors.length; i++)
                {
                    if (_postProcessors.buffer[i].enabled)
                    {
                        var isEven = Mathf.isEven(enabledCounter);
                        enabledCounter++;
                        _postProcessors.buffer[i].process(
                            isEven ? _sceneRenderTarget : _destinationRenderTarget,
                            isEven ? _destinationRenderTarget : _sceneRenderTarget);
                    }
                }
            }
            for (var i = 0; i < _afterPostProcessorRenderers.length; i++)
            {
                if (i == 0)
                {
                    Core.graphicsDevice.setRenderTarget(
                        Mathf.isEven(enabledCounter) ? _sceneRenderTarget : _destinationRenderTarget);
                }
                if (_afterPostProcessorRenderers.buffer[i].camera != null)
                    _afterPostProcessorRenderers.buffer[i].camera.forceMatrixUpdate();
                _afterPostProcessorRenderers.buffer[i].render(this);
            }
            if (_screenshotRequestCallback != null)
            {
                var tex = new Texture2D(Core.graphicsDevice, _sceneRenderTarget.Width, _sceneRenderTarget.Height);
                var data = new int[tex.Bounds.Width * tex.Bounds.Height];
                (Mathf.isEven(enabledCounter) ? _sceneRenderTarget : _destinationRenderTarget).GetData<int>(data);
                tex.SetData<int>(data);
                _screenshotRequestCallback(tex);
                _screenshotRequestCallback = null;
            }
            if (_finalRenderDelegate != null)
            {
                _finalRenderDelegate.handleFinalRender(
                    letterboxColor,
                    Mathf.isEven(enabledCounter) ? _sceneRenderTarget : _destinationRenderTarget,
                    _finalRenderDestinationRect,
                    samplerState);
            }
            else
            {
                Core.graphicsDevice.setRenderTarget(finalRenderTarget);
                Core.graphicsDevice.Clear(letterboxColor);
                Graphics.instance.batcher.begin(BlendState.Opaque, samplerState, null, null);
                Graphics.instance.batcher.draw(
                    Mathf.isEven(enabledCounter) ? _sceneRenderTarget : _destinationRenderTarget,
                    _finalRenderDestinationRect,
                    Color.White);
                Graphics.instance.batcher.end();
            }
        }
internal void postRender ( RenderTarget2D finalRenderTarget = null ) { var enabledCounter = 0 ; if ( enablePostProcessing ) { for ( var i = 0 ; i < _postProcessors . length ; i ++ ) { if ( _postProcessors . buffer [ i ] . enabled ) { var isEven = Mathf . isEven ( enabledCounter ) ; enabledCounter ++ ; _postProcessors . buffer [ i ] . process ( isEven ? _sceneRenderTarget : _destinationRenderTarget , isEven ? _destinationRenderTarget : _sceneRenderTarget ) ; } } } for ( var i = 0 ; i < _afterPostProcessorRenderers . length ; i ++ ) { if ( i == 0 ) { Core . graphicsDevice . setRenderTarget ( Mathf . isEven ( enabledCounter ) ? _sceneRenderTarget : _destinationRenderTarget ) ; } if ( _afterPostProcessorRenderers . buffer [ i ] . camera != null ) _afterPostProcessorRenderers . buffer [ i ] . camera . forceMatrixUpdate ( ) ; _afterPostProcessorRenderers . buffer [ i ] . render ( this ) ; } if ( _screenshotRequestCallback != null ) { var tex = new Texture2D ( Core . graphicsDevice , _sceneRenderTarget . Width , _sceneRenderTarget . Height ) ; var data = new int [ tex . Bounds . Width * tex . Bounds . Height ] ; ( Mathf . isEven ( enabledCounter ) ? _sceneRenderTarget : _destinationRenderTarget ) . GetData < int > ( data ) ; tex . SetData < int > ( data ) ; _screenshotRequestCallback ( tex ) ; _screenshotRequestCallback = null ; } if ( _finalRenderDelegate != null ) { _finalRenderDelegate . handleFinalRender ( letterboxColor , Mathf . isEven ( enabledCounter ) ? _sceneRenderTarget : _destinationRenderTarget , _finalRenderDestinationRect , samplerState ) ; } else { Core . graphicsDevice . setRenderTarget ( finalRenderTarget ) ; Core . graphicsDevice . Clear ( letterboxColor ) ; Graphics . instance . batcher . begin ( BlendState . Opaque , samplerState , null , null ) ; Graphics . instance . batcher . draw ( Mathf . isEven ( enabledCounter ) ? _sceneRenderTarget : _destinationRenderTarget , _finalRenderDestinationRect , Color . White ) ; Graphics . instance . batcher . end ( ) ; } }
any PostProcessors present get to do their processing then we do the final render of the RenderTarget to the screen
any PostProcessors present get to do their processing then we do the final render of the RenderTarget to the screen
// deal with our Renderers that want to render after PostProcessors if we have any // we need to set the proper RenderTarget here. We want the last one that was the destination of our PostProcessors // force a Camera matrix update to account for the new Viewport size // if we have a screenshot request deal with it before the final render to the backbuffer // render our final result to the backbuffer or let our delegate do so
None
finalRenderTarget
RenderTarget2D