예제 #1
0
        public ShadowMapSystem(
            GraphicsDevice device,
            IComponentContainer <ShadowMap> shadowMaps,
            IComponentContainer <CascadedShadowMap> cascadedShadowMaps,
            ModelSystem modelSystem,
            IMeterRegistry meterRegistry)
        {
            this.Device             = device;
            this.ShadowMaps         = shadowMaps;
            this.CascadedShadowMaps = cascadedShadowMaps;
            this.ModelSystem        = modelSystem;
            this.MeterRegistry      = meterRegistry;

            this.MeterRegistry.CreateGauge(ShadowMapCounter);
            this.MeterRegistry.CreateGauge(ShadowMapTotal);
            this.MeterRegistry.CreateGauge(ShadowMapStep, "step");

            this.NullSkybox = new TextureCube(device, 1, false, SurfaceFormat.Color);
            this.NullSkybox.SetData(CubeMapFace.PositiveX, new Color[] { Color.White });
            this.NullSkybox.SetData(CubeMapFace.NegativeX, new Color[] { Color.White });
            this.NullSkybox.SetData(CubeMapFace.PositiveY, new Color[] { Color.White });
            this.NullSkybox.SetData(CubeMapFace.NegativeY, new Color[] { Color.White });
            this.NullSkybox.SetData(CubeMapFace.PositiveZ, new Color[] { Color.White });
            this.NullSkybox.SetData(CubeMapFace.NegativeZ, new Color[] { Color.White });
        }
예제 #2
0
        public DeferredRenderPipeline(
            GraphicsDevice device,
            ShadowMapSystem shadowMapSystem,
            ModelSystem modelSystem,
            AveragedParticleSystem particleSystem,
            AdditiveParticleSystem additiveParticleSystem,
            ProjectorSystem projectorSystem,
            EffectFactory effectFactory,
            AmbientLightSystem ambientLightSystem,
            DirectionalLightSystem directionalLightSystem,
            PointLightSystem pointLightSystem,
            CascadedShadowMapSystem cascadedShadowMapSystem,
            ShadowCastingLightSystem shadowCastingLightSystem,
            SunlightSystem sunlightSystem,
            BoundarySystem boundarySystem,
            DynamicTextureSystem dynamicTextureSystem,
            IconSystem iconSystem,
            CutsceneSystem cutsceneSystem,
            IMeterRegistry meterRegistry)
        {
            this.ShadowMapSystem           = shadowMapSystem;
            this.ModelSystem               = modelSystem;
            this.TransparentParticleSystem = particleSystem;
            this.AdditiveParticleSystem    = additiveParticleSystem;
            this.ProjectorSystem           = projectorSystem;
            this.CombineEffect             = effectFactory.Construct <CombineEffect>();
            this.FxaaEffect               = effectFactory.Construct <FxaaEffect>();
            this.AmbientLightSystem       = ambientLightSystem;
            this.DirectionalLightSystem   = directionalLightSystem;
            this.PointLightSystem         = pointLightSystem;
            this.CascadedShadowMapSystem  = cascadedShadowMapSystem;
            this.ShadowCastingLightSystem = shadowCastingLightSystem;
            this.SunlightSystem           = sunlightSystem;
            this.BoundarySystem           = boundarySystem;
            this.DynamicTextureSystem     = dynamicTextureSystem;
            this.CutsceneSystem           = cutsceneSystem;
            this.IconSystem               = iconSystem;

            var width  = device.PresentationParameters.BackBufferWidth;
            var height = device.PresentationParameters.BackBufferHeight;

            this.GBuffer = new GBuffer(device, width, height);

            this.Input = new RenderPipelineInput();

            this.Settings = new RenderPipelineSettings();

            this.ShadowPipeline    = ShadowPipeline.Create(device, meterRegistry);
            this.LightingPipeline  = LightingPipeline.Create(device, meterRegistry);
            this.ModelPipeline     = ModelPipeline.Create(device, meterRegistry);
            this.ParticlePipeline  = ParticlePipeline.Create(device, meterRegistry);
            this.ProjectorPipeline = ProjectorPipeline.Create(device, meterRegistry);

            this.Pipeline = RenderPipeline.Create(device, meterRegistry);
            this.RootPass = new Pass(PassType.Opaque, 0);

            this.Recreate();
        }
예제 #3
0
        public APipeline(GraphicsDevice device, IMeterRegistry meterRegistry, string name)
        {
            this.Device        = device;
            this.MeterRegistry = meterRegistry;

            this.Stages = new List <IPipelineStage <T> >();

            this.StageGauge = $"{name}_stages_render_time";
            this.MeterRegistry.CreateGauge(this.StageGauge, "stage", "pass");
        }
예제 #4
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);
            }
        }
예제 #5
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);
            }
        }
예제 #6
0
        public RenderPipeline Build(GraphicsDevice device, IMeterRegistry meterRegistry)
        {
            var pipeline = RenderPipeline.Create(device, meterRegistry);

            pipeline
            .UpdateSystem(this.Systems.Get <AveragedParticleSystem>())
            .UpdateSystem(this.Systems.Get <AdditiveParticleSystem>())
            .UpdateSystem(this.Systems.Get <AnimationSystem>())
            .UpdateSystem(this.Systems.Get <UVAnimationSystem>());

            return(pipeline);
        }
예제 #7
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);
        }
예제 #8
0
        public ShadowMapSystem(
            GraphicsDevice device,
            IComponentContainer <ShadowMap> shadowMaps,
            ModelSystem modelSystem,
            AveragedParticleSystem particleSystem,
            IMeterRegistry meterRegistry)
        {
            this.Device         = device;
            this.ShadowMaps     = shadowMaps;
            this.ModelSystem    = modelSystem;
            this.ParticleSystem = particleSystem;
            this.MeterRegistry  = meterRegistry;

            this.MeterRegistry.CreateGauge(ShadowMapCounter);
            this.MeterRegistry.CreateGauge(ShadowMapTotal);
            this.MeterRegistry.CreateGauge(ShadowMapStep, "step");
        }
예제 #9
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);
            }
        }
예제 #10
0
        public PipelineBuilder(GraphicsDevice device, ShadowMapSystem shadowMapSystem, ModelSystem modelSystem, AveragedParticleSystem transparentParticleSystem, AdditiveParticleSystem additiveParticleSystem, ProjectorSystem projectorSystem, EffectFactory effectFactory, AmbientLightSystem ambientLightSystem, DirectionalLightSystem directionalLightSystem, PointLightSystem pointLightSystem, CascadedShadowMapSystem cascadedShadowMapSystem, ShadowCastingLightSystem shadowCastingLightSystem, SunlightSystem sunlightSystem, IconSystem iconSystem)
        {
            this.Device                    = device;
            this.ShadowMapSystem           = shadowMapSystem;
            this.ModelSystem               = modelSystem;
            this.TransparentParticleSystem = transparentParticleSystem;
            this.AdditiveParticleSystem    = additiveParticleSystem;
            this.ProjectorSystem           = projectorSystem;
            this.CombineEffect             = effectFactory.Construct <CombineEffect>();
            this.FxaaEffect                = effectFactory.Construct <FxaaEffect>();
            this.AmbientLightSystem        = ambientLightSystem;
            this.DirectionalLightSystem    = directionalLightSystem;
            this.PointLightSystem          = pointLightSystem;
            this.CascadedShadowMapSystem   = cascadedShadowMapSystem;
            this.ShadowCastingLightSystem  = shadowCastingLightSystem;
            this.SunlightSystem            = sunlightSystem;
            this.IconSystem                = iconSystem;

            this.MeterRegistry = new NullMeterRegistry();
        }
예제 #11
0
        public DeferredRenderPipeline(
            RenderPipelineBuilder renderPipelineBuilder,
            AnimationPipelineBuilder animationPipelineBuilder,
            IMeterRegistry meterRegistry,
            GraphicsDevice device)
        {
            this.RenderPipelineBuilder    = renderPipelineBuilder;
            this.AnimationPipelineBuilder = animationPipelineBuilder;
            this.MeterRegistry            = meterRegistry;

            var width  = device.PresentationParameters.BackBufferWidth;
            var height = device.PresentationParameters.BackBufferHeight;

            this.GBuffer = new GBuffer(device, width, height);

            this.Input = new RenderPipelineInput();

            this.Settings = new RenderPipelineSettings();
            this.RootPass = new Pass(PassType.Opaque, 0);

            this.Recreate();
        }
예제 #12
0
 public static ParticlePipeline Create(GraphicsDevice device, IMeterRegistry meterRegistry)
 => new ParticlePipeline(device, meterRegistry);
예제 #13
0
 private ShadowPipeline(GraphicsDevice device, IMeterRegistry meterRegistry)
     : base(device, meterRegistry, "shadow_pipeline")
 {
 }
예제 #14
0
 public static ModelPipeline Create(GraphicsDevice device, IMeterRegistry meterRegistry) => new ModelPipeline(device, meterRegistry);
예제 #15
0
 private LightingPipeline(GraphicsDevice device, IMeterRegistry meterRegistry)
     : base(device, meterRegistry, "lighting_pipeline")
 {
 }
예제 #16
0
 public static ShadowPipeline Create(GraphicsDevice device, IMeterRegistry meterRegistry) => new ShadowPipeline(device, meterRegistry);
예제 #17
0
 public RenderPipeline(GraphicsDevice device, IMeterRegistry meterRegistry)
     : base(device, meterRegistry, "render_pipeline")
 {
 }
예제 #18
0
 public static LightingPipeline Create(GraphicsDevice device, IMeterRegistry meterRegistry) => new LightingPipeline(device, meterRegistry);
예제 #19
0
 public static RenderPipeline Create(GraphicsDevice device, IMeterRegistry meterRegistry) => new RenderPipeline(device, meterRegistry);
예제 #20
0
 private ModelPipeline(GraphicsDevice device, IMeterRegistry meterRegistry)
     : base(device, meterRegistry, "model_pipeline")
 {
 }
예제 #21
0
 public static ProjectorPipeline Create(GraphicsDevice device, IMeterRegistry meterRegistry) => new ProjectorPipeline(device, meterRegistry);
예제 #22
0
 private ProjectorPipeline(GraphicsDevice device, IMeterRegistry meterRegistry)
     : base(device, meterRegistry, "projector_pipeline")
 {
 }
예제 #23
0
 private ParticlePipeline(GraphicsDevice device, IMeterRegistry meterRegistry)
     : base(device, meterRegistry, "particle_pipeline")
 {
 }