public GBuffer(GraphicsDevice graphics, GBufferInitParams p) { this.graphics = graphics; this.p = p; Rebuild(); }
public void Rebuild(GBufferInitParams newP = default) { p = newP ?? p; DestroySurfaces(); int backBufferWidth = graphics.PresentationParameters.BackBufferWidth; int backBufferHeight = graphics.PresentationParameters.BackBufferHeight; color = new RenderTarget2D(graphics, backBufferWidth, backBufferHeight, false, p.Color, DepthFormat.Depth24Stencil8); depth = new RenderTarget2D(graphics, backBufferWidth, backBufferHeight, false, p.Depth, DepthFormat.Depth24Stencil8); normal = new RenderTarget2D(graphics, backBufferWidth, backBufferHeight, false, p.Normal, DepthFormat.Depth24Stencil8); specular = new RenderTarget2D(graphics, backBufferWidth, backBufferHeight, false, p.Specular, DepthFormat.Depth24Stencil8); colorAccum = new RenderTarget2D(graphics, backBufferWidth, backBufferHeight, false, p.ColorAccumulation, DepthFormat.None); int width = backBufferWidth; int height = backBufferHeight; int steps = 0; while (width > 4 || height > 4) { width /= 2; height /= 2; steps++; } width = backBufferWidth; height = backBufferHeight; for (int i = 0; i < steps; i++) { if (width > 1) { width /= 2; } if (height > 1) { height /= 2; } } LumAccumulator = new RenderTarget2D(graphics, width, height, false, SurfaceFormat.HalfVector4, DepthFormat.None); LumStorage = new RenderTarget2D(graphics, width, height, false, SurfaceFormat.HalfVector4, DepthFormat.None); }
public DeferredRenderer(GraphicsDevice graphics, ContentManager content, GBufferInitParams p) { this.graphics = graphics; this.content = content; fullScreen = new FullScreenDraw(graphics); fillEffect = new FillGBufferEffect(content.Load <Effect>("FillGBuffer")); backgroundEffect = new BackgroundEffect(content.Load <Effect>("Background")); postEffect = content.Load <Effect>("PostProcess"); clearEffect = content.Load <Effect>("Clear"); targets = new GBuffer(graphics, p); lighting = new LightingStep(graphics, content, targets, fullScreen); downscaler = new Downscaler(graphics, content, targets, fullScreen); bloom = new Bloom(graphics, content, fullScreen); luminanceAverager = new Averager(graphics, content, fullScreen); drawStep.GraphicsDevice = graphics; }