GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::graphics::LightBaker3D Class Reference

System for pre-baking global illumination. More...

#include <GREM/graphics_3d/LightBaker3D.hpp>

Public Member Functions

 LightBaker3D (Device &device, Renderer3D &renderer3D, const LightBaker3DOptions &options={})
 Construct a light baker.
void bakeSkybox (Sky3D &sky, Texture newSkyTexture, const Sky3DOptions &newSkyOptions)
 Render a sky map texture onto a sky.
void bakeSkybox (Sky3D &sky, const resource::ImageView &newSkyImage, const Sky3DOptions &newSkyOptions, const TextureImageUploadOptions &newSkyImageUploadOptions={.convertToPremultipliedAlpha=false,.generateMipmap=false})
 Render a sky map image onto a sky.
void bakeDiffuseLighting (LightProbeVolumes3D &lightProbeVolumes, FunctionView< void(RenderPass &, const Camera3D &)> drawRadiance, FunctionView< void(RenderPass &, const Camera3D &)> drawDistance)
 Render the irradiance and distance maps of a set of light probe volumes.
void bakeLightProbeIrradianceMap (LightProbeVolumes3D &lightProbeVolumes, uint32_t lightProbeVolumeIndex, u32vec3 lightProbeGridIndices, FunctionView< void(RenderPass &, const Camera3D &)> drawRadiance)
 Render the irradiance map of a single light probe of a specific volume in a set of light probe volumes.
void bakeAllLightProbeIrradianceMaps (LightProbeVolumes3D &lightProbeVolumes, FunctionView< void(RenderPass &, const Camera3D &)> drawRadiance)
 Render the irradiance maps of all light probes of all volumes in a set of light probe volumes.
void bakeLightProbeDistanceMap (LightProbeVolumes3D &lightProbeVolumes, uint32_t lightProbeVolumeIndex, u32vec3 lightProbeGridIndices, FunctionView< void(RenderPass &, const Camera3D &)> drawDistance)
 Render the distance map of a single light probe of a specific volume in a set of light probe volumes.
void bakeAllLightProbeDistanceMaps (LightProbeVolumes3D &lightProbeVolumes, FunctionView< void(RenderPass &, const Camera3D &)> drawDistance)
 Render the distance maps of all light probes of all volumes in a set of light probe volumes.
void bakeSpecularReflections (ReflectionProbes3D &reflectionProbes, FunctionView< void(RenderPass &, const Camera3D &)> drawReflection)
 Render the reflection maps of a set of reflection probes.
void bakeReflectionProbeReflectionMap (ReflectionProbes3D &reflectionProbes, uint32_t reflectionProbeIndex, FunctionView< void(RenderPass &, const Camera3D &)> drawReflection)
 Render the reflection map of a single reflection probe in a set of reflection probes.
void bakeAllReflectionProbeReflectionMaps (ReflectionProbes3D &reflectionProbes, FunctionView< void(RenderPass &, const Camera3D &)> drawReflection)
 Render all reflection maps in a set of reflection probes.
Texture generateCubemapFromEquirectangularMap (TextureFormat internalFormat, uint32_t resolution, const Texture &equirectangularMap, Optional< TextureSamplerOptions > samplerOptions=TextureSamplerOptions{ .minificationFilter=TextureFilter::LINEAR,.magnificationFilter=TextureFilter::LINEAR,.mipmapMode=TextureMipmapMode::NONE,.horizontalWrappingMode=TextureWrappingMode::CLAMP_TO_EDGE,.verticalWrappingMode=TextureWrappingMode::CLAMP_TO_EDGE,.maxAnisotropy=1.0f, })
 Generate a cubemap from a 2D equirectangular map texture.

Detailed Description

System for pre-baking global illumination.

Constructor & Destructor Documentation

◆ LightBaker3D()

grem::graphics::LightBaker3D::LightBaker3D ( Device & device,
Renderer3D & renderer3D,
const LightBaker3DOptions & options = {} )

Construct a light baker.

Parameters
devicedevice to create the baker for. Must outlive the baker.
renderer3Dsystem providing 3D rendering capabilities. Must outlive the baker.
optionsbaking options, see LightBaker3DOptions.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

Member Function Documentation

◆ bakeSkybox() [1/2]

void grem::graphics::LightBaker3D::bakeSkybox ( Sky3D & sky,
Texture newSkyTexture,
const Sky3DOptions & newSkyOptions )

Render a sky map texture onto a sky.

Parameters
skysky to render onto.
newSkyTexturenew sky texture to set. Must be a cube texture, an equirectangular 2D texture or an empty texture without a value.
newSkyOptionssky options, see SkyOptions.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ bakeSkybox() [2/2]

void grem::graphics::LightBaker3D::bakeSkybox ( Sky3D & sky,
const resource::ImageView & newSkyImage,
const Sky3DOptions & newSkyOptions,
const TextureImageUploadOptions & newSkyImageUploadOptions = {.convertToPremultipliedAlpha=false,.generateMipmap=false} )

Render a sky map image onto a sky.

Parameters
skysky to render onto.
newSkyImagenew sky map image to set. Must be a cube image, an equirectangular 2D image or an empty image without a value.
newSkyOptionssky options, see SkyOptions.
newSkyImageUploadOptionsoptions for the new sky map image to set, see TextureImageUploadOptions.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ bakeDiffuseLighting()

void grem::graphics::LightBaker3D::bakeDiffuseLighting ( LightProbeVolumes3D & lightProbeVolumes,
FunctionView< void(RenderPass &, const Camera3D &)> drawRadiance,
FunctionView< void(RenderPass &, const Camera3D &)> drawDistance )

Render the irradiance and distance maps of a set of light probe volumes.

Parameters
lightProbeVolumesset of light probe volumes to bake.
drawRadiancefunction that records the draw commands for the radiance of the surroundings of the light probes. Should draw an image from the given camera's perspective in HDR color without tonemapping onto the given render pass. The alpha channel of the drawn image is ignored.
drawDistancefunction that records the draw commands for the distance of the surroundings of the light probe. Should draw an image from the given camera's perspective with distance in the red channel onto the given render pass, with backface culling disabled.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ bakeLightProbeIrradianceMap()

void grem::graphics::LightBaker3D::bakeLightProbeIrradianceMap ( LightProbeVolumes3D & lightProbeVolumes,
uint32_t lightProbeVolumeIndex,
u32vec3 lightProbeGridIndices,
FunctionView< void(RenderPass &, const Camera3D &)> drawRadiance )

Render the irradiance map of a single light probe of a specific volume in a set of light probe volumes.

Parameters
lightProbeVolumesset of light probe volumes containing the light probe to bake.
lightProbeVolumeIndexindex of the light probe volume in the set of light probe volumes. Must be less than lightProbeVolumes.getVolumeOptions().size().
lightProbeGridIndiceslocal grid coordinates of the light probe in the specified light probe volume. Must be in range of the specified volume's LightProbeVolumeOptions3D::probeCounts.
drawRadiancefunction that records the draw commands for the radiance of the surroundings of the light probe. Should draw an image from the given camera's perspective in HDR color without tonemapping onto the given render pass. The alpha channel of the drawn image is ignored.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ bakeAllLightProbeIrradianceMaps()

void grem::graphics::LightBaker3D::bakeAllLightProbeIrradianceMaps ( LightProbeVolumes3D & lightProbeVolumes,
FunctionView< void(RenderPass &, const Camera3D &)> drawRadiance )

Render the irradiance maps of all light probes of all volumes in a set of light probe volumes.

Parameters
lightProbeVolumesset of light probe volumes to bake the irradiance maps for.
drawRadiancefunction that records the draw commands for the radiance of the surroundings of the light probes. Should draw an image from the given camera's perspective in HDR color without tonemapping onto the given render pass. The alpha channel of the drawn image is ignored.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ bakeLightProbeDistanceMap()

void grem::graphics::LightBaker3D::bakeLightProbeDistanceMap ( LightProbeVolumes3D & lightProbeVolumes,
uint32_t lightProbeVolumeIndex,
u32vec3 lightProbeGridIndices,
FunctionView< void(RenderPass &, const Camera3D &)> drawDistance )

Render the distance map of a single light probe of a specific volume in a set of light probe volumes.

Parameters
lightProbeVolumesset of light probe volumes containing the light probe to bake.
lightProbeVolumeIndexindex of the light probe volume in the set of light probe volumes. Must be less than lightProbeVolumes.getVolumeOptions().size().
lightProbeGridIndiceslocal grid coordinates of the light probe in the specified light probe volume. Must be in range of the specified volume's LightProbeVolumeOptions3D::probeCounts.
drawDistancefunction that records the draw commands for the distance of the surroundings of the light probe. Should draw an image from the given camera's perspective with distance in the red channel onto the given render pass, with backface culling disabled.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ bakeAllLightProbeDistanceMaps()

void grem::graphics::LightBaker3D::bakeAllLightProbeDistanceMaps ( LightProbeVolumes3D & lightProbeVolumes,
FunctionView< void(RenderPass &, const Camera3D &)> drawDistance )

Render the distance maps of all light probes of all volumes in a set of light probe volumes.

Parameters
lightProbeVolumesset of light probe volumes to bake the distance maps for.
drawDistancefunction that records the draw commands for the distance of the surroundings of the light probe. Should draw an image from the given camera's perspective with distance in the red channel onto the given render pass, with backface culling disabled.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ bakeSpecularReflections()

void grem::graphics::LightBaker3D::bakeSpecularReflections ( ReflectionProbes3D & reflectionProbes,
FunctionView< void(RenderPass &, const Camera3D &)> drawReflection )

Render the reflection maps of a set of reflection probes.

Parameters
reflectionProbesset of reflection probes to bake.
drawReflectionfunction that records the draw commands for the surroundings of the reflection probes. Should draw an image from the given camera's perspective in HDR color without tonemapping onto the given render pass. The depth buffer of the drawn image is used to determine which pixels are part of the reflection probe's purview by comparing them to the maximum depth value.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ bakeReflectionProbeReflectionMap()

void grem::graphics::LightBaker3D::bakeReflectionProbeReflectionMap ( ReflectionProbes3D & reflectionProbes,
uint32_t reflectionProbeIndex,
FunctionView< void(RenderPass &, const Camera3D &)> drawReflection )

Render the reflection map of a single reflection probe in a set of reflection probes.

Parameters
reflectionProbesset of reflection probes containing the reflection probe to bake.
reflectionProbeIndexindex of the reflection probe in the set of reflection probes. Must be less than reflectionProbes.getProbeOptions().size().
drawReflectionfunction that records the draw commands for the surroundings of the reflection probe. Should draw an image from the given camera's perspective in HDR color without tonemapping onto the given render pass. The depth buffer of the drawn image is used to determine which pixels are part of the reflection probe's purview by comparing them to the maximum depth value.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ bakeAllReflectionProbeReflectionMaps()

void grem::graphics::LightBaker3D::bakeAllReflectionProbeReflectionMaps ( ReflectionProbes3D & reflectionProbes,
FunctionView< void(RenderPass &, const Camera3D &)> drawReflection )

Render all reflection maps in a set of reflection probes.

Parameters
reflectionProbesset of reflection probes to bake the reflection probes of.
drawReflectionfunction that records the draw commands for the surroundings of the reflection probes. Should draw an image from the given camera's perspective in HDR color without tonemapping onto the given render pass. The depth buffer of the drawn image is used to determine which pixels are part of the reflection probe's purview by comparing them to the maximum depth value.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ generateCubemapFromEquirectangularMap()

Texture grem::graphics::LightBaker3D::generateCubemapFromEquirectangularMap ( TextureFormat internalFormat,
uint32_t resolution,
const Texture & equirectangularMap,
Optional< TextureSamplerOptions > samplerOptions = TextureSamplerOptions{ .minificationFilter=TextureFilter::LINEAR,.magnificationFilter=TextureFilter::LINEAR,.mipmapMode=TextureMipmapMode::NONE,.horizontalWrappingMode=TextureWrappingMode::CLAMP_TO_EDGE,.verticalWrappingMode=TextureWrappingMode::CLAMP_TO_EDGE,.maxAnisotropy=1.0f, } )
nodiscard

Generate a cubemap from a 2D equirectangular map texture.

Parameters
internalFormatinternal format of the generated cubemap texture. Must be a color format.
resolutionwidth of each side of the generated cubemap texture.
equirectangularMap2D equirectangular map to generate the cubemap from.
samplerOptionssampler options of the generated cubemap.
Returns
the generated cubemap.
Exceptions
graphics::Errorif resource creation failed, or on failure to render the cubemap.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

The documentation for this class was generated from the following file: