Visual Computing Library  devel
Loading...
Searching...
No Matches
vcl::DrawableEnvironment Class Reference

A class representing an environment for PBR rendering. More...

#include <vclib/bgfx/drawable/drawable_environment.h>

Public Types

enum class  TextureType { RAW_CUBE , IRRADIANCE , SPECULAR , BRDF_LUT }
 Types of environment textures managed by the DrawableEnvironment class.
 

Public Member Functions

void bindTexture (TextureType type, uint stage, uint samplerFlags=BGFX_SAMPLER_UVW_CLAMP) const
 Binds the specified environment texture to the given texture stage.
 
bool canDraw () const
 Checks if the environment is ready to be drawn.
 
 DrawableEnvironment (const DrawableEnvironment &other)=delete
 
 DrawableEnvironment (const std::string &imagePath, uint viewId=UINT_NULL)
 
 DrawableEnvironment (DrawableEnvironment &&other)
 
void drawBackground (uint viewId, const PBRViewerSettings &settings) const
 Draws the environment in the background.
 
std::string imageFileName () const
 
const std::string & imagePath () const
 
DrawableEnvironmentoperator= (const DrawableEnvironment &other)=delete
 
DrawableEnvironmentoperator= (DrawableEnvironment &&other)
 
uint8_t specularMipLevels () const
 
void swap (DrawableEnvironment &other)
 

Private Types

enum class  FileFormat {
  UNKNOWN , HDR , EXR , KTX ,
  DDS
}
 

Private Member Functions

void generateTextures (const bimg::ImageContainer &image, uint cubeSide, uint8_t cubeMips, uint viewId)
 Generates the necessary environment textures (cubemap, irradiance map, specular map, BRDF LUT).
 
FileFormat getFileFormat (const std::string &imagePath)
 Determines the file format of the given image based on its extension.
 
bimg::ImageContainer * loadImage (std::string imagePath)
 Loads the image from the specified file path.
 
void setAndGenerateTextures (const bimg::ImageContainer &image, uint viewId)
 Sets up the environment textures based on the given image.
 

Static Private Member Functions

static vcl::VertexBuffer fullScreenTriangle ()
 Sets and returns the buffer for the full-screen triangle for background drawing.
 

Private Attributes

Texture mBrdfLuTexture
 
const Uniform mBrdfLutSamplerUniform
 
Texture mCubeMapTexture
 
const Uniform mEnvCubeSamplerUniform
 
const Uniform mHdrSamplerUniform
 
Texture mHdrTexture
 
std::string mImagePath
 
const Uniform mIrradianceCubeSamplerUniform
 
Texture mIrradianceTexture
 
const Uniform mSpecularCubeSamplerUniform
 
uint8_t mSpecularMipLevels = 0
 
Texture mSpecularTexture
 
const vcl::VertexBuffer mVertexBuffer = fullScreenTriangle()
 

Static Private Attributes

static const uint BRDF_LU_TEXTURE_SIZE = 1024
 

Friends

void swap (DrawableEnvironment &first, DrawableEnvironment &second)
 

Detailed Description

A class representing an environment for PBR rendering.

It manages the loading and setup of environment maps, including HDR images, cubemaps, irradiance maps, specular maps, and BRDF LUTs.

Member Function Documentation

◆ bindTexture()

void vcl::DrawableEnvironment::bindTexture ( TextureType  type,
uint  stage,
uint  samplerFlags = BGFX_SAMPLER_UVW_CLAMP 
) const

Binds the specified environment texture to the given texture stage.

Parameters
[in]typeThe type of texture to bind (RAW_CUBE, IRRADIANCE, SPECULAR, BRDF_LUT).
[in]stageThe texture stage to bind the texture to.
[in]samplerFlagsThe sampler flags to use when binding the texture.

◆ canDraw()

bool vcl::DrawableEnvironment::canDraw ( ) const
inline

Checks if the environment is ready to be drawn.

Returns
true if the environment can be drawn, false otherwise.

◆ drawBackground()

void vcl::DrawableEnvironment::drawBackground ( uint  viewId,
const PBRViewerSettings settings 
) const

Draws the environment in the background.

Parameters
[in]viewIdThe view ID to draw the background in.
[in]settingsThe tone mapping operator to use.

◆ generateTextures()

void vcl::DrawableEnvironment::generateTextures ( const bimg::ImageContainer &  image,
uint  cubeSide,
uint8_t  cubeMips,
uint  viewId 
)
private

Generates the necessary environment textures (cubemap, irradiance map, specular map, BRDF LUT).

This function is called by setAndGenerateTextures after setting up the initial textures.

◆ getFileFormat()

DrawableEnvironment::FileFormat vcl::DrawableEnvironment::getFileFormat ( const std::string &  imagePath)
private

Determines the file format of the given image based on its extension.

Recognized formats are HDR, EXR, KTX, DDS otherwise the format is marked as UNKNOWN.

Parameters
[in]imagePathThe path to the image file.
Returns
The determined file format.

◆ loadImage()

bimg::ImageContainer * vcl::DrawableEnvironment::loadImage ( std::string  imagePath)
private

Loads the image from the specified file path.

Parameters
[in]imagePathThe path to the image file.
Returns
A pointer to the loaded ImageContainer, can be nullptr.

◆ setAndGenerateTextures()

void vcl::DrawableEnvironment::setAndGenerateTextures ( const bimg::ImageContainer &  image,
uint  viewId 
)
private

Sets up the environment textures based on the given image.

This function is called in the constructor after loading the image.

Parameters
[in]imageThe image container holding the environment map data.

Member Data Documentation

◆ mBrdfLutSamplerUniform

const Uniform vcl::DrawableEnvironment::mBrdfLutSamplerUniform
private
Initial value:
=
Uniform("s_brdf_lut", bgfx::UniformType::Sampler)

◆ mEnvCubeSamplerUniform

const Uniform vcl::DrawableEnvironment::mEnvCubeSamplerUniform
private
Initial value:
=
Uniform("s_env0", bgfx::UniformType::Sampler)

◆ mHdrSamplerUniform

const Uniform vcl::DrawableEnvironment::mHdrSamplerUniform
private
Initial value:
=
Uniform("s_hdr", bgfx::UniformType::Sampler)

◆ mIrradianceCubeSamplerUniform

const Uniform vcl::DrawableEnvironment::mIrradianceCubeSamplerUniform
private
Initial value:
=
Uniform("s_irradiance", bgfx::UniformType::Sampler)

◆ mSpecularCubeSamplerUniform

const Uniform vcl::DrawableEnvironment::mSpecularCubeSamplerUniform
private
Initial value:
=
Uniform("s_specular", bgfx::UniformType::Sampler)

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