esp::metadata::attributes::PbrShaderAttributes class

attributes class describing essential and default quantities and settings for configuring PBR shader calculations.

Base classes

class AbstractAttributes
Base class for all implemented attributes. Inherits from esp::core::managedContainers::AbstractFileBasedManagedObject so the attributes can be managed by a esp::core::managedContainers::ManagedContainer.

Constructors, destructors, conversion operators

PbrShaderAttributes(const std::string& handle = "") explicit

Public functions

void setEnableDirectLighting(bool enableLights)
Set whether direct lighting should be used in PBR shader.
auto getEnableDirectLighting() const -> bool
Get whether direct lighting should be used in PBR shader.
void setDirectLightIntensity(double intensity)
Set the scene-wide direct lighting intensity for pbr shader. Applied to all direct lighting contributions equally.
auto getDirectLightIntensity() const -> float
Get the scene-wide lighting intensity for pbr shader. Applied to all direct lighting contributions equally.
void setSkipCalcMissingTBN(bool skipCalcMissingTBN)
Set if we should skip the calculation of a TBN frame in the fragment shader if no precalculated TBN is provided. Without this frame normal textures cannot be used, and anisotropy, if present, will not look appropriate.
auto getSkipCalcMissingTBN() const -> bool
Get if we should skip the calculation of a TBN frame in the fragment shader if no precalculated TBN is provided. Without this frame normal textures cannot be used, and anisotropy, if present, will not look appropriate.
void setUseMikkelsenTBN(bool useMikkelsenTBN)
Set if we should use the more expensive formulation for calculating the TBN frame in the fragment shader using partial derivatives given by Mikkelsen, as per https://jcgt.org/published/0009/03/04/paper.pdf . Otherwise a simplified version is used that seems to give equivalent results, based on https://github.com/KhronosGroup/Vulkan-Samples/blob/main/shaders/pbr.frag These calculations are only performed if a precalculated tangent is not provided and if normal textures or anisotropy are specified.
auto getUseMikkelsenTBN() const -> bool
Get if we should use the more expensive formulation for calculating the TBN frame in the fragment shader using partial derivatives given by Mikkelsen, as per https://jcgt.org/published/0009/03/04/paper.pdf . Otherwise a simplified version is used that seems to give equivalent results, based on https://github.com/KhronosGroup/Vulkan-Samples/blob/main/shaders/pbr.frag These calculations are only performed if a precalculated tangent is not provided and if normal textures or anisotropy are specified.
void setMapMatTxtrToLinear(bool mapMatTxtrToLinear)
Set if we should use shader-based srgb->linear approx remapping of applicable material color textures in PBR rendering for direct lighting and IBL. This field should be removed/ignored when Magnum fully supports sRGB texture conversion on load.
auto getMapMatTxtrToLinear() const -> bool
Get if we should use shader-based srgb->linear approx remapping of applicable material color textures in PBR rendering for direct lighting and IBL. This field should be removed/ignored when Magnum fully supports sRGB texture conversion on load.
void setMapIBLTxtrToLinear(bool mapIBLTxtrToLinear)
Set if we should use shader-based srgb->linear approx remapping of applicable IBL environment textures in PBR rendering for IBL calculations. This field should be removed/ignored when Magnum fully supports sRGB texture conversion on load.
auto getMapIBLTxtrToLinear() const -> bool
Get if we should use shader-based srgb->linear approx remapping of applicable IBL environment textures in PBR rendering for IBL calculations. This field should be removed/ignored when Magnum fully supports sRGB texture conversion on load.
void setMapOutputToSRGB(bool mapOutToSRGB)
Set if we should use shader-based linear->srgb approx remapping of color output in PBR rendering for direct lighting and IBL results. This field should be removed/ignored when an appropriate framebuffer is used for output to handle this conversion.
auto getMapOutputToSRGB() const -> bool
Get if we should use shader-based linear->srgb approx remapping of color output in PBR rendering for direct lighting and IBL results. This field should be removed/ignored when an appropriate framebuffer is used for output to handle this conversion.
void setUseDirectLightTonemap(bool useDirectTonemap)
Set if we should use tonemapping for direct lighting. TODO : specify multiple tonemappings? Each would be defined in the shader, and we could specify which to use by an enum.
auto getUseDirectLightTonemap() const -> bool
Get if we should use tonemapping for direct lighting. TODO : specify multiple tonemappings? Each would be defined in the shader, and we could specify which to use by an enum.
void setUseBurleyDiffuse(bool useBurleyDiffuse)
Set if we should use a diffuse calculation based on Burley, modified to be more energy conserving : https://media.disneyanimation.com/uploads/production/publication_asset/48/asset/s2012_pbs_disney_brdf_notes_v3.pdf instead of the default Lambertian calculation for direct lighting diffuse color under direct light. By default our PBR shader uses Lambertian, which is simpler and quicker to calculate but may not look as 'nice'.
auto getUseBurleyDiffuse() const -> bool
Get if we should use a diffuse calculation based on Burley, modified to be more energy conserving : https://media.disneyanimation.com/uploads/production/publication_asset/48/asset/s2012_pbs_disney_brdf_notes_v3.pdf instead of the default Lambertian calculation for direct lighting diffuse color under direct light. By default our PBR shader uses Lambertian, which is simpler and quicker to calculate but may not look as 'nice'.
void setSkipCalcClearcoatLayer(bool skipCalcClearCoat)
Set whether the clearcoat layer calculations should be skipped. If true, disable calcs regardless of material setting. Note this will not require a rebuild of the shader since only the calculations are disabled.
auto getSkipCalcClearcoatLayer() const -> bool
Set whether the clearcoat layer calculations should be skipped. If true, disable calcs regardless of material setting. Note this will not require a rebuild of the shader since only the calculations are disabled.
void setSkipCalcSpecularLayer(bool skipCalcSpecular)
Set whether the specular layer calculations should be skipped. If true, disable calcs regardless of material setting. Note this will not require a rebuild of the shader since only the calculations are disabled.
auto getSkipCalcSpecularLayer() const -> bool
Set whether the specular layer calculations should be skipped. If true, disable calcs regardless of material setting. Note this will not require a rebuild of the shader since only the calculations are disabled.
void setSkipCalcAnisotropyLayer(bool skipCalcAnisotropy)
Set whether the anisotropy layer calculations should be skipped. If true, disable calcs regardless of material setting. Note this will not require a rebuild of the shader since only the calculations are disabled.
auto getSkipCalcAnisotropyLayer() const -> bool
Set whether the anisotropy layer calculations should be skipped. If true, disable calcs regardless of material setting. Note this will not require a rebuild of the shader since only the calculations are disabled.
void setEnableIBL(bool enableIBL)
Set whether Image-based lighting should be used in PBR shader.
auto getEnableIBL() -> bool
Get whether Image-based lighting should be used in PBR shader.
void setIBLBrdfLUTAssetHandle(const std::string& brdfLUTAsset)
Set the filename for the brdf lookup table used by the IBL calculations.Also builds the PbrIBLHelper key to check/retrive helpers in map in ResourceManager.
auto getIBLBrdfLUTAssetHandle() const -> std::string
Get the filename for the brdf lookup table used by the IBL calculations.
void setIBLEnvMapAssetHandle(const std::string& envMapAsset)
Set the filename for the equirectangular environment map used by the IBL calculations. Also builds the PbrIBLHelper key to check/retrive helpers in map in ResourceManager.
auto getIBLEnvMapAssetHandle() const -> std::string
Get the filename for the equirectangular environment map used by the calculations.
auto getPbrShaderHelperKey() const -> std::string
Retrieve the handle for the PbrIBLHelper to be used for objects using this attributes. This value is set internally when either bLUT or EnvMap asset names are set. Format is '<bLUT asset handle>_<envMap asset handle>'.
void setUseIBLTonemap(bool useIBLTonemap)
set if we should use tonemapping for IBL lighting. TODO : Eventually provide mechanism for specifying multiple tonemappings? Each would be defined in the shader, and we could specify which to use by an enum.
auto getUseIBLTonemap() const -> bool
Get if we should use tonemapping for IBL lighting. TODO : Eventually provide mechanism for specifying multiple tonemappings? Each would be defined in the shader, and we could specify which to use by an enum.
void setTonemapExposure(double exposure)
Set the exposure value for tonemapping in the pbr shader. This value scales the color before the tonemapping is applied.
auto getTonemapExposure() const -> float
Get the exposure value for tonemapping in the pbr shader. This value scales the color before the tonemapping is applied.
void setGamma(double gamma)
Set the gamma value for the pbr shader. This value is used for the approximation mapping from sRGB to linear and back. Cannot be <= 0.
auto getGamma() const -> float
Get the gamma value for the pbr shader. This value is used for the approximation mapping from sRGB to linear and back.
void setIBLToDirectDiffuseBalance(double balance)
Convenience accessor to address balance between direct diffuse and indirect diffuse. Setting this to 0 or less will have full direct lighting result and no indirect/IBL, setting to 1 or more will have full IBL lighting result and no direct lighting contributions. Only used if both direct and image-based lighting is enabled.
void setIBLToDirectSpecularBalance(double balance)
Convenience accessor to address balance between direct specular and indirect specular. Setting this to 0 or less will have full direct lighting result and no indirect/IBL, setting to 1 or more will have full IBL lighting result and no direct lighting contributions. Only used if both direct and image-based lighting is enabled.
auto getIBLToDirectDiffuseBalance() const -> double
Convenience accessor to balance between direct diffuse and indirect diffuse. Retrieves a value from [0.1], with 0 meaning only direct lighting diffuse results, and 1 meaning only image-based lighting diffuse results. Only used if both direct and image-based lighting is enabled.
auto getIBLToDirectSpecularBalance() const -> double
Convenience accessor to balance between direct specular and indirect specular. Retrieves a value from [0.1], with 0 meaning only direct lighting specular results, and 1 meaning only image-based lighting specular results. Only used if both direct and image-based lighting is enabled.
void setDirectDiffuseScale(double scale)
Set value to scale the direct lighting diffuse contribution if both Direct lighting and IBL are specified, Ignored otherwise. Value is not checked, so can create energy if direct + indirect contributions scaled by more than 1.0.
auto getDirectDiffuseScale() const -> float
Get value to scale the direct lighting diffuse contribution if both Direct lighting and IBL are specified, Ignored otherwise. Value is not checked, so can create energy if direct + indirect contributions scaled by more than 1.0.
void setDirectSpecularScale(double scale)
Set value to scale the direct lighting specular contribution if both Direct lighting and IBL are specified, Ignored otherwise. Value is not checked, so can create energy if direct + indirect contributions scaled by more than 1.0.
auto getDirectSpecularScale() const -> float
Get value to scale the direct lighting specular contribution if both Direct lighting and IBL are specified, Ignored otherwise. Value is not checked, so can create energy if direct + indirect contributions scaled by more than 1.0.
void setIBLDiffuseScale(double scale)
Set value to scale the IBL lighting diffuse contribution if both Direct lighting and IBL are specified, Ignored otherwise. Value is not checked, so can create energy if direct + indirect contributions scaled by more than 1.0.
auto getIBLDiffuseScale() const -> float
Get value to scale the IBL lighting diffuse contribution if both Direct lighting and IBL are specified, Ignored otherwise. Value is not checked, so can create energy if direct + indirect contributions scaled by more than 1.0.
void setIBLSpecularScale(double scale)
Set value to scale the IBL lighting specular contribution if both Direct lighting and IBL are specified, Ignored otherwise. Value is not checked, so can create energy if direct + indirect contributions scaled by more than 1.0.
auto getIBLSpecularScale() const -> float
Get value to scale the IBL lighting specular contribution if both Direct lighting and IBL are specified, Ignored otherwise. Value is not checked, so can create energy if direct + indirect contributions scaled by more than 1.0.
void writeValuesToJson(io::JsonGenericValue& jsonObj, io::JsonAllocator& allocator) const override
Populate a json object with all the first-level values held in this configuration. Default is overridden to handle special cases for PbrShaderAttributes.

Protected functions

void buildPbrShaderHelperKey(const std::string& brdfLUTAsset, const std::string& envMapAsset)
Used internally. Build the PbrShaderHelper Key from the ibl blut filename and the ibl envmap filename used to check/retrive helpers in map in ResourceManager.
auto getObjectInfoHeaderInternal() const -> std::string override
Retrieve a comma-separated string holding the header values for the info returned for this managed object, type-specific.
auto getObjectInfoInternal() const -> std::string override
Retrieve a comma-separated informational string about the contents of this managed object.