OGRE 2.1
Object-Oriented Graphics Rendering Engine
Loading...
Searching...
No Matches
Ogre::HlmsPbsDatablock Class Reference

Contains information needed by PBS (Physically Based Shading) for OpenGL 3+ & D3D11+. More...

#include <OgreHlmsPbsDatablock.h>

+ Inheritance diagram for Ogre::HlmsPbsDatablock:

Public Types

enum  TransparencyModes { None , Transparent , Fade }
 
enum  Workflows { SpecularWorkflow , SpecularAsFresnelWorkflow , MetallicWorkflow }
 

Public Member Functions

 HlmsPbsDatablock (IdString name, HlmsPbs *creator, const HlmsMacroblock *macroblock, const HlmsBlendblock *blendblock, const HlmsParamVec &params)
 Valid parameters in params:
 
virtual ~HlmsPbsDatablock ()
 
uint16 _getTextureIdx (PbsTextureTypes texType) const
 Returns the internal index to the array in a texture array.
 
bool _hasEmissive (void) const
 Returns true if getEmissive is non-zero or if there is an emissive texture set.
 
void _linkRenderable (Renderable *renderable)
 
void _setTextures (const PackedTexture packedTextures[])
 Advanced function for setting all textures at once, instead of one by one, for performance reasons.
 
void _unlinkRenderable (Renderable *renderable)
 
virtual void calculateHash ()
 Calculates the hashes needed for sorting by the RenderQueue (i.e. mTextureHash)
 
HlmsDatablockclone (String name) const
 Creates a copy of this datablock with the same settings, but a different name.
 
CompareFunction getAlphaTest (void) const
 
bool getAlphaTestShadowCasterOnly (void) const
 
float getAlphaTestThreshold (void) const
 
const ConstBufferPool::BufferPoolgetAssignedPool (void) const
 
uint32 getAssignedSlot (void) const
 
ColourValue getBackgroundDiffuse (void) const
 
uint8 getBakedTextureIdx (PbsTextureTypes texType) const
 Returns the index to mBakedTextures.
 
const HlmsBlendblockgetBlendblock (bool casterBlock=false) const
 
uint32 getBrdf (void) const
 
HlmsgetCreator (void) const
 
CubemapProbegetCubemapProbe (void) const
 
PbsBlendModes getDetailMapBlendMode (uint8 detailMapIdx) const
 
Vector4 getDetailMapOffsetScale (uint8 detailMap) const
 
Real getDetailMapWeight (uint8 detailMap) const
 
Real getDetailNormalWeight (uint8 detailNormalMapIdx) const
 Returns the detail normal maps' weight.
 
Vector3 getDiffuse (void) const
 
Vector3 getEmissive (void) const
 
void getFilenameAndResourceGroup (String const **outFilename, String const **outResourceGroup) const
 
Vector3 getFresnel (void) const
 Returns the current fresnel.
 
const vector< Renderable * >::type & getLinkedRenderables (void) const
 
const HlmsMacroblockgetMacroblock (bool casterBlock=false) const
 
float getMetalness (void) const
 
IdString getName (void) const
 
const StringgetNameStr (void) const
 
Real getNormalMapWeight (void) const
 Returns the detail normal maps' weight.
 
bool getReceiveShadows (void) const
 
float getRoughness (void) const
 
const HlmsSamplerblockgetSamplerblock (PbsTextureTypes texType) const
 
Vector3 getSpecular (void) const
 
TexturePtr getTexture (PbsTextureTypes texType) const
 
TexturePtr getTexture (size_t texType) const
 
uint8 getTextureUvSource (PbsTextureTypes sourceType) const
 
float getTransparency (void) const
 
TransparencyModes getTransparencyMode (void) const
 
bool getTwoSidedLighting (void) const
 
bool getUseAlphaFromTextures (void) const
 
Vector4 getUserValue (uint8 userValueIdx) const
 
Workflows getWorkflow (void) const
 
virtual bool hasCustomShadowMacroblock (void) const
 
bool hasEmissiveConstant (void) const
 Returns true iif getEmissive is non-zero.
 
bool hasSeparateFresnel (void) const
 Whether the same fresnel term is used for RGB, or individual ones for each channel.
 
void importUnity (const Vector3 &colour, Real metallic, Real roughness, bool changeBrdf)
 Helper function to import values from Unity (metallic workflow).
 
void importUnity (const Vector3 &diffuse, const Vector3 &specular, Real roughness, bool changeBrdf)
 Helper function to import & convert values from Unity (specular workflow).
 
void operator delete (void *ptr)
 
void operator delete (void *ptr, const char *, int, const char *)
 
void operator delete (void *ptr, void *)
 
void operator delete[] (void *ptr)
 
void operator delete[] (void *ptr, const char *, int, const char *)
 
voidoperator new (size_t sz)
 
voidoperator new (size_t sz, const char *file, int line, const char *func)
 operator new, with debug line info
 
voidoperator new (size_t sz, void *ptr)
 placement operator new
 
voidoperator new[] (size_t sz)
 
voidoperator new[] (size_t sz, const char *file, int line, const char *func)
 array operator new, with debug line info
 
virtual void saveTextures (const String &folderPath, set< String >::type &savedTextures, bool saveOitd, bool saveOriginal, HlmsTextureExportListener *listener)
 
virtual void setAlphaTest (CompareFunction compareFunction, bool shadowCasterOnly=false)
 Sets the alpha test to the given compare function.
 
virtual void setAlphaTestThreshold (float threshold)
 
void setBackgroundDiffuse (const ColourValue &bgDiffuse)
 Sets the diffuse background colour.
 
void setBlendblock (const HlmsBlendblock &blendblock, bool casterBlock=false)
 Sets a new blendblock that matches the same parameter as the input.
 
void setBlendblock (const HlmsBlendblock *blendblock, bool casterBlock=false)
 Sets the blendblock from the given pointer that was already retrieved from the HlmsManager.
 
void setBrdf (PbsBrdf::PbsBrdf brdf)
 Changes the BRDF in use.
 
void setCubemapProbe (CubemapProbe *probe)
 Manually set a probe to affect this particular material.
 
void setDetailMapBlendMode (uint8 detailMapIdx, PbsBlendModes blendMode)
 Changes the blend mode of the detail map.
 
void setDetailMapOffsetScale (uint8 detailMap, const Vector4 &offsetScale)
 Sets the scale and offset of the detail map.
 
void setDetailMapWeight (uint8 detailMap, Real weight)
 Sets the weight of detail map.
 
void setDetailNormalWeight (uint8 detailNormalMapIdx, Real weight)
 Sets the normal mapping weight.
 
void setDiffuse (const Vector3 &diffuseColour)
 Sets the diffuse colour (final multiplier). The colour will be divided by PI for energy conservation.
 
void setEmissive (const Vector3 &emissiveColour)
 Sets emissive colour (e.g.
 
void setFresnel (const Vector3 &fresnel, bool separateFresnel)
 Sets the fresnel (F0) directly, instead of using the IOR.
 
void setIndexOfRefraction (const Vector3 &refractionIdx, bool separateFresnel)
 Calculates fresnel (F0 in most books) based on the IOR.
 
void setMacroblock (const HlmsMacroblock &macroblock, bool casterBlock=false)
 Sets a new macroblock that matches the same parameter as the input.
 
void setMacroblock (const HlmsMacroblock *macroblock, bool casterBlock=false)
 Sets the macroblock from the given pointer that was already retrieved from the HlmsManager.
 
void setMetalness (float metalness)
 Sets the metalness in a metallic workflow.
 
void setNormalMapWeight (Real weight)
 @See setDetailNormalWeight. This is the same, but for the main normal map.
 
void setReceiveShadows (bool receiveShadows)
 When false, objects with this material will not receive shadows (independent of whether they case shadows or not)
 
void setRoughness (float roughness)
 Sets the roughness.
 
void setSamplerblock (PbsTextureTypes texType, const HlmsSamplerblock &params)
 Sets a new sampler block to be associated with the texture (i.e.
 
void setSpecular (const Vector3 &specularColour)
 Sets the specular colour.
 
void setTexture (PbsTextureTypes texType, uint16 arrayIndex, const TexturePtr &newTexture, const HlmsSamplerblock *refParams=0)
 Sets a new texture for rendering.
 
void setTextureUvSource (PbsTextureTypes sourceType, uint8 uvSet)
 Sets which UV set to use for the given texture.
 
void setTransparency (float transparency, TransparencyModes mode=Transparent, bool useAlphaFromTextures=true, bool changeBlendblock=true)
 Makes the material transparent, and sets the amount of transparency.
 
void setTwoSidedLighting (bool twoSided, bool changeMacroblock=true, CullingMode oneSidedShadowCast=CULL_ANTICLOCKWISE)
 Allows support for two sided lighting.
 
void setUserValue (uint8 userValueIdx, const Vector4 &value)
 Sets the value of the userValue, this can be used in a custom piece.
 
void setWorkflow (Workflows workflow)
 Sets whether to use a specular workflow, or a metallic workflow.
 
HlmsTextureManager::TextureMapType suggestMapTypeBasedOnTextureType (PbsTextureTypes type)
 Suggests the TextureMapType (aka texture category) for each type of texture (i.e.
 

Static Public Member Functions

static const chargetCmpString (CompareFunction compareFunction)
 

Public Attributes

uint16 mMacroblockHash [2]
 
float mShadowConstantBias
 
uint32 mTextureHash
 
uint8 mType
 

Static Public Attributes

static const size_t MaterialSizeInGpu
 
static const size_t MaterialSizeInGpuAligned
 

Friends

class HlmsPbs
 

Detailed Description

Contains information needed by PBS (Physically Based Shading) for OpenGL 3+ & D3D11+.

Member Enumeration Documentation

◆ TransparencyModes

Enumerator
None 

No alpha blending. Default.

Transparent 

Realistic transparency that preserves lighting reflections (particularly specular on the edges).

Great for glass, transparent plastic, most stuff. Note that at transparency = 0 the object may not be fully invisible.

Fade 

Good 'ol regular alpha blending.

Ideal for just fading out an object until it completely disappears.

◆ Workflows

Enumerator
SpecularWorkflow 

Specular workflow.

Many popular PBRs use SpecularAsFresnelWorkflow though.

See also
setWorkflow
SpecularAsFresnelWorkflow 

Specular workflow where the specular texture is addressed to the fresnel instead of kS.

This is normally referred as simply Specular workflow in many other PBRs.

See also
setWorkflow
MetallicWorkflow 

Constructor & Destructor Documentation

◆ HlmsPbsDatablock()

Ogre::HlmsPbsDatablock::HlmsPbsDatablock ( IdString  name,
HlmsPbs creator,
const HlmsMacroblock macroblock,
const HlmsBlendblock blendblock,
const HlmsParamVec params 
)

Valid parameters in params:

Parameters
paramsfresnel <value [g, b]> The IOR. @See setIndexOfRefraction When specifying three values, the fresnel is separate for each colour component

fresnel_coeff <value [g, b]> Directly sets the fresnel values, instead of using IORs "F0" in most books about PBS

roughness

Specifies the roughness value. Should be in range (0; inf) Note: Values extremely close to zero could cause NaNs and INFs in the pixel shader, also depends on the GPU's precision.

background_diffuse <r g b a> Specifies diffuse colour to use as a background when diffuse texture are not present. Does not replace 'diffuse <r g b>' Default: background_diffuse 1 1 1 1

diffuse <r g b> Specifies the RGB diffuse colour. "kD" in most books about PBS Default: diffuse 1 1 1 1 Note: Internally the diffuse colour is divided by PI.

diffuse_map <texture name> Name of the diffuse texture for the base image (optional)

specular <r g b> Specifies the RGB specular colour. "kS" in most books about PBS Default: specular 1 1 1 1

specular_map <texture name> Name of the specular texture for the base image (optional).

roughness_map <texture name> Name of the roughness texture for the base image (optional) Note: Only the Red channel will be used, and the texture will be converted to an efficient monochrome representation.

normal_map <texture name> Name of the normal texture for the base image (optional) for normal mapping

detail_weight_map <texture name> Texture that when present, will be used as mask/weight for the 4 detail maps. The R channel is used for detail map #0; the G for detail map #1, B for #2, and Alpha for #3. This affects both the diffuse and normal-mapped detail maps.

detail_map0 <texture name> Similar: detail_map1, detail_map2, detail_map3 Name of the detail map to be used on top of the diffuse colour. There can be gaps (i.e. set detail maps 0 and 2 but not 1)

detail_blend_mode0 <blend_mode> Similar: detail_blend_mode1, detail_blend_mode2, detail_blend_mode3 Blend mode to use for each detail map. Valid values are: "NormalNonPremul", "NormalPremul", "Add", "Subtract", "Multiply", "Multiply2x", "Screen", "Overlay", "Lighten", "Darken", "GrainExtract", "GrainMerge", "Difference"

detail_offset_scale0 <offset_u> <offset_v> <scale_u> <scale_v> Similar: detail_offset_scale1, detail_offset_scale2, detail_offset_scale3 Sets the UV offset and scale of the detail maps.

detail_normal_map0 <texture name> Similar: detail_normal_map1, detail_normal_map2, detail_normal_map3 Name of the detail map's normal map to be used. It's not affected by blend mode. May be used even if there is no detail_map

detail_normal_offset_scale0 <offset_u> <offset_v> <scale_u> <scale_v> Similar: detail_normal_offset_scale1, detail_normal_offset_scale2, detail_normal_offset_scale3 Sets the UV offset and scale of the detail normal maps.

reflection_map <texture name> Name of the reflection map. Must be a cubemap. Doesn't use an UV set because the tex. coords are automatically calculated.

uv_diffuse_map <uv> Similar: uv_specular_map, uv_normal_map, uv_detail_mapN, uv_detail_normal_mapN, uv_detail_weight_map where N is a number between 0 and 3. UV set to use for the particular texture map. The UV value must be in range [0; 8)

transparency

Specifies the transparency amount. Value in range [0; 1] where 0 = full transparency and 1 = fully opaque.

transparency_mode <transparent, none, fade> Specifies the transparency mode.

See also
TransparencyModes

alpha_from_textures <true, false> When set to false transparency calculations ignore the alpha channel in the textures

◆ ~HlmsPbsDatablock()

virtual Ogre::HlmsPbsDatablock::~HlmsPbsDatablock ( )
virtual

Member Function Documentation

◆ _getTextureIdx()

uint16 Ogre::HlmsPbsDatablock::_getTextureIdx ( PbsTextureTypes  texType) const
inline

Returns the internal index to the array in a texture array.

Note: If there is no texture assigned to the given texType, returned value is undefined

◆ _hasEmissive()

bool Ogre::HlmsPbsDatablock::_hasEmissive ( void  ) const

Returns true if getEmissive is non-zero or if there is an emissive texture set.

◆ _linkRenderable()

void Ogre::HlmsDatablock::_linkRenderable ( Renderable renderable)
inherited

◆ _setTextures()

void Ogre::HlmsPbsDatablock::_setTextures ( const PackedTexture  packedTextures[])

Advanced function for setting all textures at once, instead of one by one, for performance reasons.

Parameters
packedTexturesThe reference count in packedTextures[i].samplerblock is assumed to have already been increased prior to calling this function. We will not increase. If null, a default samplerblock will be assigned

◆ _unlinkRenderable()

void Ogre::HlmsDatablock::_unlinkRenderable ( Renderable renderable)
inherited

◆ calculateHash()

virtual void Ogre::HlmsPbsDatablock::calculateHash ( )
virtual

Calculates the hashes needed for sorting by the RenderQueue (i.e. mTextureHash)

Reimplemented from Ogre::HlmsDatablock.

◆ clone()

HlmsDatablock * Ogre::HlmsDatablock::clone ( String  name) const
inherited

Creates a copy of this datablock with the same settings, but a different name.

Parameters
nameName of the cloned datablock.

◆ getAlphaTest()

CompareFunction Ogre::HlmsDatablock::getAlphaTest ( void  ) const
inherited

◆ getAlphaTestShadowCasterOnly()

bool Ogre::HlmsDatablock::getAlphaTestShadowCasterOnly ( void  ) const
inherited

◆ getAlphaTestThreshold()

float Ogre::HlmsDatablock::getAlphaTestThreshold ( void  ) const
inlineinherited

◆ getAssignedPool()

const ConstBufferPool::BufferPool * Ogre::ConstBufferPoolUser::getAssignedPool ( void  ) const
inlineinherited

◆ getAssignedSlot()

uint32 Ogre::ConstBufferPoolUser::getAssignedSlot ( void  ) const
inlineinherited

◆ getBackgroundDiffuse()

ColourValue Ogre::HlmsPbsDatablock::getBackgroundDiffuse ( void  ) const

◆ getBakedTextureIdx()

uint8 Ogre::HlmsPbsDatablock::getBakedTextureIdx ( PbsTextureTypes  texType) const

Returns the index to mBakedTextures.

Returns NUM_PBSM_TEXTURE_TYPES if there is no texture assigned to texType

◆ getBlendblock()

const HlmsBlendblock * Ogre::HlmsDatablock::getBlendblock ( bool  casterBlock = false) const
inlineinherited

◆ getBrdf()

uint32 Ogre::HlmsPbsDatablock::getBrdf ( void  ) const

◆ getCmpString()

static const char * Ogre::HlmsDatablock::getCmpString ( CompareFunction  compareFunction)
staticinherited

◆ getCreator()

Hlms * Ogre::HlmsDatablock::getCreator ( void  ) const
inlineinherited

◆ getCubemapProbe()

CubemapProbe * Ogre::HlmsPbsDatablock::getCubemapProbe ( void  ) const

◆ getDetailMapBlendMode()

PbsBlendModes Ogre::HlmsPbsDatablock::getDetailMapBlendMode ( uint8  detailMapIdx) const

◆ getDetailMapOffsetScale()

Vector4 Ogre::HlmsPbsDatablock::getDetailMapOffsetScale ( uint8  detailMap) const

◆ getDetailMapWeight()

Real Ogre::HlmsPbsDatablock::getDetailMapWeight ( uint8  detailMap) const

◆ getDetailNormalWeight()

Real Ogre::HlmsPbsDatablock::getDetailNormalWeight ( uint8  detailNormalMapIdx) const

Returns the detail normal maps' weight.

◆ getDiffuse()

Vector3 Ogre::HlmsPbsDatablock::getDiffuse ( void  ) const

◆ getEmissive()

Vector3 Ogre::HlmsPbsDatablock::getEmissive ( void  ) const

◆ getFilenameAndResourceGroup()

void Ogre::HlmsDatablock::getFilenameAndResourceGroup ( String const **  outFilename,
String const **  outResourceGroup 
) const
inherited
See also
Hlms::getFilenameAndResourceGroup. This operations is NOT fast. Might return null (if the datablock was removed from the Hlms but somehow is still alive) Usage: String const *filename; String const *resourceGroup; datablock->getFilenameAndResourceGroup( &filename, &resourceGroup ); if( filename && resourceGroup && !filename->empty() && !resourceGroup->empty() ) { //Valid filename & resource group. }

◆ getFresnel()

Vector3 Ogre::HlmsPbsDatablock::getFresnel ( void  ) const

Returns the current fresnel.

Note: when hasSeparateFresnel returns false, the Y and Z components still correspond to mFresnelG & mFresnelB just in case you want to preserve this data (i.e. toggling separate fresnel often (which is not a good idea though, in terms of performance)

◆ getLinkedRenderables()

const vector< Renderable * >::type & Ogre::HlmsDatablock::getLinkedRenderables ( void  ) const
inlineinherited

◆ getMacroblock()

const HlmsMacroblock * Ogre::HlmsDatablock::getMacroblock ( bool  casterBlock = false) const
inlineinherited

◆ getMetalness()

float Ogre::HlmsPbsDatablock::getMetalness ( void  ) const

◆ getName()

IdString Ogre::HlmsDatablock::getName ( void  ) const
inlineinherited

◆ getNameStr()

const String * Ogre::HlmsDatablock::getNameStr ( void  ) const
inherited
See also
Hlms::getNameStr. This operations is NOT fast. Might return null (if the datablock was removed from the Hlms but somehow is still alive)

◆ getNormalMapWeight()

Real Ogre::HlmsPbsDatablock::getNormalMapWeight ( void  ) const

Returns the detail normal maps' weight.

◆ getReceiveShadows()

bool Ogre::HlmsPbsDatablock::getReceiveShadows ( void  ) const

◆ getRoughness()

float Ogre::HlmsPbsDatablock::getRoughness ( void  ) const

◆ getSamplerblock()

const HlmsSamplerblock * Ogre::HlmsPbsDatablock::getSamplerblock ( PbsTextureTypes  texType) const

◆ getSpecular()

Vector3 Ogre::HlmsPbsDatablock::getSpecular ( void  ) const

◆ getTexture() [1/2]

TexturePtr Ogre::HlmsPbsDatablock::getTexture ( PbsTextureTypes  texType) const

◆ getTexture() [2/2]

TexturePtr Ogre::HlmsPbsDatablock::getTexture ( size_t  texType) const

◆ getTextureUvSource()

uint8 Ogre::HlmsPbsDatablock::getTextureUvSource ( PbsTextureTypes  sourceType) const

◆ getTransparency()

float Ogre::HlmsPbsDatablock::getTransparency ( void  ) const
inline

◆ getTransparencyMode()

TransparencyModes Ogre::HlmsPbsDatablock::getTransparencyMode ( void  ) const
inline

◆ getTwoSidedLighting()

bool Ogre::HlmsPbsDatablock::getTwoSidedLighting ( void  ) const

◆ getUseAlphaFromTextures()

bool Ogre::HlmsPbsDatablock::getUseAlphaFromTextures ( void  ) const
inline

◆ getUserValue()

Vector4 Ogre::HlmsPbsDatablock::getUserValue ( uint8  userValueIdx) const

◆ getWorkflow()

Workflows Ogre::HlmsPbsDatablock::getWorkflow ( void  ) const

◆ hasCustomShadowMacroblock()

virtual bool Ogre::HlmsPbsDatablock::hasCustomShadowMacroblock ( void  ) const
virtual

Reimplemented from Ogre::HlmsDatablock.

◆ hasEmissiveConstant()

bool Ogre::HlmsPbsDatablock::hasEmissiveConstant ( void  ) const

Returns true iif getEmissive is non-zero.

◆ hasSeparateFresnel()

bool Ogre::HlmsPbsDatablock::hasSeparateFresnel ( void  ) const

Whether the same fresnel term is used for RGB, or individual ones for each channel.

◆ importUnity() [1/2]

void Ogre::HlmsPbsDatablock::importUnity ( const Vector3 colour,
Real  metallic,
Real  roughness,
bool  changeBrdf 
)

Helper function to import values from Unity (metallic workflow).

Remarks
The metallic parameter will be converted to a specular workflow.

◆ importUnity() [2/2]

void Ogre::HlmsPbsDatablock::importUnity ( const Vector3 diffuse,
const Vector3 specular,
Real  roughness,
bool  changeBrdf 
)

Helper function to import & convert values from Unity (specular workflow).

Parameters
changeBrdfTrue if you want us to select a BRDF that closely matches that of Unity. It will change the BRDF to PbsBrdf::DefaultUncorrelated. For best realism though, it is advised that you use that you actually use PbsBrdf::Default.

◆ operator delete() [1/3]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void ptr)
inlineinherited

◆ operator delete() [2/3]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void ptr,
const char ,
int  ,
const char  
)
inlineinherited

◆ operator delete() [3/3]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void ptr,
void  
)
inlineinherited

◆ operator delete[]() [1/2]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete[] ( void ptr)
inlineinherited

◆ operator delete[]() [2/2]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete[] ( void ptr,
const char ,
int  ,
const char  
)
inlineinherited

◆ operator new() [1/3]

template<class Alloc >
void * Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz)
inlineinherited

◆ operator new() [2/3]

template<class Alloc >
void * Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz,
const char file,
int  line,
const char func 
)
inlineinherited

operator new, with debug line info

◆ operator new() [3/3]

template<class Alloc >
void * Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz,
void ptr 
)
inlineinherited

placement operator new

◆ operator new[]() [1/2]

template<class Alloc >
void * Ogre::AllocatedObject< Alloc >::operator new[] ( size_t  sz)
inlineinherited

◆ operator new[]() [2/2]

template<class Alloc >
void * Ogre::AllocatedObject< Alloc >::operator new[] ( size_t  sz,
const char file,
int  line,
const char func 
)
inlineinherited

array operator new, with debug line info

◆ saveTextures()

virtual void Ogre::HlmsPbsDatablock::saveTextures ( const String folderPath,
set< String >::type &  savedTextures,
bool  saveOitd,
bool  saveOriginal,
HlmsTextureExportListener listener 
)
virtual
Remarks
It's possible to set both saveOitd & saveOriginal to true, but will likely double storage requirements (2x as many textures). Setting both to true is useful for troubleshooting obscure Ogre bugs.
Parameters
folderPathFolder where to dump the textures.
savedTextures[in/out] Set of texture names. Textures whose name is already in the set won't be saved again. Textures that were saved will be inserted into the set.
saveOitdWhen true, we will download the texture from GPU and save it in OITD format. OITD is faster to load as it's stored in Ogre's native format it understands, but it cannot be opened by traditional image editors; also OITD is not backwards compatible with older versions of Ogre.
saveOriginalWhen true, we will attempt to read the raw filestream of the original texture and save it (i.e. copy the original png/dds/etc file).

Reimplemented from Ogre::HlmsDatablock.

◆ setAlphaTest()

virtual void Ogre::HlmsDatablock::setAlphaTest ( CompareFunction  compareFunction,
bool  shadowCasterOnly = false 
)
virtualinherited

Sets the alpha test to the given compare function.

CMPF_ALWAYS_PASS means disabled.

See also
mAlphaTestThreshold. Calling this function triggers a HlmsDatablock::flushRenderables
Remarks
It is to the derived implementation to actually implement the alpha test.
Parameters
compareFunctionCompare function to use. Default is CMPF_ALWAYS_PASS, which means disabled. Note: CMPF_ALWAYS_FAIL is not supported. Set a negative threshold to workaround this issue.

◆ setAlphaTestThreshold()

virtual void Ogre::HlmsPbsDatablock::setAlphaTestThreshold ( float  threshold)
virtual
See also
HlmsDatablock::setAlphaTest
Remarks
Alpha testing works on the alpha channel of the diffuse texture. If there is no diffuse texture, the first diffuse detail map after applying the blend weights (texture + params) is used. If there are no diffuse nor detail-diffuse maps, the alpha test is compared against the value 1.0

Reimplemented from Ogre::HlmsDatablock.

◆ setBackgroundDiffuse()

void Ogre::HlmsPbsDatablock::setBackgroundDiffuse ( const ColourValue bgDiffuse)

Sets the diffuse background colour.

When no diffuse texture is present, this solid colour replaces it, and can act as a background for the detail maps.

◆ setBlendblock() [1/2]

void Ogre::HlmsDatablock::setBlendblock ( const HlmsBlendblock blendblock,
bool  casterBlock = false 
)
inherited

Sets a new blendblock that matches the same parameter as the input.

Decreases the reference count of the previous mBlendblock. Runs an O(N) search to get the right block. Calling this function triggers a HlmsDatablock::flushRenderables

Parameters
blendblock@See HlmsManager::getBlendblock
casterBlockTrue to directly set the blendblock to be used during the shadow mapping's caster pass. Note that when false, it will reset the caster block to the same as the regular one.

◆ setBlendblock() [2/2]

void Ogre::HlmsDatablock::setBlendblock ( const HlmsBlendblock blendblock,
bool  casterBlock = false 
)
inherited

Sets the blendblock from the given pointer that was already retrieved from the HlmsManager.

Unlike the other overload, this operation is O(1). Calling this function triggers a HlmsDatablock::flushRenderables

Parameters
blendblockA valid block. The reference count is increased inside this function.
casterBlockTrue to directly set the blendblock to be used during the shadow mapping's caster pass. Note that when false, it will reset the caster block to the same as the regular one.

◆ setBrdf()

void Ogre::HlmsPbsDatablock::setBrdf ( PbsBrdf::PbsBrdf  brdf)

Changes the BRDF in use.

Calling this function may trigger an HlmsDatablock::flushRenderables

◆ setCubemapProbe()

void Ogre::HlmsPbsDatablock::setCubemapProbe ( CubemapProbe probe)

Manually set a probe to affect this particular material.

Remarks
PCC (Parallax Corrected Cubemaps) have two main forms of operation: Auto and manual. They both have advantages and disadvantages. This method allows you to enable the manual mode of operation.
Manual Advantages: It's independent of camera position. The reflections are always visible and working on the object. Works best for static objects Also works well on dynamic objects that you can guarantee are going to be constrained to the probe's area. Manual Disadvantages: Needs to be manually applied on the material by the user. Can produce harsh lighting/reflection seams when two objects affected by different probes are close together. Sucks for dynamic objects.

To use manual probes just call: datablock->setCubemapProbe( probe );

Auto Advantages: Smoothly blends between probes, making smooth transitions Avoids seams. No need to change anything on the material or the object, you don't need to do anything. Works best for dynamic objects (eg. characters) Also works well on static objects if the camera is inside rooms/corridors, thus blocking the view from distant rooms that aren't receiving reflections. Auto Disadvantages: Objects that are further away won't have reflections as only one probe can be active. It depends on the camera's position. Doesn't work well if the user can see many distant objects at once, as they won't have reflections until you get close.

To use Auto you don't need to do anything. Just enable PCC: hlmsPbs->setParallaxCorrectedCubemap( mParallaxCorrectedCubemap ); and leave PBSM_REFLECTION empty and don't enable manual mode.

When other reflection methods can be used as fallback (Planar reflections, SSR), then usually auto will be the preferred choice. But if multiple reflections/fallbacks aren't available, you'll likely have to make good use of manual and auto
Parameters
probeThe probe that should affect this material to enable manual mode. Null pointer to disable manual mode and switch to auto.

◆ setDetailMapBlendMode()

void Ogre::HlmsPbsDatablock::setDetailMapBlendMode ( uint8  detailMapIdx,
PbsBlendModes  blendMode 
)

Changes the blend mode of the detail map.

Calling this function triggers a HlmsDatablock::flushRenderables even if you never use detail maps (they affect the cache's hash)

Remarks
This parameter only affects the diffuse detail map. Not the normal map.
Parameters
detailMapIdxValue in the range [0; 4)
blendModeBlend mode

◆ setDetailMapOffsetScale()

void Ogre::HlmsPbsDatablock::setDetailMapOffsetScale ( uint8  detailMap,
const Vector4 offsetScale 
)

Sets the scale and offset of the detail map.

Remarks
A value of Vector4( 0, 0, 1, 1 ) will cause a flushRenderables as we remove the code from the shader.
Parameters
detailMapValue in the range [0; 4)
offsetScaleXY = Contains the UV offset. ZW = Constains the UV scale. Default value is Vector4( 0, 0, 1, 1 )

◆ setDetailMapWeight()

void Ogre::HlmsPbsDatablock::setDetailMapWeight ( uint8  detailMap,
Real  weight 
)

Sets the weight of detail map.

Affects both diffuse and normal at the same time.

Remarks
A value of 1 will cause a flushRenderables as we remove the code from the shader. The weight from
See also
setNormalMapWeight is multiplied against this value when it comes to the detail normal map.
Parameters
detailMapValue in the range [0; 4)
weightThe weight for the detail map. Usual values are in range [0; 1] but any value is accepted and valid. Default value is 1

◆ setDetailNormalWeight()

void Ogre::HlmsPbsDatablock::setDetailNormalWeight ( uint8  detailNormalMapIdx,
Real  weight 
)

Sets the normal mapping weight.

The range doesn't necessarily have to be in [0; 1]

Remarks
An exact value of 1 will generate a shader without the weighting math, while any other value will generate another shader that uses this weight (i.e. will cause a flushRenderables)
Parameters
detailNormalMapIdxValue in the range [0; 4)
weightThe weight for the normal map. A value of 0 means no effect (tangent space normal is 0, 0, 1); and would be the same as disabling the normal map texture. A value of 1 means full normal map effect. A value outside the [0; 1] range extrapolates. Default value is 1.

◆ setDiffuse()

void Ogre::HlmsPbsDatablock::setDiffuse ( const Vector3 diffuseColour)

Sets the diffuse colour (final multiplier). The colour will be divided by PI for energy conservation.

◆ setEmissive()

void Ogre::HlmsPbsDatablock::setEmissive ( const Vector3 emissiveColour)

Sets emissive colour (e.g.

a firefly). Emissive colour has no physical basis. Though in HDR, if you're working in lumens, this value should probably be in lumens too. To disable emissive, setEmissive( Vector3::ZERO ) and unset any texture in PBSM_EMISSIVE slot.

◆ setFresnel()

void Ogre::HlmsPbsDatablock::setFresnel ( const Vector3 fresnel,
bool  separateFresnel 
)

Sets the fresnel (F0) directly, instead of using the IOR.

@See setIndexOfRefraction

Remarks
If "separateFresnel" was different from the current setting, it will call
See also
HlmsDatablock::flushRenderables. If the another shader must be created, it could cause a stall.
Parameters
refractionIdxThe fresnel of the material for each colour component. When separateFresnel = false, the Y and Z components are ignored.
separateFresnelWhether to use the same fresnel term for RGB channel, or individual ones.

◆ setIndexOfRefraction()

void Ogre::HlmsPbsDatablock::setIndexOfRefraction ( const Vector3 refractionIdx,
bool  separateFresnel 
)

Calculates fresnel (F0 in most books) based on the IOR.

The formula used is ( (1 - idx) / (1 + idx) )²

Remarks
If "separateFresnel" was different from the current setting, it will call
See also
HlmsDatablock::flushRenderables. If the another shader must be created, it could cause a stall.
Parameters
refractionIdxThe index of refraction of the material for each colour component. When separateFresnel = false, the Y and Z components are ignored.
separateFresnelWhether to use the same fresnel term for RGB channel, or individual ones.

◆ setMacroblock() [1/2]

void Ogre::HlmsDatablock::setMacroblock ( const HlmsMacroblock macroblock,
bool  casterBlock = false 
)
inherited

Sets a new macroblock that matches the same parameter as the input.

Decreases the reference count of the previously set one. Runs an O(N) search to get the right block. Calling this function triggers a HlmsDatablock::flushRenderables

Parameters
macroblock@See HlmsManager::getMacroblock
casterBlockTrue to directly set the macroblock to be used during the shadow mapping's caster pass. Note that when false, it will automatically reset the caster's block according to HlmsManager::setShadowMappingUseBackFaces setting.

◆ setMacroblock() [2/2]

void Ogre::HlmsDatablock::setMacroblock ( const HlmsMacroblock macroblock,
bool  casterBlock = false 
)
inherited

Sets the macroblock from the given pointer that was already retrieved from the HlmsManager.

Unlike the other overload, this operation is O(1). Calling this function triggers a HlmsDatablock::flushRenderables

Parameters
macroblockA valid block. The reference count is increased inside this function.
casterBlockTrue to directly set the macroblock to be used during the shadow mapping's caster pass. Note that when false, it will automatically reset the caster's block according to HlmsManager::setShadowMappingUseBackFaces setting.

◆ setMetalness()

void Ogre::HlmsPbsDatablock::setMetalness ( float  metalness)

Sets the metalness in a metallic workflow.

Remarks
Overrides any fresnel value. Should be in Metallic mode.
See also
setWorkflow;
Parameters
metalnessValue in range [0; 1]

◆ setNormalMapWeight()

void Ogre::HlmsPbsDatablock::setNormalMapWeight ( Real  weight)

@See setDetailNormalWeight. This is the same, but for the main normal map.

◆ setReceiveShadows()

void Ogre::HlmsPbsDatablock::setReceiveShadows ( bool  receiveShadows)

When false, objects with this material will not receive shadows (independent of whether they case shadows or not)

Remarks
Changing this parameter will cause a flushRenderables Shadow casting lights (which are normally processed in a Forward way) will still lit the object, it just won't have shadows in it.
Parameters
receiveShadowsWhether to enable or disable receiving shadows.

◆ setRoughness()

void Ogre::HlmsPbsDatablock::setRoughness ( float  roughness)

Sets the roughness.

◆ setSamplerblock()

void Ogre::HlmsPbsDatablock::setSamplerblock ( PbsTextureTypes  texType,
const HlmsSamplerblock params 
)

Sets a new sampler block to be associated with the texture (i.e.

filtering mode, addressing modes, etc). If the samplerblock changes, this function will always trigger a HlmsDatablock::flushRenderables

Parameters
texTypeType of texture.
paramsThe sampler block to use as reference.

◆ setSpecular()

void Ogre::HlmsPbsDatablock::setSpecular ( const Vector3 specularColour)

Sets the specular colour.

◆ setTexture()

void Ogre::HlmsPbsDatablock::setTexture ( PbsTextureTypes  texType,
uint16  arrayIndex,
const TexturePtr newTexture,
const HlmsSamplerblock refParams = 0 
)

Sets a new texture for rendering.

Calling this function may trigger an HlmsDatablock::flushRenderables if the texture or the samplerblock changes. Won't be called if only the arrayIndex changes

Parameters
texTypeType of the texture.
arrayIndexThe index in the array texture.
newTextureTexture to change to. If it is null and previously wasn't (or viceversa), will trigger HlmsDatablock::flushRenderables.
paramsOptional. We'll create (or retrieve an existing) samplerblock based on the input parameters. When null, we leave the previously set samplerblock (if a texture is being set, and if no samplerblock was set, we'll create a default one)

◆ setTextureUvSource()

void Ogre::HlmsPbsDatablock::setTextureUvSource ( PbsTextureTypes  sourceType,
uint8  uvSet 
)

Sets which UV set to use for the given texture.

Calling this function triggers a HlmsDatablock::flushRenderables.

Parameters
sourceTypeSource texture to modify. Note that we don't enforce PBSM_SOURCE_DETAIL0 = PBSM_SOURCE_DETAIL_NM0, but you probably want to have both textures using the same UV source. Must be lower than NUM_PBSM_SOURCES.
uvSetUV coordinate set. Value must be between in range [0; 8)

◆ setTransparency()

void Ogre::HlmsPbsDatablock::setTransparency ( float  transparency,
TransparencyModes  mode = Transparent,
bool  useAlphaFromTextures = true,
bool  changeBlendblock = true 
)

Makes the material transparent, and sets the amount of transparency.

Parameters
transparencyValue in range [0; 1] where 0 = full transparency and 1 = fully opaque.
mode
See also
TransparencyModes
Parameters
useAlphaFromTexturesWhen false, the alpha channel of the diffuse maps and detail maps will be ignored. It's a GPU performance optimization.
changeBlendblockWhen true, the routine prepares the ideal blendblock to use according to the selected mode. When false, the user is expected to change the blendblock manually before calling this function to prevent false warnings. Useful for advanced experiments or artistic license.

◆ setTwoSidedLighting()

void Ogre::HlmsPbsDatablock::setTwoSidedLighting ( bool  twoSided,
bool  changeMacroblock = true,
CullingMode  oneSidedShadowCast = CULL_ANTICLOCKWISE 
)

Allows support for two sided lighting.

Disabled by default (faster)

Remarks
Changing this parameter will cause a flushRenderables
Parameters
twoSidedWhether to enable or disable.
changeMacroblockWhether to change the current macroblock for one that has cullingMode = CULL_NONE or set it to false to leave the current macroblock as is.
oneSidedShadowCastIf changeMacroblock == true; this parameter controls the culling mode of the shadow caster (the setting of HlmsManager::setShadowMappingUseBackFaces is ignored!). While oneSidedShadowCast == CULL_NONE is usually the "correct" option, setting oneSidedShadowCast=CULL_ANTICLOCKWISE can prevent ugly self-shadowing on interiors.

◆ setUserValue()

void Ogre::HlmsPbsDatablock::setUserValue ( uint8  userValueIdx,
const Vector4 value 
)

Sets the value of the userValue, this can be used in a custom piece.

Parameters
userValueIdxWhich userValue to modify, in the range [0; 3)

◆ setWorkflow()

void Ogre::HlmsPbsDatablock::setWorkflow ( Workflows  workflow)

Sets whether to use a specular workflow, or a metallic workflow.

Remarks
The texture types PBSM_SPECULAR & PBSM_METALLIC map to the same value.
When in metal workflow, the texture is used as a metallic texture, and is expected to be a monochrome texture. Global specularity's strength can still be affected via setSpecular. The fresnel settings should not be used (metalness is stored where fresnel used to).
When in specular workflow, the texture is used as a specular texture, and is expected to be either coloured or monochrome. setMetalness should not be called in this mode.
If "workflow" was different from the current setting, it will call
See also
HlmsDatablock::flushRenderables. If the another shader must be created, it could cause a stall.
Parameters
bEnableMetallic

◆ suggestMapTypeBasedOnTextureType()

HlmsTextureManager::TextureMapType Ogre::HlmsPbsDatablock::suggestMapTypeBasedOnTextureType ( PbsTextureTypes  type)

Suggests the TextureMapType (aka texture category) for each type of texture (i.e.

normals should load from TEXTURE_TYPE_NORMALS).

Remarks
Remember that if "myTexture" was loaded as TEXTURE_TYPE_DIFFUSE and then you try to load it as TEXTURE_TYPE_NORMALS, the first one will prevail until it's removed. You could create an alias however, and thus have two copies of the same texture with different loading parameters.

Friends And Related Symbol Documentation

◆ HlmsPbs

Member Data Documentation

◆ MaterialSizeInGpu

const size_t Ogre::HlmsPbsDatablock::MaterialSizeInGpu
static

◆ MaterialSizeInGpuAligned

const size_t Ogre::HlmsPbsDatablock::MaterialSizeInGpuAligned
static

◆ mMacroblockHash

uint16 Ogre::HlmsDatablock::mMacroblockHash[2]
inherited

◆ mShadowConstantBias

float Ogre::HlmsDatablock::mShadowConstantBias
inherited

◆ mTextureHash

uint32 Ogre::HlmsDatablock::mTextureHash
inherited

◆ mType

uint8 Ogre::HlmsDatablock::mType
inherited

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