Ejemplo n.º 1
0
        public static async Task Run(EngineContext engineContext)
        {
            var renderingSetup = new RenderingSetup();

            renderingSetup.Initialize(engineContext);
            var device = engineContext.RenderContext.GraphicsDevice;

            var effectMeshGroup = new RenderPassListEnumerator();

            engineContext.RenderContext.RenderPassEnumerators.Add(effectMeshGroup);


            EffectOld linearEffect = engineContext.RenderContext.BuildEffect("LinearColor")
                                     .Using(new PostEffectShaderPlugin())
                                     .Using(new BasicShaderPlugin(new ShaderClassSource("ComputeToneMap", "0")));
            var linearMesh = new EffectMesh(linearEffect);

            renderingSetup.LinearColorPlugin.RenderPass.AddPass(linearMesh.EffectMeshPasses[0].EffectPass);
            var linearTexture = Texture2D.New(engineContext.RenderContext.GraphicsDevice, 512, 512, PixelFormat.R16G16B16A16_Float, TextureFlags.RenderTarget);

            linearMesh.Parameters.Set(RenderTargetKeys.RenderTarget, linearTexture.ToRenderTarget());
            effectMeshGroup.AddMesh(linearMesh);

            EffectOld reinhardColor = engineContext.RenderContext.BuildEffect("ReinhardColor")
                                      .Using(new PostEffectShaderPlugin())
                                      .Using(new BasicShaderPlugin(new ShaderClassSource("ComputeToneMap", "1")));
            var reinhardMesh = new EffectMesh(reinhardColor);

            renderingSetup.ReinhardColorPlugin.RenderPass.AddPass(reinhardMesh.EffectMeshPasses[0].EffectPass);
            var reinhardTexture = Texture2D.New(engineContext.RenderContext.GraphicsDevice, 512, 512, PixelFormat.R16G16B16A16_Float, TextureFlags.RenderTarget);

            reinhardMesh.Parameters.Set(RenderTargetKeys.RenderTarget, reinhardTexture.ToRenderTarget());
            effectMeshGroup.AddMesh(reinhardMesh);

            var yebisTexture = Texture2D.New(engineContext.RenderContext.GraphicsDevice, 512, 512, PixelFormat.R8G8B8A8_UNorm, TextureFlags.RenderTarget);

#if XENKO_YEBIS
            var yebisPlugin = renderingSetup.YebisPlugin;

            yebisPlugin.RenderSource = reinhardTexture;
            yebisPlugin.RenderTarget = yebisTexture.ToRenderTarget();

            yebisPlugin.Glare.Enable           = false;
            yebisPlugin.Lens.Vignette.Enable   = false;
            yebisPlugin.Lens.Distortion.Enable = false;

            yebisPlugin.ToneMap.Exposure = 1.0f;
            yebisPlugin.ToneMap.Gamma    = 2.2f;
            yebisPlugin.ToneMap.Type     = ToneMapType.Reinhard;
            engineContext.RenderContext.Register(yebisPlugin);
#endif

            EffectOld filmicEffect = engineContext.RenderContext.BuildEffect("FilmicColor")
                                     .Using(new PostEffectShaderPlugin())
                                     .Using(new BasicShaderPlugin(new ShaderClassSource("ComputeToneMap", "2")));
            var filmicMesh = new EffectMesh(filmicEffect);
            renderingSetup.FilmicColorPlugin.RenderPass.AddPass(filmicMesh.EffectMeshPasses[0].EffectPass);
            var filmicTexture = Texture2D.New(engineContext.RenderContext.GraphicsDevice, 512, 512, PixelFormat.R16G16B16A16_Float, TextureFlags.ShaderResource | TextureFlags.RenderTarget);
            filmicTexture.Name = "FilmicTexture";
            filmicMesh.Parameters.Set(RenderTargetKeys.RenderTarget, filmicTexture.ToRenderTarget());
            effectMeshGroup.AddMesh(filmicMesh);

            EffectOld mainEffect = engineContext.RenderContext.BuildEffect("ComposeToneMap")
                                   .Using(new PostEffectShaderPlugin())
                                   .Using(new BasicShaderPlugin(new ShaderClassSource("ComposeToneMap")));
            var mainMesh = new EffectMesh(mainEffect);
            renderingSetup.MainPlugin.RenderPass.AddPass(mainMesh.EffectMeshPasses[0].EffectPass);

            mainMesh.Parameters.Set(TexturingKeys.Texture0, linearTexture);
            mainMesh.Parameters.Set(TexturingKeys.Texture2, yebisTexture);
            mainMesh.Parameters.Set(TexturingKeys.Texture3, filmicTexture);
            mainMesh.Parameters.Set(RenderTargetKeys.RenderTarget, engineContext.RenderContext.RenderTarget);
            effectMeshGroup.AddMesh(mainMesh);
        }
Ejemplo n.º 2
0
        public static async Task Run(EngineContext engineContext)
        {
            var renderingSetup = new RenderingSetup();
            renderingSetup.Initialize(engineContext);
            var device = engineContext.RenderContext.GraphicsDevice;

            var effectMeshGroup = new RenderPassListEnumerator();
            engineContext.RenderContext.RenderPassEnumerators.Add(effectMeshGroup);


            EffectOld linearEffect = engineContext.RenderContext.BuildEffect("LinearColor")
                        .Using(new PostEffectShaderPlugin())
                        .Using(new BasicShaderPlugin(new ShaderClassSource("ComputeToneMap", "0")));
            var linearMesh = new EffectMesh(linearEffect);
            renderingSetup.LinearColorPlugin.RenderPass.AddPass(linearMesh.EffectMeshPasses[0].EffectPass);
            var linearTexture = Texture2D.New(engineContext.RenderContext.GraphicsDevice, 512, 512, PixelFormat.R16G16B16A16_Float, TextureFlags.RenderTarget);
            linearMesh.Parameters.Set(RenderTargetKeys.RenderTarget, linearTexture.ToRenderTarget());
            effectMeshGroup.AddMesh(linearMesh);

            EffectOld reinhardColor = engineContext.RenderContext.BuildEffect("ReinhardColor")
                        .Using(new PostEffectShaderPlugin())
                        .Using(new BasicShaderPlugin(new ShaderClassSource("ComputeToneMap", "1")));
            var reinhardMesh = new EffectMesh(reinhardColor);
            renderingSetup.ReinhardColorPlugin.RenderPass.AddPass(reinhardMesh.EffectMeshPasses[0].EffectPass);
            var reinhardTexture = Texture2D.New(engineContext.RenderContext.GraphicsDevice, 512, 512, PixelFormat.R16G16B16A16_Float, TextureFlags.RenderTarget);
            reinhardMesh.Parameters.Set(RenderTargetKeys.RenderTarget, reinhardTexture.ToRenderTarget());
            effectMeshGroup.AddMesh(reinhardMesh);

            var yebisTexture = Texture2D.New(engineContext.RenderContext.GraphicsDevice, 512, 512, PixelFormat.R8G8B8A8_UNorm, TextureFlags.RenderTarget);
#if PARADOX_YEBIS
            var yebisPlugin = renderingSetup.YebisPlugin;

            yebisPlugin.RenderSource = reinhardTexture;
            yebisPlugin.RenderTarget = yebisTexture.ToRenderTarget();

            yebisPlugin.Glare.Enable = false;
            yebisPlugin.Lens.Vignette.Enable = false;
            yebisPlugin.Lens.Distortion.Enable = false;

            yebisPlugin.ToneMap.Exposure = 1.0f;
            yebisPlugin.ToneMap.Gamma = 2.2f;
            yebisPlugin.ToneMap.Type = ToneMapType.Reinhard;
            engineContext.RenderContext.Register(yebisPlugin);
#endif

            EffectOld filmicEffect = engineContext.RenderContext.BuildEffect("FilmicColor")
                        .Using(new PostEffectShaderPlugin())
                        .Using(new BasicShaderPlugin(new ShaderClassSource("ComputeToneMap", "2")));
            var filmicMesh = new EffectMesh(filmicEffect);
            renderingSetup.FilmicColorPlugin.RenderPass.AddPass(filmicMesh.EffectMeshPasses[0].EffectPass);
            var filmicTexture = Texture2D.New(engineContext.RenderContext.GraphicsDevice, 512, 512, PixelFormat.R16G16B16A16_Float, TextureFlags.ShaderResource | TextureFlags.RenderTarget);
            filmicTexture.Name = "FilmicTexture";
            filmicMesh.Parameters.Set(RenderTargetKeys.RenderTarget, filmicTexture.ToRenderTarget());
            effectMeshGroup.AddMesh(filmicMesh);

            EffectOld mainEffect = engineContext.RenderContext.BuildEffect("ComposeToneMap")
            .Using(new PostEffectShaderPlugin())
            .Using(new BasicShaderPlugin(new ShaderClassSource("ComposeToneMap")));
            var mainMesh = new EffectMesh(mainEffect);
            renderingSetup.MainPlugin.RenderPass.AddPass(mainMesh.EffectMeshPasses[0].EffectPass);

            mainMesh.Parameters.Set(TexturingKeys.Texture0, linearTexture);
            mainMesh.Parameters.Set(TexturingKeys.Texture2, yebisTexture);
            mainMesh.Parameters.Set(TexturingKeys.Texture3, filmicTexture);
            mainMesh.Parameters.Set(RenderTargetKeys.RenderTarget, engineContext.RenderContext.RenderTarget);
            effectMeshGroup.AddMesh(mainMesh);

        }