Example #1
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();
        }
        public AveragedParticleSystem(
            GraphicsDevice device,
            EffectFactory effectFactory,
            IComponentContainer <AveragedEmitter> emitters)
        {
            this.Device = device;
            this.WeightedParticlesEffect = effectFactory.Construct <WeightedParticlesEffect>();
            this.AverageParticlesEffect  = effectFactory.Construct <AverageParticlesEffect>();
            this.Emitters = emitters;

            this.Particles = new List <ParticlePose>();

            this.FullScreenTriangle = new FullScreenTriangle();
            this.Quad = new UnitQuad(device);
        }
Example #3
0
        public ImGuiRenderer(Game game, EffectFactory effectFactory)
        {
            var context = ImGui.CreateContext();

            ImGui.SetCurrentContext(context);

            this.Game           = game;
            this.Effect         = effectFactory.Construct <UIEffect>();
            this.GraphicsDevice = game.GraphicsDevice;

            this.LoadedTextures = new Dictionary <IntPtr, TextureReference>();

            this.RasterizerState = new RasterizerState()
            {
                CullMode             = CullMode.None,
                DepthBias            = 0,
                FillMode             = FillMode.Solid,
                MultiSampleAntiAlias = false,
                ScissorTestEnable    = true,
                SlopeScaleDepthBias  = 0
            };

            this.TextureContrast = 1.0f;

            this.SetupInput();
            this.RebuildFontAtlas();
        }
Example #4
0
 public PointLightSystem(GraphicsDevice device, EffectFactory effectFactory, LightPrimitiveLoader lightPrimitiveLoader, IComponentContainer <PointLight> lights)
 {
     this.Device = device;
     this.Effect = effectFactory.Construct <PointLightEffect>();
     this.Sphere = lightPrimitiveLoader.UnitSphere();
     this.Lights = lights;
 }
Example #5
0
 public DirectionalLightSystem(GraphicsDevice device, EffectFactory effectFactory, IComponentContainer <DirectionalLight> lights)
 {
     this.Device             = device;
     this.Effect             = effectFactory.Construct <DirectionalLightEffect>();
     this.Lights             = lights;
     this.FullScreenTriangle = new FullScreenTriangle();
 }
Example #6
0
 public IconSystem(GraphicsDevice device, EffectFactory effectFactory, IComponentContainer <DebugInfo> debugInfos, IList <IComponentContainer> containers, IconLibrary library)
     : base(debugInfos, containers)
 {
     this.Device  = device;
     this.Effect  = effectFactory.Construct <TextureEffect>();
     this.Library = library;
     this.Quad    = new UnitQuad(device);
 }
Example #7
0
 public BoundarySystem(GraphicsDevice device, EffectFactory effectFactory, IComponentContainer <DebugInfo> components, IComponentContainer <Bounds> bounds)
 {
     this.Device     = device;
     this.Components = components;
     this.Bounds     = bounds;
     this.Effect     = effectFactory.Construct <ColorEffect>();
     this.Bound      = new BoundsDrawer3D(device);
     this.Quad       = new BoundsDrawer2D(device);
 }
Example #8
0
 public IconSystem(GraphicsDevice device, EffectFactory effectFactory, IComponentContainer <DebugInfo> components, IComponentContainer <Pose> poses, IconLibrary library)
 {
     this.Device     = device;
     this.Components = components;
     this.Poses      = poses;
     this.Effect     = effectFactory.Construct <TextureEffect>();
     this.Library    = library;
     this.Quad       = new UnitQuad(device);
 }
Example #9
0
        public ProjectorSystem(GraphicsDevice device, IComponentContainer <Projector> projectors, EffectFactory effectFactory)
        {
            this.Device     = device;
            this.Projectors = projectors;
            this.Effect     = effectFactory.Construct <ProjectorEffect>();

            this.FrustumDrawer = new BoundsDrawer3D(device);
            this.Technique     = ProjectorEffectTechniques.Projector;
        }
Example #10
0
        public BoundarySystem(GraphicsDevice device, EffectFactory effectFactory, IComponentContainer <DebugInfo> debugInfos, IList <IComponentContainer> containers)
            : base(debugInfos, containers)
        {
            this.Device = device;
            this.Effect = effectFactory.Construct <ColorEffect>();

            this.Bounds = new BoundsDrawer3D(device);
            this.Quad   = new BoundsDrawer2D(device);
        }
Example #11
0
        public LineSystem(GraphicsDevice device, EffectFactory effectFactory, IComponentContainer <DebugLine> components)
        {
            this.Device     = device;
            this.Components = components;

            this.Effect = effectFactory.Construct <ColorEffect>();

            this.vertices = new VertexPosition[0];
            this.indices  = new short[0];
        }
Example #12
0
        public SunlightSystem(GraphicsDevice device, EffectFactory effectFactory, IComponentContainer <Sunlight> Lights,
                              CascadedShadowMapFactory cascadedShadowMapFactory)
        {
            this.Device = device;
            this.Effect = effectFactory.Construct <SunlightEffect>();
            this.Lights = Lights;

            this.FullScreenTriangle = new FullScreenTriangle();
            this.Frustum            = new Frustum();
        }
Example #13
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();
        }
Example #14
0
        public ShadowCastingLightSystem(
            GraphicsDevice device,
            IComponentContainer <ShadowCastingLight> lights,
            EffectFactory effectFactory,
            ShadowMapSystem shadowMapSystem)
        {
            this.Device          = device;
            this.Effect          = effectFactory.Construct <ShadowCastingLightEffect>();
            this.Lights          = lights;
            this.ShadowMapSystem = shadowMapSystem;

            this.FrustumDrawer = new BoundsDrawer3D(device);
        }
        public AdditiveParticleSystem(
            GraphicsDevice device,
            EffectFactory effectFactory,
            IComponentContainer <AdditiveEmitter> emitters)
        {
            this.Device = device;

            this.AdditiveParticlesEffect = effectFactory.Construct <AdditiveParticlesEffect>();
            this.Emitters = emitters;

            this.Particles = new List <ParticlePose>();
            this.Quad      = new UnitQuad(device);
        }
Example #16
0
        public AmbientLightSystem(GraphicsDevice device, EffectFactory effectFactory, IComponentContainer <AmbientLight> lights)
        {
            this.Device             = device;
            this.Effect             = effectFactory.Construct <AmbientLightEffect>();
            this.BlurEffect         = effectFactory.Construct <BlurEffect>();
            this.Lights             = lights;
            this.FullScreenTriangle = new FullScreenTriangle();

            this.Kernel = this.GenerateKernel();

            var random = new Random(255);

            this.NoiseMap     = new Texture2D(device, 64, 64, false, SurfaceFormat.Color);
            SimplexNoise.Seed = random.Next();
            var noiseX = SimplexNoise.Calc2D(this.NoiseMap.Width, this.NoiseMap.Height, 1.0f);

            SimplexNoise.Seed = random.Next();
            var noiseY = SimplexNoise.Calc2D(this.NoiseMap.Width, this.NoiseMap.Height, 1.0f);

            SimplexNoise.Seed = random.Next();
            var noiseZ = SimplexNoise.Calc2D(this.NoiseMap.Width, this.NoiseMap.Height, 1.0f);

            var noise = new Color[this.NoiseMap.Width * this.NoiseMap.Height];

            for (var y = 0; y < this.NoiseMap.Height; y++)
            {
                for (var x = 0; x < this.NoiseMap.Width; x++)
                {
                    var r = (noiseX[x, y] / 128.0f) - 1.0f;
                    var g = (noiseY[x, y] / 128.0f) - 1.0f;
                    var b = (noiseZ[x, y] / 128.0f) - 1.0f;

                    noise[x * y] = new Color(r, g, b);
                }
            }

            this.NoiseMap.SetData(noise);
        }
Example #17
0
        public GeometrySystem(
            GraphicsDevice device,
            EffectFactory effectFactory,
            IComponentContainer <Geometry> geometries,
            IComponentContainer <Pose> poses,
            IComponentContainer <Bounds> bounds)
        {
            this.Device     = device;
            this.Geometries = geometries;
            this.Poses      = poses;
            this.Bounds     = bounds;

            this.Effect = effectFactory.Construct <RenderEffect>();
        }