OGRE-Next  4.0.0unstable
Object-Oriented Graphics Rendering Engine
Ogre::HlmsPbs Class Reference

Physically based shading implementation specfically designed for OpenGL 3+, D3D11 and other RenderSystems which support uniform buffers. More...

#include <OgreHlmsPbs.h>

+ Inheritance diagram for Ogre::HlmsPbs:

Public Types

enum  AmbientLightMode {
  AmbientAutoNormal , AmbientAutoInverted , AmbientFixed , AmbientHemisphereNormal ,
  AmbientHemisphereInverted , AmbientSh , AmbientShMonochrome , AmbientNone
}
 
enum  ShadowFilter {
  PCF_2x2 , PCF_3x3 , PCF_4x4 , PCF_5x5 ,
  PCF_6x6 , ExponentialShadowMaps , NumShadowFilter
}
 
- Public Types inherited from Ogre::Hlms
enum  CachedCustomPieceFileStatus { CCPFS_Success , CCPFS_OutOfDate , CCPFS_CriticalError }
 
typedef std::map< int32, DatablockCustomPieceFileDatablockCustomPieceFileMap
 
typedef std::map< IdString, DatablockEntryHlmsDatablockMap
 
typedef vector< Library >::type LibraryVec
 
enum  LightGatheringMode { LightGatherForward , LightGatherForwardPlus , LightGatherDeferred , LightGatherNone }
 
enum  PrecisionMode { PrecisionFull32 , PrecisionMidf16 , PrecisionRelaxed }
 
- Public Types inherited from Ogre::ConstBufferPool
enum  DirtyFlags { DirtyNone = 0u , DirtyConstBuffer = 1u << 0u , DirtyTextures = 1u << 1u , DirtySamplers = 1u << 2u }
 
enum  OptimizationStrategy { LowerCpuOverhead , LowerGpuOverhead }
 

Public Member Functions

 HlmsPbs (Archive *dataFolder, ArchiveVec *libraryFolders)
 
 ~HlmsPbs () override
 
void _changeRenderSystem (RenderSystem *newRs) override
 
void _collectSamplerblocks (set< const HlmsSamplerblock * >::type &outSamplerblocks, const HlmsDatablock *datablock) const override
 
void _loadJson (const rapidjson::Value &jsonValue, const HlmsJson::NamedBlocks &blocks, HlmsDatablock *datablock, const String &resourceGroup, HlmsJsonListener *listener, const String &additionalTextureExtension) const override
 Loads datablock values from a JSON value. More...
 
void _notifyIblSpecMipmap (uint8 numMipmaps)
 
void _saveJson (const HlmsDatablock *datablock, String &outString, HlmsJsonListener *listener, const String &additionalTextureExtension) const override
 
void analyzeBarriers (BarrierSolver &barrierSolver, ResourceTransitionArray &resourceTransitions, Camera *renderingCamera, const bool bCasterPass) override
 
uint32 fillBuffersFor (const HlmsCache *cache, const QueuedRenderable &queuedRenderable, bool casterPass, uint32 lastCacheHash, uint32 lastTextureHash) override
 Fills the constant buffers. More...
 
uint32 fillBuffersForV1 (const HlmsCache *cache, const QueuedRenderable &queuedRenderable, bool casterPass, uint32 lastCacheHash, CommandBuffer *commandBuffer) override
 
uint32 fillBuffersForV2 (const HlmsCache *cache, const QueuedRenderable &queuedRenderable, bool casterPass, uint32 lastCacheHash, CommandBuffer *commandBuffer) override
 
void frameEnded () override
 Called when the frame has fully ended (ALL passes have been executed to all RTTs) More...
 
AmbientLightMode getAmbientLightMode () const
 
TextureGpugetAreaLightMasks () const
 
bool getDebugPssmSplits () const
 
bool getDefaultBrdfWithDiffuseFresnel () const
 
uint16 getEsmK () const
 
bool getFineLightMaskGranularity () const
 
bool getIndustryCompatible () const
 
IrradianceFieldgetIrradianceField ()
 
IrradianceVolumegetIrradianceVolume () const
 
TextureGpugetLightProfilesTexture () const
 
ParallaxCorrectedCubemapBasegetParallaxCorrectedCubemap () const
 
bool getPerceptualRoughness () const
 
ShadowFilter getShadowFilter () const
 
bool getShadowReceiversInPixelShader () const
 
bool getUseLightBuffers ()
 
bool getVctFullConeCount () const
 
VctLightinggetVctLighting ()
 
void loadLtcMatrix ()
 
 OGRE_DEPRECATED_VER (3) void setPerceptualRoughness(bool bPerceptualRoughness)
 Toggle whether the roughness value (set via material parameters and via roughness textures) is perceptual or raw. More...
 
void postCommandBufferExecution (CommandBuffer *commandBuffer) override
 This gets called after executing the command buffer. More...
 
HlmsCache preparePassHash (const Ogre::CompositorShadowNode *shadowNode, bool casterPass, bool dualParaboloid, SceneManager *sceneManager) override
 Called every frame by the Render Queue to cache the properties needed by this pass. More...
 
void resetIblSpecMipmap (uint8 numMipmaps)
 By default we see the reflection textures' mipmaps and store the largest one we found. More...
 
void setAmbientLightMode (AmbientLightMode mode)
 
void setAreaLightMasks (TextureGpu *areaLightMask)
 
void setDebugPssmSplits (bool bDebug)
 
void setDefaultBrdfWithDiffuseFresnel (bool bDefaultToDiffuseFresnel)
 OgreNext 3.0 changed Default BRDF to not include diffuse fresnel in order to match what most DCC tools (e.g. More...
 
void setEsmK (uint16 K)
 Sets the 'K' parameter of ESM filter. More...
 
void setFineLightMaskGranularity (bool useFineGranularity)
 Toggles whether light masks will be obeyed per object by doing: if( movableObject->getLightMask() & light->getLightMask() ) doLighting( movableObject light ); Note this toggle only affects forward lights (i.e. More...
 
void setIndustryCompatible (bool bIndustryCompatible)
 There are slight variations between how PBR formulas are handled in OgreNext and other game engines or DCC (Digital Content Creator) tools. More...
 
void setIrradianceField (IrradianceField *irradianceField)
 
void setIrradianceVolume (IrradianceVolume *irradianceVolume)
 
void setLightProfilesTexture (TextureGpu *lightProfilesTex)
 
void setParallaxCorrectedCubemap (ParallaxCorrectedCubemapBase *pcc, float pccVctMinDistance=1.0f, float pccVctMaxDistance=2.0f)
 Sets PCC. More...
 
void setShadowReceiversInPixelShader (bool bInPixelShader)
 Toggles whether light-space position is calculated in vertex or pixel shader. More...
 
void setShadowSettings (ShadowFilter filter)
 
void setStaticBranchingLights (bool staticBranchingLights) override
 By default shadow-caster spot and point lights are hardcoded into shaders. More...
 
void setUseLightBuffers (bool b)
 
void setVctFullConeCount (bool vctFullConeCount)
 When false, we will use 4 cones for diffuse VCT. More...
 
void setVctLighting (VctLighting *vctLighting)
 
- Public Member Functions inherited from Ogre::HlmsBufferManager
 HlmsBufferManager (HlmsTypes type, const String &typeName, Archive *dataFolder, ArchiveVec *libraryFolders)
 
 ~HlmsBufferManager () override
 
void preCommandBufferExecution (CommandBuffer *commandBuffer) override
 This gets called right before executing the command buffer. More...
 
void setTextureBufferDefaultSize (size_t defaultSize)
 Changes the default suggested size for the texture buffer. More...
 
- Public Member Functions inherited from Ogre::Hlms
 Hlms (HlmsTypes type, const String &typeName, Archive *dataFolder, ArchiveVec *libraryFolders)
 
virtual ~Hlms ()
 
void _addDatablockCustomPieceFile (const String &filename, const String &resourceGroup)
 See HlmsDatablock::setCustomPieceCodeFromMemory & HlmsDatablock::setCustomPieceFile. More...
 
CachedCustomPieceFileStatus _addDatablockCustomPieceFile (const String &filename, const String &resourceGroup, const uint64 sourceCodeHash[2])
 
void _addDatablockCustomPieceFileFromMemory (const String &filename, const String &sourceCode)
 
void _clearShaderCache ()
 
void _compileShaderFromPreprocessedSource (const RenderableCache &mergedCache, const String source[NumShaderTypes], const uint32 shaderCounter, size_t tid)
 
int32 _getProperty (size_t tid, IdString key, int32 defaultVal=0) const
 
void _notifyManager (HlmsManager *manager)
 
void _setNumThreads (size_t numThreads)
 
void _setProperty (size_t tid, IdString key, int32 value)
 For debugging stuff. I.e. the Command line uses it for testing manually set properties. More...
 
void _setShadersGenerated (uint32 shadersGenerated)
 
void _setTextureReg (size_t tid, ShaderType shaderType, const char *texName, int32 texUnit)
 
void _tagShaderCodeCacheUpToDate ()
 
void compileShaderCode (ShaderCodeCache &codeCache, uint32 shaderCounter, size_t tid)
 Compiles input properties and adds it to the shader code cache. More...
 
void compileStubEntry (const HlmsCache &passCache, HlmsCache *reservedStubEntry, QueuedRenderable queuedRenderable, uint32 renderableHash, uint32 finalHash, size_t tid)
 Called by ParallelHlmsCompileQueue to finish the job started in getMaterial() More...
 
HlmsDatablockcreateDatablock (IdString name, const String &refName, const HlmsMacroblock &macroblockRef, const HlmsBlendblock &blendblockRef, const HlmsParamVec &paramVec, bool visibleToManager=true, const String &filename=BLANKSTRING, const String &resourceGroup=BLANKSTRING)
 Creates a unique datablock that can be shared by multiple renderables. More...
 
void destroyAllDatablocks ()
 Destroys all datablocks created with createDatablock(). More...
 
void destroyDatablock (IdString name)
 Destroys a datablocks given its name. More...
 
uint16 getAreaLightsApproxLimit () const
 
uint16 getAreaLightsLtcLimit () const
 
HlmsDatablockgetDatablock (IdString name) const
 Finds an existing datablock based on its name (. More...
 
const DatablockCustomPieceFilegetDatablockCustomPieceData (int32 filenameHashId) const
 Returns all the data we know about filenameHashId. Can be nullptr if not found. More...
 
const StringgetDatablockCustomPieceFileNameStr (int32 filenameHashId) const
 
const HlmsDatablockMapgetDatablockMap () const
 Returns all datablocks owned by this Hlms, including the default one. More...
 
ArchivegetDataFolder ()
 
HlmsDatablockgetDefaultDatablock () const
 Datablock to use when another datablock failed or none was specified. More...
 
bool getFastShaderBuildHack () const
 Returns true if shaders are being compiled with Fast Shader Build Hack (D3D11 only) More...
 
void getFilenameAndResourceGroup (IdString name, String const **outFilename, String const **outResourceGroup) const
 Returns the filaname & resource group a datablock was created from, and is associated with its hashed name (this was passed as in createDatablock()). More...
 
HlmsManagergetHlmsManager () const
 
HlmsListenergetListener () const
 Returns the current listener. More...
 
const HlmsCachegetMaterial (HlmsCache const *lastReturnedValue, const HlmsCache &passCache, const QueuedRenderable &queuedRenderable, bool casterPass, ParallelHlmsCompileQueue *parallelQueue)
 Retrieves an HlmsCache filled with the GPU programs to be used by the given renderable. More...
 
uint32 getMaterialSerial01 (uint32 lastReturnedValue, const HlmsCache &passCache, const size_t passCacheIdx, const QueuedRenderable &queuedRenderable, bool casterPass, ParallelHlmsCompileQueue &parallelQueue)
 This is extremely similar to getMaterial() except it's been designed to be always in parallel and to be used by warm_up passes. More...
 
uint16 getMaxNonCasterDirectionalLights () const
 
const StringgetNameStr (IdString name) const
 Returns the string name associated with its hashed name (this was passed as refName in createDatablock()). More...
 
uint8 getParticleSystemConstSlot () const
 
uint8 getParticleSystemSlot () const
 
const LibraryVecgetPiecesLibrary () const
 
ArchiveVec getPiecesLibraryAsArchiveVec () const
 
PrecisionMode getPrecisionMode () const
 Returns requested precision mode (i.e., value passed to setPrecisionMode) See getSupportedPrecisionMode. More...
 
RenderSystemgetRenderSystem () const
 
const ShaderCodeCacheVec & getShaderCodeCache () const
 
const StringgetShaderProfile () const
 
IdString getShaderSyntax () const
 
bool getStaticBranchingLights () const
 
PrecisionMode getSupportedPrecisionMode () const
 Some GPUs don't support all precision modes. More...
 
void getTemplateChecksum (uint64 outHash[2]) const
 
HlmsTypes getType () const
 
IdString getTypeName () const
 
const StringgetTypeNameStr () const
 
bool isDatablockCustomPieceFileCacheable (int32 filenameHashId) const
 
bool isShaderCodeCacheDirty () const
 Users can check this function to tell if HlmsDiskCache needs saving. More...
 
bool parseOffline (const String &filename, String &inBuffer, String &outBuffer, size_t tid)
 For standalone parsing. More...
 
virtual void reloadFrom (Archive *newDataFolder, ArchiveVec *libraryFolders=0)
 Destroys all the cached shaders and in the next opportunity will recreate them from the new location. More...
 
void saveAllTexturesFromDatablocks (const String &folderPath, set< String >::type &savedTextures, bool saveOitd, bool saveOriginal, HlmsTextureExportListener *listener)
 
void setAreaLightForwardSettings (uint16 areaLightsApproxLimit, uint16 areaLightsLtcLimit)
 Area lights use regular Forward. More...
 
void setDebugOutputPath (bool enableDebugOutput, bool outputProperties, const String &path=BLANKSTRING)
 Call to output the automatically generated shaders (which are usually made from templates) on the given folder for inspection, analyzing, debugging, etc. More...
 
void setListener (HlmsListener *listener)
 Sets a listener to extend an existing Hlms implementation's with custom code, without having to rewrite it or modify the source code directly. More...
 
void setMaxNonCasterDirectionalLights (uint16 maxLights)
 Non-caster directional lights are hardcoded into shaders. More...
 
void setPrecisionMode (PrecisionMode precisionMode)
 Sets the precision mode of Hlms. More...
 
- Public Member Functions inherited from Ogre::ConstBufferPool
 ConstBufferPool (uint32 bytesPerSlot, const ExtraBufferParams &extraBufferParams)
 
virtual ~ConstBufferPool ()
 
OptimizationStrategy getOptimizationStrategy () const
 
size_t getPoolIndex (ConstBufferPoolUser *user) const
 Gets an ID corresponding to the pool this user was assigned to, unique per hash. More...
 
void releaseSlot (ConstBufferPoolUser *user)
 Releases a slot requested with requestSlot. More...
 
void requestSlot (uint32 hash, ConstBufferPoolUser *user, bool wantsExtraBuffer)
 Requests a slot and fills 'user'. Automatically schedules for update. More...
 
void scheduleForUpdate (ConstBufferPoolUser *dirtyUser, uint8 dirtyFlags=DirtyConstBuffer)
 
virtual void setOptimizationStrategy (OptimizationStrategy optimizationStrategy)
 Sets the optimization strategy. More...
 

Static Public Member Functions

static void getDefaultPaths (String &outDataFolderPath, StringVector &outLibraryFoldersPaths)
 Fill the provided string and string vector with all the sub-folder needed to instantiate an HlmsPbs object with the default distribution of the HlmsResources. More...
 
- Static Public Member Functions inherited from Ogre::Hlms
static void _setHasParticleFX2Plugin (bool bHasPfx2Plugin)
 
static bool findParamInVec (const HlmsParamVec &paramVec, IdString key, String &inOut)
 Finds the parameter with key 'key' in the given 'paramVec'. More...
 
static int32 getProperty (const HlmsPropertyVec &properties, IdString key, int32 defaultVal=0)
 Utility helper, mostly useful to HlmsListener implementations. More...
 
static bool hasParticleFX2Plugin ()
 
static void setProperty (HlmsPropertyVec &properties, IdString key, int32 value)
 Utility helper, mostly useful to HlmsListener implementations. More...
 

Additional Inherited Members

- Static Public Attributes inherited from Ogre::Hlms
static constexpr size_t kNoTid = 0u
 For single-threaded operations. More...
 

Detailed Description

Physically based shading implementation specfically designed for OpenGL 3+, D3D11 and other RenderSystems which support uniform buffers.

Member Enumeration Documentation

◆ AmbientLightMode

Enumerator
AmbientAutoNormal 

Use fixed-colour ambient lighting when upper hemisphere = lower hemisphere, use hemisphere lighting when they don't match.

Disables ambient lighting if the colours are black.

AmbientAutoInverted 

Same as AmbientAutoNormal but inverts specular & diffuse calculations.

See AmbientHemisphereInverted.

This version was called "AmbientAuto" in OgreNext <= 2.3

AmbientFixed 

Force fixed-colour ambient light. Only uses the upper hemisphere paramter.

AmbientHemisphereNormal 

Force hemisphere ambient light.

Useful if you plan on adjusting the colours dynamically very often and this might cause swapping shaders.

AmbientHemisphereInverted 

Same as AmbientHemisphereNormal, but inverts the specular & diffuse calculations which can be visually more pleasant, or you just need it to look how it was in 2.3.

This version was called "AmbientHemisphere" in OgreNext <= 2.3

AmbientSh 

Uses spherical harmonics.

AmbientShMonochrome 

Uses spherical harmonics (monochrome / single channel)

AmbientNone 

Disable ambient lighting.

◆ ShadowFilter

Enumerator
PCF_2x2 

Standard quality. Very fast.

PCF_3x3 

Good quality. Still quite fast on most modern hardware.

PCF_4x4 

High quality.

Very slow in old hardware (i.e. DX10 level hw and below) Use RSC_TEXTURE_GATHER to check whether it will be slow or not.

PCF_5x5 

Better and slower than 4x4, same considerations.

PCF_6x6 

Better and slower than 5x5, same considerations.

ExponentialShadowMaps 

High quality.

Produces soft shadows. It's much more expensive but given its blurry results, you can reduce resolution and/or use less PSSM splits which gives you very competing performance with great results. ESM stands for Exponential Shadow Maps.

NumShadowFilter 

Constructor & Destructor Documentation

◆ HlmsPbs()

Ogre::HlmsPbs::HlmsPbs ( Archive dataFolder,
ArchiveVec libraryFolders 
)

◆ ~HlmsPbs()

Ogre::HlmsPbs::~HlmsPbs ( )
override

Member Function Documentation

◆ _changeRenderSystem()

void Ogre::HlmsPbs::_changeRenderSystem ( RenderSystem newRs)
overridevirtual

Reimplemented from Ogre::ConstBufferPool.

◆ _collectSamplerblocks()

void Ogre::HlmsPbs::_collectSamplerblocks ( set< const HlmsSamplerblock * >::type &  outSamplerblocks,
const HlmsDatablock datablock 
) const
overridevirtual

Reimplemented from Ogre::Hlms.

◆ _loadJson()

void Ogre::HlmsPbs::_loadJson ( const rapidjson::Value jsonValue,
const HlmsJson::NamedBlocks blocks,
HlmsDatablock datablock,
const String resourceGroup,
HlmsJsonListener listener,
const String additionalTextureExtension 
) const
overridevirtual

Loads datablock values from a JSON value.

See also
HlmsJson.
Parameters
jsonValueJSON Object containing the definition of this datablock.
blocksAll the loaded Macro-, Blend- & Samplerblocks the JSON has defined and may be referenced by the datablock declaration.
datablockDatablock to fill the values.

Reimplemented from Ogre::Hlms.

◆ _notifyIblSpecMipmap()

void Ogre::HlmsPbs::_notifyIblSpecMipmap ( uint8  numMipmaps)

◆ _saveJson()

void Ogre::HlmsPbs::_saveJson ( const HlmsDatablock datablock,
String outString,
HlmsJsonListener listener,
const String additionalTextureExtension 
) const
overridevirtual

Reimplemented from Ogre::Hlms.

◆ analyzeBarriers()

void Ogre::HlmsPbs::analyzeBarriers ( BarrierSolver barrierSolver,
ResourceTransitionArray resourceTransitions,
Camera renderingCamera,
const bool  bCasterPass 
)
overridevirtual

Reimplemented from Ogre::Hlms.

◆ fillBuffersFor()

uint32 Ogre::HlmsPbs::fillBuffersFor ( const HlmsCache cache,
const QueuedRenderable queuedRenderable,
bool  casterPass,
uint32  lastCacheHash,
uint32  lastTextureHash 
)
overridevirtual

Fills the constant buffers.

Gets executed right before drawing the mesh.

Parameters
cacheCurrent cache of Shaders to be used.
queuedRenderableThe Renderable-MovableObject pair about to be rendered.
casterPassWhether this is a shadow mapping caster pass.
lastCacheHashThe hash of the cache of shaders that was the used by the previous renderable.
lastTextureHashLast Texture Hash, used to let the Hlms know whether the textures should be changed again
Returns
New Texture hash (may be equal or different to lastTextureHash).

Implements Ogre::Hlms.

◆ fillBuffersForV1()

uint32 Ogre::HlmsPbs::fillBuffersForV1 ( const HlmsCache cache,
const QueuedRenderable queuedRenderable,
bool  casterPass,
uint32  lastCacheHash,
CommandBuffer commandBuffer 
)
overridevirtual

Implements Ogre::Hlms.

◆ fillBuffersForV2()

uint32 Ogre::HlmsPbs::fillBuffersForV2 ( const HlmsCache cache,
const QueuedRenderable queuedRenderable,
bool  casterPass,
uint32  lastCacheHash,
CommandBuffer commandBuffer 
)
overridevirtual

Implements Ogre::Hlms.

◆ frameEnded()

void Ogre::HlmsPbs::frameEnded ( )
overridevirtual

Called when the frame has fully ended (ALL passes have been executed to all RTTs)

Reimplemented from Ogre::HlmsBufferManager.

◆ getAmbientLightMode()

AmbientLightMode Ogre::HlmsPbs::getAmbientLightMode ( ) const
inline

◆ getAreaLightMasks()

TextureGpu* Ogre::HlmsPbs::getAreaLightMasks ( ) const
inline

◆ getDebugPssmSplits()

bool Ogre::HlmsPbs::getDebugPssmSplits ( ) const
inline

◆ getDefaultBrdfWithDiffuseFresnel()

bool Ogre::HlmsPbs::getDefaultBrdfWithDiffuseFresnel ( ) const
inline

◆ getDefaultPaths()

static void Ogre::HlmsPbs::getDefaultPaths ( String outDataFolderPath,
StringVector outLibraryFoldersPaths 
)
static

Fill the provided string and string vector with all the sub-folder needed to instantiate an HlmsPbs object with the default distribution of the HlmsResources.

These paths are dependent of the current RenderSystem.

This method can only be called after a valid RenderSysttem has been chosen.

All output parameter's content will be replaced with the new set of paths.

Parameters
outDataFolderPathPath (as a String) used for creating the "dataFolder" Archive the constructor will need
outLibraryFoldersPathsVector of String used for creating the ArchiveVector "libraryFolders" the constructor will need

◆ getEsmK()

uint16 Ogre::HlmsPbs::getEsmK ( ) const
inline

◆ getFineLightMaskGranularity()

bool Ogre::HlmsPbs::getFineLightMaskGranularity ( ) const
inline

◆ getIndustryCompatible()

bool Ogre::HlmsPbs::getIndustryCompatible ( ) const
inline

◆ getIrradianceField()

IrradianceField* Ogre::HlmsPbs::getIrradianceField ( )
inline

◆ getIrradianceVolume()

IrradianceVolume* Ogre::HlmsPbs::getIrradianceVolume ( ) const
inline

◆ getLightProfilesTexture()

TextureGpu* Ogre::HlmsPbs::getLightProfilesTexture ( ) const
inline

◆ getParallaxCorrectedCubemap()

ParallaxCorrectedCubemapBase* Ogre::HlmsPbs::getParallaxCorrectedCubemap ( ) const
inline

◆ getPerceptualRoughness()

bool Ogre::HlmsPbs::getPerceptualRoughness ( ) const

◆ getShadowFilter()

ShadowFilter Ogre::HlmsPbs::getShadowFilter ( ) const
inline

◆ getShadowReceiversInPixelShader()

bool Ogre::HlmsPbs::getShadowReceiversInPixelShader ( ) const
inline

◆ getUseLightBuffers()

bool Ogre::HlmsPbs::getUseLightBuffers ( )
inline

◆ getVctFullConeCount()

bool Ogre::HlmsPbs::getVctFullConeCount ( ) const
inline

◆ getVctLighting()

VctLighting* Ogre::HlmsPbs::getVctLighting ( )
inline

◆ loadLtcMatrix()

void Ogre::HlmsPbs::loadLtcMatrix ( )

◆ OGRE_DEPRECATED_VER()

Ogre::HlmsPbs::OGRE_DEPRECATED_VER ( )

Toggle whether the roughness value (set via material parameters and via roughness textures) is perceptual or raw.

Ogre 2.1 and 2.2.0 used raw roughness
Ogre 2.2.1+ default to perceptual roughness to better match the output of other PBR tools

If you're porting from Ogre 2.1 you may want to disable this feature unless if you want your materials to look exactly how they did in 2.2.0 and 2.1

See https://forums.ogre3d.org/viewtopic.php?f=25&t=95523

Deprecated in OgreNext 3.0. This function will be forced to true in 4.0

Parameters
bPerceptualRoughnessTrue to enable perceptual roughess (default) False to use raw roughess (Ogre 2.1's behavior)

◆ postCommandBufferExecution()

void Ogre::HlmsPbs::postCommandBufferExecution ( CommandBuffer commandBuffer)
overridevirtual

This gets called after executing the command buffer.

Reimplemented from Ogre::HlmsBufferManager.

◆ preparePassHash()

HlmsCache Ogre::HlmsPbs::preparePassHash ( const Ogre::CompositorShadowNode shadowNode,
bool  casterPass,
bool  dualParaboloid,
SceneManager sceneManager 
)
overridevirtual

Called every frame by the Render Queue to cache the properties needed by this pass.

i.e. Number of PSSM splits, number of shadow casting lights, etc

Parameters
shadowNodeThe shadow node currently in effect. Can be null.
Returns
A hash and cached property parameters. Unlike calculateHashFor(), the cache must be kept by the caller and not by us (because it may change every frame and is one for the whole pass, but Mesh' properties usually stay consistent through its lifetime but may differ per mesh)

Reimplemented from Ogre::HlmsBufferManager.

◆ resetIblSpecMipmap()

void Ogre::HlmsPbs::resetIblSpecMipmap ( uint8  numMipmaps)

By default we see the reflection textures' mipmaps and store the largest one we found.

By calling resetIblSpecMipmap; you can reset this process thus if a reflection texture with a large number of mipmaps was removed, these textures can be reevaluated

Parameters
numMipmapsWhen 0; we automatically check for reflection texture. When non-zero, we force the number of mipmaps to the specified value

◆ setAmbientLightMode()

void Ogre::HlmsPbs::setAmbientLightMode ( AmbientLightMode  mode)

◆ setAreaLightMasks()

void Ogre::HlmsPbs::setAreaLightMasks ( TextureGpu areaLightMask)

◆ setDebugPssmSplits()

void Ogre::HlmsPbs::setDebugPssmSplits ( bool  bDebug)

◆ setDefaultBrdfWithDiffuseFresnel()

void Ogre::HlmsPbs::setDefaultBrdfWithDiffuseFresnel ( bool  bDefaultToDiffuseFresnel)

OgreNext 3.0 changed Default BRDF to not include diffuse fresnel in order to match what most DCC tools (e.g.

Marmoset) do.

However this breaks existing material scripts which were tuned to the old BRDF.

When enabling this setting, all materials created from scripts (including JSON) will convert Default BRDF to PbsBrdf::DefaultHasDiffuseFresnel which is what was the default on OgreNext 2.4 and earlier.

The same is done with CookTorrance and BlinnPhong models.

Parameters
bDefaultToDiffuseFresnelTrue to convert Default/CookTorrance/BlinnPhong to DefaultHasDiffuseFresnel & co.

◆ setEsmK()

void Ogre::HlmsPbs::setEsmK ( uint16  K)

Sets the 'K' parameter of ESM filter.

Defaults to 600. Small values will give weak shadows, and light bleeding (specially if the caster is close to the receiver; particularly noticeable at contact points). It also gives the chance of over darkening to appear (the shadow of a small caster in front of a large caster looks darker; thus the large caster appers like if it were made of glass instead of being solid).

Large values give strong, dark shadows; but the higher the value, the more you push floating point limits. This value is related to K in MiscUtils::setGaussianLogFilterParams. You don't have to set them to the same value; but you'll notice that if you change this value here, you'll likely have to change the log filter's too.

Parameters
KIn range (0; infinite).

◆ setFineLightMaskGranularity()

void Ogre::HlmsPbs::setFineLightMaskGranularity ( bool  useFineGranularity)
inline

Toggles whether light masks will be obeyed per object by doing: if( movableObject->getLightMask() & light->getLightMask() ) doLighting( movableObject light ); Note this toggle only affects forward lights (i.e.

Directional lights + shadow casting lights). You may want to see ForwardPlusBase::setFineLightMaskGranularity for control over Forward+ lights.

◆ setIndustryCompatible()

void Ogre::HlmsPbs::setIndustryCompatible ( bool  bIndustryCompatible)

There are slight variations between how PBR formulas are handled in OgreNext and other game engines or DCC (Digital Content Creator) tools.

Enabling this setting forces OgreNext to mimic as close as possible what popular DCC are doing.

Enable this option if the art director wants the model to look exactly (or as close as possible) as it looks in Blender/Maya/Marmoset.

Parameters
bIndustryCompatibleTrue to be as close as possible to other DCC. Default is false.

◆ setIrradianceField()

void Ogre::HlmsPbs::setIrradianceField ( IrradianceField irradianceField)
inline

◆ setIrradianceVolume()

void Ogre::HlmsPbs::setIrradianceVolume ( IrradianceVolume irradianceVolume)
inline

◆ setLightProfilesTexture()

void Ogre::HlmsPbs::setLightProfilesTexture ( TextureGpu lightProfilesTex)

◆ setParallaxCorrectedCubemap()

void Ogre::HlmsPbs::setParallaxCorrectedCubemap ( ParallaxCorrectedCubemapBase pcc,
float  pccVctMinDistance = 1.0f,
float  pccVctMaxDistance = 2.0f 
)

Sets PCC.

Remarks
PCC is a crude approximation of reflections that works best when the shape of the objects in the scene resemble the rectangle shape set by the PCC probe(s).

But when they do not, severe distortion could happen.

When both VCT and PCC are active, VCT can be used to determine whether the PCC approximation is accurate. If it is, it uses the PCC result. If it's not, it uses the VCT one (which is accurate but more 'blocky' due to voxelization)

This setting determines how much deviation is allowed and smoothly transition between the VCT and PCC results.

This value only affects specular reflections. For diffuse GI, VCT is always preferred over the cubemap's.

Parameters
pccPointer to PCC
pccVctMinDistanceValue in units (e.g. meters, centimeters, whatever your engine uses) Any discrepancy between PCC and VCT below this threshold means PCC reflections will be used.

The assertion pccVctMinDistance < pccVctMaxDistance must be true. Use a very high pccVctMinDistance to always use PCC

Parameters
pccVctMaxDistanceValue in units (e.g. meters, centimeters, whatever your engine uses) Any discrepancy between PCC and VCT above this threshold means VCT reflections will be used.

Errors between pccVctMinDistance & pccVctMaxDistance will be faded smoothly Use negative pccVctMaxDistance to always use VCT

◆ setShadowReceiversInPixelShader()

void Ogre::HlmsPbs::setShadowReceiversInPixelShader ( bool  bInPixelShader)

Toggles whether light-space position is calculated in vertex or pixel shader.

This position is used for evaluating shadow mapping

Remarks
Set this setting to true if you need to support a very large number of shadow mapped lights (e.g. > 30) because otherwise you will hit HW limits on how much data we can send from Vertex to Pixel shader.

Performance: Whether this setting results in higher or lower performance depends on:

  1. Vertex count of the scene (high vertex count benefit from bInPixelShader = true)
  2. Screen resolution (large resolutions benefit from bInPixelShader = false)
  3. Number of shadow mapping lights (large numbers benefit from bInPixelShader = true)

You will have to profile which setting gives you better performance, although generally speaking for low number of lights (e.g. < 5) bInPixelShader = false is more likely to win.

◆ setShadowSettings()

void Ogre::HlmsPbs::setShadowSettings ( ShadowFilter  filter)

◆ setStaticBranchingLights()

void Ogre::HlmsPbs::setStaticBranchingLights ( bool  staticBranchingLights)
overridevirtual

By default shadow-caster spot and point lights are hardcoded into shaders.

This means that if you have 8 spot/point lights and then you add a 9th one, a whole new set of shaders will be created. Even more if you have a combination of 3 spot and 5 point lights and the combination has changed to 4 spot and 4 point lights then you'll get the next set of shaders

This setting allows you to tremendously reduce the amount of shader permutations by forcing Ogre to switching to static branching with an upper limit to the max number of shadow-casting spot or point lights.

See Hlms::setAreaLightForwardSettings

Remarks
All point and spot lights must share the same hlms_shadowmap atlas

This is mostly an D3D11 / HLSL SM 5.0 restriction (https://github.com/OGRECave/ogre-next/pull/255) but it may also help with performance in other APIs.

If multiple atlas support is needed, using Texture2DArrays may be a good solution, although it is currently untested and may need additional fixes to get it working

Parameters
staticBranchingLightsTrue to evalute number of lights in the shader using static branching (less shader variants). False to recompile the shader more often (more variants, but better optimized shaders).

Reimplemented from Ogre::Hlms.

◆ setUseLightBuffers()

void Ogre::HlmsPbs::setUseLightBuffers ( bool  b)

◆ setVctFullConeCount()

void Ogre::HlmsPbs::setVctFullConeCount ( bool  vctFullConeCount)
inline

When false, we will use 4 cones for diffuse VCT.

When true, we will use 6 cones instead. This is higher quality but consumes more performance and is usually overkill (benefit / cost ratio).

Default value is false

Parameters
vctFullConeCount

◆ setVctLighting()

void Ogre::HlmsPbs::setVctLighting ( VctLighting vctLighting)
inline

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