コード例 #1
0
        private void CreateRenderTargets(int width, int height)
        {
            Colors?.Dispose();
            Albedo?.Dispose();
            Normals?.Dispose();
            Depth?.Dispose();

#if OPENGL
            Colors  = new RenderTarget2D(GraphicsDevice, width, height, false, SurfaceFormat.HalfVector4, DepthFormat.Depth24Stencil8);
            Albedo  = new RenderTarget2D(GraphicsDevice, width, height, false, SurfaceFormat.HalfVector4, DepthFormat.Depth24Stencil8);
            Normals = new RenderTarget2D(GraphicsDevice, width, height, false, SurfaceFormat.HalfVector4, DepthFormat.Depth24Stencil8);
            Depth   = new RenderTarget2D(GraphicsDevice, width, height, false, SurfaceFormat.Vector2, DepthFormat.Depth24Stencil8);
#else
            Colors  = new RenderTarget2D(GraphicsDevice, width, height, false, SurfaceFormat.Rgba64, DepthFormat.Depth24Stencil8);
            Albedo  = new RenderTarget2D(GraphicsDevice, width, height, false, SurfaceFormat.Rgba64, DepthFormat.Depth24Stencil8);
            Normals = new RenderTarget2D(GraphicsDevice, width, height, false, SurfaceFormat.Rgba64, DepthFormat.Depth24Stencil8);
            Depth   = new RenderTarget2D(GraphicsDevice, width, height, false, SurfaceFormat.Vector2, DepthFormat.Depth24Stencil8);
#endif
            _bufferTextureSize = new Vector2(width, height);
            _gBufferTargets    = new[] {
                new RenderTargetBinding(Colors),
                new RenderTargetBinding(Normals),
                new RenderTargetBinding(Depth),
                new RenderTargetBinding(Albedo)
            };

            _lightMap?.Dispose();
            _lightMap = new RenderTarget2D(GraphicsDevice, width, height, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8);
        }