Exemple #1
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;
 }
Exemple #2
0
        public PointLightSystem(GraphicsDevice device, SphereLightVolume volume, PointLightEffect effect, FrameService frameService)
        {
            this.Device       = device;
            this.FrameService = frameService;
            this.Volume       = volume;
            this.Effect       = effect;

            this.InsideRasterizer = new RasterizerState()
            {
                CullMode        = CullMode.CullClockwiseFace,
                DepthClipEnable = false
            };

            this.OutsideRasterizer = new RasterizerState()
            {
                CullMode        = CullMode.CullCounterClockwiseFace,
                DepthClipEnable = false
            };
        }
Exemple #3
0
        public DeferredColoredChunkRenderer(EngineConfiguration config, ContentLibrary contentLibrary, GraphicsDevice device, CameraManager cameraManager, IChunkManager chunkManager)
        {
            _device = device;
            _sb     = new SpriteBatch(_device);

            _halfPixel = new Vector2(0.5f / _device.PresentationParameters.BackBufferWidth, 0.5f / _device.PresentationParameters.BackBufferHeight);

            _quadRenderer = new QuadRenderer(_device);

            _clearEffect            = new ClearEffect(contentLibrary.ClearEffect);
            _renderGBufferEffect    = new RenderGBufferColorEffect(contentLibrary.RenderGBufferColorEffect);
            _renderCombineEffect    = new RenderCombineEffect(contentLibrary.RenderCombineEffect);
            _directionalLightEffect = new DirectionalLightEffect(contentLibrary.DirectionalLightEffect);
            _pointLightEffect       = new PointLightEffect(contentLibrary.PointLightEffect);
            _ssaoEffect             = new SSAOEffect(contentLibrary.SSAOEffect);

            _camManager = cameraManager;
            _chunks     = chunkManager;

            _debugOptions = ChunkRendererDebugOptions.NONE;

            basicEffect = contentLibrary.BasicEffect;

            _uiFontTiny = contentLibrary.UIFontTiny;

            _albedoTarget = new RenderTarget2D(_device, _device.PresentationParameters.BackBufferWidth, _device.PresentationParameters.BackBufferHeight, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8);
            _lightTarget  = new RenderTarget2D(_device, _device.PresentationParameters.BackBufferWidth, _device.PresentationParameters.BackBufferHeight, false, SurfaceFormat.Color, DepthFormat.None);
            _normalTarget = new RenderTarget2D(_device, _device.PresentationParameters.BackBufferWidth, _device.PresentationParameters.BackBufferHeight, false, SurfaceFormat.Color, DepthFormat.None);
            _depthTarget  = new RenderTarget2D(_device, _device.PresentationParameters.BackBufferWidth, _device.PresentationParameters.BackBufferHeight, false, SurfaceFormat.Single, DepthFormat.Depth24Stencil8);

            _randomMap = new Texture2D(_device, _device.PresentationParameters.BackBufferWidth, _device.PresentationParameters.BackBufferHeight);
            CreateRandomNormalTexture(_randomMap);

            _debugRasterizerState = new RasterizerState()
            {
                CullMode = Microsoft.Xna.Framework.Graphics.CullMode.None, FillMode = Microsoft.Xna.Framework.Graphics.FillMode.WireFrame
            };
            _rasterizerState = new RasterizerState()
            {
                CullMode = Microsoft.Xna.Framework.Graphics.CullMode.CullCounterClockwiseFace
            };
        }
        public override void Init(RendererBase <ToyWorld> renderer, ToyWorld world, EffectSettings settings)
        {
            Settings = settings;

            if (Settings.EnabledEffects.HasFlag(RenderRequestEffect.Lights))
            {
                if (m_pointLightEffect == null)
                {
                    m_pointLightEffect = new PointLightEffect();
                }
            }

            if (Settings.EnabledEffects.HasFlag(RenderRequestEffect.Smoke))
            {
                if (m_smokeEffect == null)
                {
                    m_smokeEffect = renderer.EffectManager.Get <SmokeEffect>();
                }
                renderer.EffectManager.Use(m_smokeEffect); // Need to use the effect to set uniforms
                m_smokeEffect.SmokeColorUniform(new Vector4(Settings.SmokeColor.R, Settings.SmokeColor.G, Settings.SmokeColor.B, Settings.SmokeColor.A) / 255f);
            }
        }