예제 #1
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();
 }
예제 #2
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
            };
        }