Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
DynamicGI.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
20#pragma once
21
22#include "../../core/Types.hpp"
24#include "../rhi/GfxEnums.hpp"
25
26#include <glm/glm.hpp>
27#include <vector>
28
29namespace esengine {
30
31class GfxDevice;
32class RenderContext;
33
55
61 std::vector<f32> header;
63 std::vector<f32> sdf;
65 std::vector<f32> instances;
67 std::vector<u32> pixels;
71 bool full = true;
73};
74
95
98
101
103public:
104 DynamicGI(GfxDevice& device, RenderContext& context);
105 ~DynamicGI();
106
107 DynamicGI(const DynamicGI&) = delete;
108 DynamicGI& operator=(const DynamicGI&) = delete;
109
111 rg::ResourceId declare(rg::RenderGraph& graph, rg::ResourceId input, rg::ResourceId scene, const DynamicGIParams& params, u32 width, u32 height);
112
113 void release();
114
115private:
116 bool ensure();
117 bool upload();
118 bool ensureProbes(u32 tilesX, u32 tilesY);
119
120 GfxDevice& device_;
121 RenderContext& context_;
127 u32 sdfBytes_ = 0, instanceBytes_ = 0, pixelBytes_ = 0, radianceBytes_ = 0;
131 u32 probeTilesX_ = 0, probeTilesY_ = 0;
137 u32 uploadedVersion_ = 0;
138 bool failed_ = false;
139 u32 frame_ = 0;
140 u32 pixelCount_ = 0;
142 u32 probeSpacing_ = 8;
143};
144
145} // namespace esengine
Backend-agnostic graphics enumerations.
Full-screen passes as a declared graph: what each one reads, what it writes, and at what size — the g...
Core type definitions and utilities for ESEngine.
DynamicGI(const DynamicGI &)=delete
rg::ResourceId declare(rg::RenderGraph &graph, rg::ResourceId input, rg::ResourceId scene, const DynamicGIParams &params, u32 width, u32 height)
DynamicGI & operator=(const DynamicGI &)=delete
DynamicGI(GfxDevice &device, RenderContext &context)
Abstract graphics device interface.
Definition GfxDevice.hpp:75
DynamicGIScene & dynamicGIScene()
Definition DynamicGI.cpp:15
ComputeHandle
A compute program (GfxDevice::createCompute); only a device that supportsCompute() issues one.
Definition GfxEnums.hpp:39
const DynamicGIStats & dynamicGIStats()
Definition DynamicGI.cpp:24
std::uint32_t u32
Unsigned 32-bit integer.
Definition Types.hpp:45
constexpr u32 kDynamicGIStatFloats
Definition DynamicGI.hpp:94
float f32
32-bit floating point
Definition Types.hpp:59
f32 intensity
How much of the gathered light is added over the picture.
Definition DynamicGI.hpp:37
f32 blend
How much of each frame's card lighting replaces what the card held (the rest is history,...
Definition DynamicGI.hpp:39
u32 skip
For measuring: skip the cards (1), the probes (2) or the apply (4), to read what the rest of the fram...
Definition DynamicGI.hpp:45
u32 cardSlices
The cards are relit a slice at a time over this many frames (their light changes slowly; the cost is ...
Definition DynamicGI.hpp:41
u32 probeSpacing
Pixels between probes: 0 picks about 160 x 90 probes whatever the picture size.
Definition DynamicGI.hpp:47
u32 probeStride
One in this many of a probe rays is traced each frame, alternating, so the history fills the rest in.
Definition DynamicGI.hpp:43
f32 probeDensity
How many of the rows of probes the picture would have are kept, 0.25 to 1 (it acts where probeSpacing...
Definition DynamicGI.hpp:52
std::vector< f32 > sdf
The distance field, dim^3 cells, toroidal.
Definition DynamicGI.hpp:63
std::vector< u32 > pixels
4 words a card pixel.
Definition DynamicGI.hpp:67
std::vector< f32 > header
Header: sdf dim, cell size, origin x y z (cells), reach, instance count, card pixel count,...
Definition DynamicGI.hpp:61
std::vector< f32 > instances
64 floats an instance.
Definition DynamicGI.hpp:65
f32 probeSpacing
Pixels between probes, and how many probes there are.
Definition DynamicGI.hpp:83
f32 residentBytes
What the effect keeps in video memory.
Definition DynamicGI.hpp:91
f32 probeRays
Rays traced this frame by the probes (a probe has 64, one in stride of them a frame) and by the cards...
Definition DynamicGI.hpp:85
f32 applyPixels
Pixels the apply pass visits, and the texture reads it makes of each (the four nearest probes; twelve...
Definition DynamicGI.hpp:87
f32 forcedAttachmentBytes
What the scene pass writes only because this effect is on: the G-buffer (8 bytes a pixel) and the alb...
Definition DynamicGI.hpp:89