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

Implementation without lighting or skeletal animation specfically designed for OpenGL 3+, D3D11 and other RenderSystems which support uniform buffers. More...

#include <OgreHlmsUnlit.h>

+ Inheritance diagram for Ogre::HlmsUnlit:

Public Member Functions

 HlmsUnlit (Archive *dataFolder, ArchiveVec *libraryFolders)
 
 HlmsUnlit (Archive *dataFolder, ArchiveVec *libraryFolders, HlmsTypes type, const String &typeName)
 
 ~HlmsUnlit () 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 _saveJson (const HlmsDatablock *datablock, String &outString, HlmsJsonListener *listener, const String &additionalTextureExtension) const 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...
 
bool getDefaultGenerateMipmaps () const
 Returns true if automatic mipmap generation when loading textures is on. More...
 
uint16 getEsmK () const
 
bool getShadowFilter () const
 
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 setDefaultGenerateMipmaps (bool bDefaultGenerateMips)
 By default Unlit does not automatically generate mipmaps for textures loaded (the texture may already have mipmaps though). More...
 
void setEsmK (uint16 K)
 Sets the 'K' parameter of ESM filter. More...
 
void setOptimizationStrategy (OptimizationStrategy) override
 Not supported. More...
 
void setShadowSettings (bool useExponentialShadowMaps)
 
- Public Member Functions inherited from Ogre::HlmsBufferManager
 HlmsBufferManager (HlmsTypes type, const String &typeName, Archive *dataFolder, ArchiveVec *libraryFolders)
 
 ~HlmsBufferManager () override
 
void postCommandBufferExecution (CommandBuffer *commandBuffer) override
 This gets called after executing the command buffer. More...
 
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 ()
 
virtual void analyzeBarriers (BarrierSolver &barrierSolver, ResourceTransitionArray &resourceTransitions, Camera *renderingCamera, const bool bCasterPass)
 
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...
 
virtual void setStaticBranchingLights (bool staticBranchingLights)
 By default shadow-caster spot and point lights are hardcoded into shaders. 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)
 

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

- 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 }
 
- Static Public Attributes inherited from Ogre::Hlms
static constexpr size_t kNoTid = 0u
 For single-threaded operations. More...
 

Detailed Description

Implementation without lighting or skeletal animation specfically designed for OpenGL 3+, D3D11 and other RenderSystems which support uniform buffers.

Useful for GUI, ParticleFXs, other misc objects that don't require lighting.

Constructor & Destructor Documentation

◆ HlmsUnlit() [1/2]

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

◆ HlmsUnlit() [2/2]

Ogre::HlmsUnlit::HlmsUnlit ( Archive dataFolder,
ArchiveVec libraryFolders,
HlmsTypes  type,
const String typeName 
)

◆ ~HlmsUnlit()

Ogre::HlmsUnlit::~HlmsUnlit ( )
override

Member Function Documentation

◆ _changeRenderSystem()

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

Reimplemented from Ogre::ConstBufferPool.

◆ _collectSamplerblocks()

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

Reimplemented from Ogre::Hlms.

◆ _loadJson()

void Ogre::HlmsUnlit::_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.

◆ _saveJson()

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

Reimplemented from Ogre::Hlms.

◆ fillBuffersFor()

uint32 Ogre::HlmsUnlit::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::HlmsUnlit::fillBuffersForV1 ( const HlmsCache cache,
const QueuedRenderable queuedRenderable,
bool  casterPass,
uint32  lastCacheHash,
CommandBuffer commandBuffer 
)
overridevirtual

Implements Ogre::Hlms.

◆ fillBuffersForV2()

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

Implements Ogre::Hlms.

◆ frameEnded()

void Ogre::HlmsUnlit::frameEnded ( )
overridevirtual

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

Reimplemented from Ogre::HlmsBufferManager.

◆ getDefaultGenerateMipmaps()

bool Ogre::HlmsUnlit::getDefaultGenerateMipmaps ( ) const
inline

Returns true if automatic mipmap generation when loading textures is on.

See setDefaultGenerateMipmaps()

◆ getDefaultPaths()

static void Ogre::HlmsUnlit::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::HlmsUnlit::getEsmK ( ) const
inline

◆ getShadowFilter()

bool Ogre::HlmsUnlit::getShadowFilter ( ) const
inline

◆ preparePassHash()

HlmsCache Ogre::HlmsUnlit::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.

◆ setDefaultGenerateMipmaps()

void Ogre::HlmsUnlit::setDefaultGenerateMipmaps ( bool  bDefaultGenerateMips)

By default Unlit does not automatically generate mipmaps for textures loaded (the texture may already have mipmaps though).

This behavior is the opposite from HlmsPbs.

This is because often Unlit will be used for 2D stuff, which doesn't require mipmaps. However for 3D stuff, mipmaps are highly useful.

JSON materials can override this behavior.

Parameters
bDefaultGenerateMipsTrue to automatically generate mipmaps False to not generate. If the texture was already loaded by HlmsPbs it may have mipmaps, or if the texture on disk already has mipmaps (e.g. DDS) mipmaps will be loaded.

This setting only affects automatic generation when the texture does not have mipmaps and is being loaded by Unlit.

◆ setEsmK()

void Ogre::HlmsUnlit::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).

◆ setOptimizationStrategy()

void Ogre::HlmsUnlit::setOptimizationStrategy ( OptimizationStrategy  )
inlineoverridevirtual

Not supported.

Reimplemented from Ogre::ConstBufferPool.

◆ setShadowSettings()

void Ogre::HlmsUnlit::setShadowSettings ( bool  useExponentialShadowMaps)

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