示例#1
0
        private void AddModels(RenderPipeline pipeline, GraphicsDevice device, IMeterRegistry meterRegistry, RenderPipelineSettings settings)
        {
            if (settings.EnableModels)
            {
                pipeline.UpdateSystem(this.Systems.Get <BoundsSystem>());

                var modelPipeline = ModelPipeline.Create(device, meterRegistry)
                                    .ClearModelRenderTargets()
                                    .RenderGeometry(this.Systems.Get <GeometrySystem>())
                                    .RenderModelBatch();

                if (settings.EnableProjectors)
                {
                    var projectorPipeline = ProjectorPipeline.Create(device, meterRegistry);
                    var projectorSystem   = this.Systems.Get <ProjectorSystem>();
                    projectorSystem.Technique = settings.ProjectorTechnique;
                    projectorPipeline.RenderProjectors(projectorSystem);

                    modelPipeline.RenderProjectors(projectorPipeline);
                }

                if (EnableLights(settings))
                {
                    var ls = settings.LightSettings;
                    var lightingPipeline = LightingPipeline.Create(device, meterRegistry)
                                           .ClearLightTargets()
                                           .EnableIf(ls.EnableAmbientLights, x => x.RenderAmbientLight(this.Systems.Get <AmbientLightSystem>(), ls.EnableSSAO))
                                           .EnableIf(ls.EnableDirectionalLights, x => x.RenderDirectionalLights(this.Systems.Get <DirectionalLightSystem>()))
                                           .EnableIf(ls.EnablePointLights, x => x.RenderPointLights(this.Systems.Get <PointLightSystem>()))
                                           .EnableIf(ls.EnableShadowCastingLights, x => x.RenderShadowCastingLights(this.Systems.Get <ShadowCastingLightSystem>()))
                                           .EnableIf(ls.EnableSunLights, x => x.RenderSunlights(this.Systems.Get <SunlightSystem>()));

                    modelPipeline.RenderLights(lightingPipeline);
                }

                var combineEffect = this.EffectFactory.Construct <CombineEffect>();
                var fxaaEffect    = this.EffectFactory.Construct <FxaaEffect>();
                modelPipeline
                .CombineDiffuseWithLighting(combineEffect)
                .AntiAlias(fxaaEffect, settings.ModelSettings.FxaaFactor);

                pipeline.RenderModels(this.Systems.Get <ModelSystem>(), modelPipeline);
            }
        }
示例#2
0
        private void AddShadows(RenderPipeline pipeline, GraphicsDevice device, IMeterRegistry meterRegistry, RenderPipelineSettings settings)
        {
            if (settings.EnableShadows)
            {
                var shadowPipeline = ShadowPipeline.Create(device, meterRegistry)
                                     .RenderShadowMaps(this.Systems.Get <ShadowMapSystem>());

                pipeline
                .UpdateSystem(this.Systems.Get <CascadedShadowMapSystem>())
                .RenderShadows(shadowPipeline);
            }
        }
示例#3
0
        private void AddParticles(RenderPipeline pipeline, GraphicsDevice device, IMeterRegistry meterRegistry, RenderPipelineSettings settings)
        {
            if (settings.EnableParticles)
            {
                var particlePipeline = ParticlePipeline.Create(device, meterRegistry).ClearParticleRenderTargets()
                                       .RenderTransparentParticles(this.Systems.Get <AveragedParticleSystem>())
                                       .RenderAdditiveParticles(this.Systems.Get <AdditiveParticleSystem>());

                pipeline.RenderParticles(particlePipeline);
            }
        }
示例#4
0
        public RenderPipeline Build(GraphicsDevice device, IMeterRegistry meterRegistry, RenderPipelineSettings settings)
        {
            var pipeline = RenderPipeline.Create(device, meterRegistry)
                           .ClearRenderTargetSet()
                           .UpdateSystem(this.Systems.Get <OffsetSystem>());

            this.AddDynamicTextures(pipeline);
            this.AddShadows(pipeline, device, meterRegistry, settings);
            this.AddModels(pipeline, device, meterRegistry, settings);
            this.AddParticles(pipeline, device, meterRegistry, settings);
            this.AddDebug(pipeline, settings);

            return(pipeline);
        }
示例#5
0
        private static bool EnableLights(RenderPipelineSettings settings)
        {
            var ls = settings.LightSettings;

            return(ls.EnableAmbientLights || ls.EnableDirectionalLights || ls.EnablePointLights || ls.EnableShadowCastingLights || ls.EnableSunLights);
        }