GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
ReflectionProbes3D.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Ivar Härnqvist
2// SPDX-License-Identifier: MIT
3
4#ifndef GREM_GRAPHICS_3D_REFLECTION_PROBES_3D_HPP
5#define GREM_GRAPHICS_3D_REFLECTION_PROBES_3D_HPP
6
8
13#include <GREM/core/math.hpp>
16
17namespace grem::graphics {
18
19class Device; // Forward declaration, to avoid including Device.hpp.
20class RenderPass; // Forward declaration, to avoid including RenderPass.hpp.
21class Renderer3D; // Forward declaration, to avoid a circular include of Renderer3D.hpp.
22class LightBaker3D; // Forward declaration, to avoid a circular include of LightBaker3D.hpp.
23
81
92
100 [[nodiscard]] constexpr bool operator==(const ReflectionProbes3DOptions& other) const noexcept = default;
101};
102
107public:
121
125 using AtlasBuffer = UniformBuffer<AtlasParameters, "ReflectionProbes3DAtlases">;
126
155
159 using ProbeBuffer = StorageBuffer<ProbeFields, "LightProbeVolumes3DProbes">;
160
165 .minificationFilter = TextureFilter::LINEAR,
166 .magnificationFilter = TextureFilter::LINEAR,
167 .mipmapMode = TextureMipmapMode::LINEAR,
168 .horizontalWrappingMode = TextureWrappingMode::CLAMP_TO_EDGE,
169 .verticalWrappingMode = TextureWrappingMode::CLAMP_TO_EDGE,
170 .maxAnisotropy = 1.0f,
171 };
172
185 GREM_API(graphics_3d) explicit ReflectionProbes3D(Device& device, const ReflectionProbes3DOptions& options = {});
186
205 GREM_API(graphics_3d) ReflectionProbes3D(Device& device, Texture reflectionMaps, ArrayList<ReflectionProbeOptions3D> probeOptions, const ReflectionProbes3DOptions& options);
206
210 GREM_API(graphics_3d) void clearReflectionProbes() noexcept;
211
221 GREM_API(graphics_3d) void addReflectionProbe(const ReflectionProbeOptions3D& options);
222
234 GREM_API(graphics_3d) void setReflectionProbes(const ReflectionProbes3DOptions& newOptions);
235
251 GREM_API(graphics_3d) void setReflectionProbes(Texture newReflectionMaps, ArrayList<ReflectionProbeOptions3D> newProbeOptions, const ReflectionProbes3DOptions& newOptions);
252
260 [[nodiscard]] const Texture& getReflectionMaps() const noexcept {
261 return reflectionMaps;
262 }
263
271 return probeOptions;
272 }
273
279 [[nodiscard]] ReflectionProbes3DOptions getOptions() const noexcept {
280 return options;
281 }
282
283private:
284 friend Renderer3D;
285 friend LightBaker3D;
286
287 GREM_API(graphics_3d) void flushProbesAndTextures(Device& device) const;
288 GREM_API(graphics_3d) void flush(Device& device, Renderer3D& renderer3D) const;
289
292 mutable Texture reflectionMaps{};
293 mutable Buffer<ProbeFields> probes{};
294 mutable Buffer<float> worldSpaceBoxVolumes{};
295 mutable AtlasBuffer atlasBuffer;
296 mutable ProbeBuffer probeBuffer;
297 mutable bool probesDirty = false;
298 mutable bool texturesDirty = false;
299 mutable bool buffersDirty = true;
300};
301
302} // namespace grem::graphics
303
304#endif
Definition ArrayList.hpp:27
Definition Span.hpp:146
Persistent system managing the rendering context of a Window.
Definition Device.hpp:68
System for pre-baking global illumination.
Definition LightBaker3D.hpp:134
UniformBuffer< AtlasParameters, "ReflectionProbes3DAtlases"> AtlasBuffer
Shader buffer for reflection probe atlases.
Definition ReflectionProbes3D.hpp:125
ReflectionProbes3DOptions getOptions() const noexcept
Get the configuration options of the reflection probe set.
Definition ReflectionProbes3D.hpp:279
StorageBuffer< ProbeFields, "LightProbeVolumes3DProbes"> ProbeBuffer
Shader buffer for reflection probes.
Definition ReflectionProbes3D.hpp:159
const Texture & getReflectionMaps() const noexcept
Get the reflection maps of the reflection probes.
Definition ReflectionProbes3D.hpp:260
Span< const ReflectionProbeOptions3D > getProbeOptions() const noexcept
Get the configuration options for the reflection probes in the set.
Definition ReflectionProbes3D.hpp:270
void addReflectionProbe(const ReflectionProbeOptions3D &options)
Add a reflection probe to the set.
ReflectionProbes3D(Device &device, Texture reflectionMaps, ArrayList< ReflectionProbeOptions3D > probeOptions, const ReflectionProbes3DOptions &options)
Construct a pre-baked set of reflection probes.
ReflectionProbes3D(Device &device, const ReflectionProbes3DOptions &options={})
Construct an empty set of reflection probes.
static constexpr TextureSamplerOptions REFLECTION_MAPS_SAMPLER_OPTIONS
Sampler options to use for the reflection maps of reflection probes.
Definition ReflectionProbes3D.hpp:164
void clearReflectionProbes() noexcept
Remove all reflection probes from the set.
void setReflectionProbes(const ReflectionProbes3DOptions &newOptions)
Set the reflection probe set to the default empty set with new options.
Backend-specific implementation of RenderPass.
Definition RenderPass.hpp:38
Persistent system that provides 3D rendering capabilities.
Definition Renderer3D.hpp:120
GPU memory buffer containing an array of structs to be read by a shader program.
Definition buffers.hpp:493
Storage for multidimensional data, such as 2D images, on the GPU, combined with a sampler configurati...
Definition Texture.hpp:700
GPU memory buffer containing a fixed-size struct of uniform parameters to be read by a shader program...
Definition buffers.hpp:426
Definition buffer_layouts.hpp:20
@ CLAMP_TO_EDGE
Clamp to the edge of the texture when sampling outside the 0-1 range.
Definition Texture.hpp:492
@ LINEAR
Interpolate between the two nearest mip levels to the displayed size.
Definition Texture.hpp:484
@ LINEAR
Interpolate between texels for a smoother appearance.
Definition Texture.hpp:475
qua< float > quat
Definition math.hpp:892
vec< 4, float > vec4
Definition math.hpp:440
vec< 3, float > vec3
Definition math.hpp:439
Configuration options for a reflection probe in a ReflectionProbes3D set.
Definition ReflectionProbes3D.hpp:27
vec3 blendWidthsOnNegativeSides
Size of the blend padding along each local axis on the local negative sides of the affected region.
Definition ReflectionProbes3D.hpp:65
quat orientation
Orientation of the reflection probe box in world space.
Definition ReflectionProbes3D.hpp:36
vec3 localAffectedRegionSize
Size of the local region of the reflection probe box where the reflection will be visible.
Definition ReflectionProbes3D.hpp:57
vec3 captureOffset
Offset of the reflection probe's capture position from the center of the box in world space.
Definition ReflectionProbes3D.hpp:79
vec3 center
Center position of the reflection probe box in world space.
Definition ReflectionProbes3D.hpp:31
vec3 size
Size of the reflection probe box along each local axis.
Definition ReflectionProbes3D.hpp:43
vec3 blendWidthsOnPositiveSides
Size of the blend padding along each local axis on the local positive sides of the affected region.
Definition ReflectionProbes3D.hpp:73
vec3 localAffectedRegionOffset
Offset of the center of the local region of the reflection probe box where the reflection will be vis...
Definition ReflectionProbes3D.hpp:49
Configuration options for a ReflectionProbes3D set.
Definition ReflectionProbes3D.hpp:85
constexpr bool operator==(const ReflectionProbes3DOptions &other) const noexcept=default
Compare these options to another set of options for equality.
uint32_t reflectionMapResolution
Width, in texels, of the reflection maps of reflection probes.
Definition ReflectionProbes3D.hpp:91
Struct of shader parameters representing the reflection probe atlases.
Definition ReflectionProbes3D.hpp:111
float reflectionProbesReflectionMapDetailLevelMax
Maximum mip level in the reflection maps of the reflection probes.
Definition ReflectionProbes3D.hpp:119
float reflectionProbesReflectionMapDetailLevelScale
Scale of the reflection probes reflection detail level.
Definition ReflectionProbes3D.hpp:116
samplerCubeArray reflectionProbesReflectionMaps
Sampler for the reflection maps of the reflection probes.
Definition ReflectionProbes3D.hpp:113
Struct of shader fields representing a reflection probe.
Definition ReflectionProbes3D.hpp:130
vec3 reflectionProbeCenter
Center position of the reflection probe box in world space.
Definition ReflectionProbes3D.hpp:132
vec3 reflectionProbeCaptureOffset
Offset of the reflection probe's capture position from the center of the box in world space.
Definition ReflectionProbes3D.hpp:153
vec3 reflectionProbeBlendWidthsOnNegativeSides
Size of the reflection probe box's blend padding along each local axis on the local negative sides of...
Definition ReflectionProbes3D.hpp:147
vec3 reflectionProbeBlendWidthsOnPositiveSides
Size of the reflection probe box's blend padding along each local axis on the local positive sides of...
Definition ReflectionProbes3D.hpp:150
vec3 reflectionProbeLocalAffectedRegionOffset
Offset of the center of the local region of the reflection probe box where the reflection will be vis...
Definition ReflectionProbes3D.hpp:141
vec3 reflectionProbeSize
Size of the reflection probe box along each local axis.
Definition ReflectionProbes3D.hpp:138
vec3 reflectionProbeLocalAffectedRegionSize
Size of the local region of the reflection probe box where the reflection will be visible.
Definition ReflectionProbes3D.hpp:144
vec4 reflectionProbeOrientation
Components of the quaternion representing the orientation of the reflection probe box in world space.
Definition ReflectionProbes3D.hpp:135
Configuration options for the sampler of a Texture.
Definition Texture.hpp:617
Reference to a samplerCubeArray Texture that may be used as a parameter value type in a shader-read b...
Definition ParameterDescription.hpp:179