// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. #pragma once #include "RendererPass.h" /// /// Rendering scene to the GBuffer /// class GBufferPass : public RendererPass { private: AssetReference _gBufferShader; GPUPipelineState* _psDebug = nullptr; AssetReference _skyModel; AssetReference _boxModel; #if USE_EDITOR class LightmapUVsDensityMaterialShader* _lightmapUVsDensity = nullptr; class VertexColorsMaterialShader* _vertexColors = nullptr; class LODPreviewMaterialShader* _lodPreview = nullptr; class MaterialComplexityMaterialShader* _materialComplexity = nullptr; #endif public: /// /// Fill GBuffer /// /// The rendering context. /// Light buffer to output material emissive light and precomputed indirect lighting void Fill(RenderContext& renderContext, GPUTextureView* lightBuffer); /// /// Render debug view /// /// The rendering context. void RenderDebug(RenderContext& renderContext); /// /// Renders the sky or skybox into low-resolution cubemap. Can be used to sample realtime sky lighting in GI passes. /// /// The rendering context. /// The GPU context. /// Rendered cubemap or null if not ready or failed. GPUTextureView* RenderSkybox(RenderContext& renderContext, GPUContext* context); #if USE_EDITOR void DrawMaterialComplexity(RenderContext& renderContext, GPUContext* context, GPUTextureView* lightBuffer); #endif public: static bool IsDebugView(ViewMode mode); /// /// Set GBuffer inputs structure for given render task /// /// The rendering view. /// GBuffer input to setup static void SetInputs(const RenderView& view, GBufferData& gBuffer); private: void DrawSky(RenderContext& renderContext, GPUContext* context); void DrawDecals(RenderContext& renderContext, GPUTextureView* lightBuffer); #if COMPILE_WITH_DEV_ENV void OnShaderReloading(Asset* obj) { _psDebug->ReleaseGPU(); invalidateResources(); } #endif public: // [RendererPass] String ToString() const override; bool Init() override; void Dispose() override; protected: // [RendererPass] bool setupResources() override; };