OGRE
2.2.4
Object-Oriented Graphics Rendering Engine
|
Contains information needed by PBS (Physically Based Shading) for OpenGL ES 2.0. More...
#include <OgreHlmsPbsMobileDatablock.h>
Public Member Functions | |
HlmsPbsMobileDatablock (IdString name, Hlms *creator, const HlmsMacroblock *macroblock, const HlmsBlendblock *blendblock, const HlmsParamVec ¶ms) | |
Valid parameters in params: More... | |
virtual | ~HlmsPbsMobileDatablock () |
int | _calculateNumUvAtlas (bool casterPass) const |
void | _linkRenderable (Renderable *renderable) |
void | _unlinkRenderable (Renderable *renderable) |
virtual void | calculateHash () |
Calculates the hashes needed for sorting by the RenderQueue (i.e. mTextureHash) More... | |
HlmsDatablock * | clone (String name) const |
Creates a copy of this datablock with the same settings, but a different name. More... | |
CompareFunction | getAlphaTest (void) const |
bool | getAlphaTestShadowCasterOnly (void) const |
float | getAlphaTestThreshold (void) const |
const HlmsBlendblock * | getBlendblock (bool casterBlock=false) const |
Hlms * | getCreator (void) const |
const Vector4 & | getDetailMapOffsetScale (uint8 detailMap) const |
Real | getDetailMapWeight (uint8 detailMap) const |
Real | getDetailNormalWeight (uint8 detailNormalMapIdx) const |
Returns the detail normal maps' weight. More... | |
Vector3 | getDiffuse (void) const |
virtual ColourValue | getDiffuseColour (void) const |
Returns the closest match for a diffuse colour, if applicable by the actual implementation. More... | |
virtual TextureGpu * | getDiffuseTexture (void) const |
Returns the closest match for a diffuse texture, if applicable by the actual implementation. More... | |
virtual ColourValue | getEmissiveColour (void) const |
Returns the closest match for a emissive colour, if applicable by the actual implementation. More... | |
virtual TextureGpu * | getEmissiveTexture (void) const |
Returns the closest match for a emissive texture, if applicable by the actual implementation. More... | |
void | getFilenameAndResourceGroup (String const **outFilename, String const **outResourceGroup) const |
Vector3 | getFresnel (void) const |
Returns the current fresnel. More... | |
const vector< Renderable * >::type & | getLinkedRenderables (void) const |
const HlmsMacroblock * | getMacroblock (bool casterBlock=false) const |
IdString | getName (void) const |
const String * | getNameStr (void) const |
Real | getNormalMapWeight (void) const |
Returns the detail normal maps' weight. More... | |
float | getRoughness (void) const |
const HlmsSamplerblock * | getSamplerblock (PbsMobileTextureTypes texType) const |
Vector3 | getSpecular (void) const |
virtual bool | hasCustomShadowMacroblock (void) const |
bool | hasSeparateFresnel (void) const |
Whether the same fresnel term is used for RGB, or individual ones for each channel. More... | |
void | operator delete (void *ptr) |
void | operator delete (void *ptr, void *) |
void | operator delete (void *ptr, const char *, int, const char *) |
void | operator delete[] (void *ptr) |
void | operator delete[] (void *ptr, const char *, int, const char *) |
void * | operator new (size_t sz, const char *file, int line, const char *func) |
operator new, with debug line info More... | |
void * | operator new (size_t sz) |
void * | operator new (size_t sz, void *ptr) |
placement operator new More... | |
void * | operator new[] (size_t sz, const char *file, int line, const char *func) |
array operator new, with debug line info More... | |
void * | operator new[] (size_t sz) |
virtual void | saveTextures (const String &folderPath, set< String >::type &savedTextures, bool saveOitd, bool saveOriginal, HlmsTextureExportListener *listener) |
virtual void | setAlphaTest (CompareFunction compareFunction) |
virtual void | setAlphaTest (CompareFunction compareFunction, bool shadowCasterOnly=false) |
Sets the alpha test to the given compare function. More... | |
virtual void | setAlphaTestThreshold (float threshold) |
Alpha test's threshold. More... | |
void | setBlendblock (const HlmsBlendblock &blendblock, bool casterBlock=false) |
Sets a new blendblock that matches the same parameter as the input. More... | |
void | setBlendblock (const HlmsBlendblock *blendblock, bool casterBlock=false) |
Sets the blendblock from the given pointer that was already retrieved from the HlmsManager. More... | |
void | setDetailMapBlendMode (uint8 detailMapIdx, PbsMobileBlendModes blendMode) |
Changes the blend mode of the detail map. More... | |
void | setDetailMapOffsetScale (uint8 detailMap, const Vector4 &offsetScale) |
Sets the scale and offset of the detail map. More... | |
void | setDetailMapWeight (uint8 detailMap, Real weight) |
Sets the weight of detail map. More... | |
void | setDetailNormalWeight (uint8 detailNormalMapIdx, Real weight) |
Sets the normal mapping weight. More... | |
void | setDiffuse (const Vector3 &diffuseColour) |
Sets the diffuse colour. The colour will be divided by PI for energy conservation. More... | |
void | setFresnel (const Vector3 &fresnel, bool separateFresnel) |
Sets the fresnel (F0) directly, instead of using the IOR. More... | |
void | setIndexOfRefraction (const Vector3 &refractionIdx, bool separateFresnel) |
Calculates fresnel (F0 in most books) based on the IOR. More... | |
void | setMacroblock (const HlmsMacroblock ¯oblock, bool casterBlock=false) |
Sets a new macroblock that matches the same parameter as the input. More... | |
void | setMacroblock (const HlmsMacroblock *macroblock, bool casterBlock=false) |
Sets the macroblock from the given pointer that was already retrieved from the HlmsManager. More... | |
void | setNormalMapWeight (Real weight) |
setDetailNormalWeight. This is the same, but for the main normal map. More... | |
void | setRoughness (float roughness) |
Sets the roughness. More... | |
void | setSamplerblock (PbsMobileTextureTypes texType, const HlmsSamplerblock ¶ms) |
Sets a new sampler block to be associated with the texture (i.e. More... | |
void | setSpecular (const Vector3 &specularColour) |
Sets the specular colour. More... | |
void | setTexture (PbsMobileTextureTypes texType, TexturePtr &newTexture, const PbsUvAtlasParams &atlasParams) |
Sets a new texture for rendering. More... | |
void | setTextureUvSource (PbsMobileTextureTypes sourceType, uint8 uvSet) |
Sets which UV set to use for the given texture. More... | |
Static Public Member Functions | |
static const char * | getCmpString (CompareFunction compareFunction) |
static HlmsTextureManager::TextureMapType | suggestMapTypeBasedOnTextureType (PbsMobileTextureTypes type) |
Suggests the TextureMapType (aka texture category) for each type of texture (i.e. More... | |
static PbsUvAtlasParams | textureLocationToAtlasParams (const HlmsTextureManager::TextureLocation &texLocation) |
Public Attributes | |
bool | mAllowTextureResidencyChange |
When false, we won't try to have Textures become resident. More... | |
float | mkDb |
float | mkDg |
float | mkDr |
float | mkSb |
float | mkSg |
float | mkSr |
uint16 | mMacroblockHash [2] |
float | mRoughness |
float | mShadowConstantBias |
uint32 | mTextureHash |
uint8 | mType |
Friends | |
class | HlmsPbsMobile |
Contains information needed by PBS (Physically Based Shading) for OpenGL ES 2.0.
Ogre::HlmsPbsMobileDatablock::HlmsPbsMobileDatablock | ( | IdString | name, |
Hlms * | creator, | ||
const HlmsMacroblock * | macroblock, | ||
const HlmsBlendblock * | blendblock, | ||
const HlmsParamVec & | params | ||
) |
Valid parameters in params:
params | fresnel <value [g, b]> The IOR. 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.
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)
|
virtual |
int Ogre::HlmsPbsMobileDatablock::_calculateNumUvAtlas | ( | bool | casterPass | ) | const |
|
inherited |
|
inherited |
|
virtual |
Calculates the hashes needed for sorting by the RenderQueue (i.e. mTextureHash)
Reimplemented from Ogre::HlmsDatablock.
|
inherited |
Creates a copy of this datablock with the same settings, but a different name.
name | Name of the cloned datablock. |
|
inherited |
|
inherited |
|
inlineinherited |
|
inlineinherited |
|
staticinherited |
|
inlineinherited |
Returns the detail normal maps' weight.
Vector3 Ogre::HlmsPbsMobileDatablock::getDiffuse | ( | void | ) | const |
|
virtualinherited |
Returns the closest match for a diffuse colour, if applicable by the actual implementation.
Note that Unlit implementation returns 0 as diffuse, since it's considered emissive instead due to being bright even in the absence lights.
|
virtualinherited |
Returns the closest match for a diffuse texture, if applicable by the actual implementation.
|
virtualinherited |
Returns the closest match for a emissive colour, if applicable by the actual implementation.
|
virtualinherited |
Returns the closest match for a emissive texture, if applicable by the actual implementation.
|
inherited |
Vector3 Ogre::HlmsPbsMobileDatablock::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)
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inherited |
Real Ogre::HlmsPbsMobileDatablock::getNormalMapWeight | ( | void | ) | const |
Returns the detail normal maps' weight.
float Ogre::HlmsPbsMobileDatablock::getRoughness | ( | void | ) | const |
const HlmsSamplerblock* Ogre::HlmsPbsMobileDatablock::getSamplerblock | ( | PbsMobileTextureTypes | texType | ) | const |
Vector3 Ogre::HlmsPbsMobileDatablock::getSpecular | ( | void | ) | const |
|
virtualinherited |
bool Ogre::HlmsPbsMobileDatablock::hasSeparateFresnel | ( | void | ) | const |
Whether the same fresnel term is used for RGB, or individual ones for each channel.
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
operator new, with debug line info
|
inlineinherited |
|
inlineinherited |
placement operator new
|
inlineinherited |
array operator new, with debug line info
|
inlineinherited |
|
virtualinherited |
folderPath | Folder 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. |
saveOitd | When 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. |
saveOriginal | When 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 in Ogre::OGRE_HLMS_TEXTURE_BASE_CLASS.
|
virtual |
|
virtualinherited |
Sets the alpha test to the given compare function.
CMPF_ALWAYS_PASS means disabled.
compareFunction | Compare 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. |
|
virtual |
Alpha test's threshold.
threshold | Value typically in the range [0; 1) |
Reimplemented from Ogre::HlmsDatablock.
|
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
blendblock | HlmsManager::getBlendblock |
casterBlock | True 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. |
|
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
blendblock | A valid block. The reference count is increased inside this function. |
casterBlock | True 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. |
void Ogre::HlmsPbsMobileDatablock::setDetailMapBlendMode | ( | uint8 | detailMapIdx, |
PbsMobileBlendModes | 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)
detailMapIdx | Value in the range [0; 4) |
blendMode | Blend mode |
void Ogre::HlmsPbsMobileDatablock::setDetailMapOffsetScale | ( | uint8 | detailMap, |
const Vector4 & | offsetScale | ||
) |
Sets the scale and offset of the detail map.
detailMap | Value in the range [0; 8) Range [0; 4) affects diffuse maps. Range [4; 8) affects normal maps. |
offsetScale | XY = Contains the UV offset. ZW = Constains the UV scale. Default value is Vector4( 0, 0, 1, 1 ) |
Sets the weight of detail map.
Affects both diffuse and normal at the same time.
detailMap | Value in the range [0; 4) |
weight | The weight for the detail map. Usual values are in range [0; 1] but any value is accepted and valid. Default value is 1 |
Sets the normal mapping weight.
The range doesn't necessarily have to be in [0; 1]
detailNormalMapIdx | Value in the range [0; 4) |
weight | The 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. |
void Ogre::HlmsPbsMobileDatablock::setDiffuse | ( | const Vector3 & | diffuseColour | ) |
Sets the diffuse colour. The colour will be divided by PI for energy conservation.
void Ogre::HlmsPbsMobileDatablock::setFresnel | ( | const Vector3 & | fresnel, |
bool | separateFresnel | ||
) |
Sets the fresnel (F0) directly, instead of using the IOR.
setIndexOfRefraction
refractionIdx | The fresnel of the material for each colour component. When separateFresnel = false, the Y and Z components are ignored. |
separateFresnel | Whether to use the same fresnel term for RGB channel, or individual ones. |
void Ogre::HlmsPbsMobileDatablock::setIndexOfRefraction | ( | const Vector3 & | refractionIdx, |
bool | separateFresnel | ||
) |
Calculates fresnel (F0 in most books) based on the IOR.
The formula used is ( (1 - idx) / 1 + idx )²
refractionIdx | The index of refraction of the material for each colour component. When separateFresnel = false, the Y and Z components are ignored. |
separateFresnel | Whether to use the same fresnel term for RGB channel, or individual ones. |
|
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
macroblock | HlmsManager::getMacroblock |
casterBlock | True 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. |
|
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
macroblock | A valid block. The reference count is increased inside this function. |
casterBlock | True 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. |
void Ogre::HlmsPbsMobileDatablock::setNormalMapWeight | ( | Real | weight | ) |
setDetailNormalWeight. This is the same, but for the main normal map.
void Ogre::HlmsPbsMobileDatablock::setRoughness | ( | float | roughness | ) |
Sets the roughness.
void Ogre::HlmsPbsMobileDatablock::setSamplerblock | ( | PbsMobileTextureTypes | texType, |
const HlmsSamplerblock & | params | ||
) |
Sets a new sampler block to be associated with the texture (i.e.
filtering mode, addressing modes, etc).
texType | Type of texture. |
params | The sampler block to use as reference. |
void Ogre::HlmsPbsMobileDatablock::setSpecular | ( | const Vector3 & | specularColour | ) |
Sets the specular colour.
void Ogre::HlmsPbsMobileDatablock::setTexture | ( | PbsMobileTextureTypes | texType, |
TexturePtr & | newTexture, | ||
const PbsUvAtlasParams & | atlasParams | ||
) |
Sets a new texture for rendering.
UvAtlasParams | Type of the texture. |
newTexture | Texture to change to. If it is null and previously wasn't (or viceversa), will trigger HlmsDatablock::flushRenderables. |
atlasParams | The atlas offsets in case this texture is an atlas or an array texture Doesn't apply to certain texture types (i.e. PBSM_REFLECTION) |
void Ogre::HlmsPbsMobileDatablock::setTextureUvSource | ( | PbsMobileTextureTypes | sourceType, |
uint8 | uvSet | ||
) |
Sets which UV set to use for the given texture.
Calling this function triggers a HlmsDatablock::flushRenderables.
sourceType | Source 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. |
uvSet | UV coordinate set. Value must be between in range [0; 8) |
|
static |
Suggests the TextureMapType (aka texture category) for each type of texture (i.e.
normals should load from TEXTURE_TYPE_NORMALS).
|
static |
|
friend |
|
inherited |
When false, we won't try to have Textures become resident.
float Ogre::HlmsPbsMobileDatablock::mkDb |
float Ogre::HlmsPbsMobileDatablock::mkDg |
float Ogre::HlmsPbsMobileDatablock::mkDr |
float Ogre::HlmsPbsMobileDatablock::mkSb |
float Ogre::HlmsPbsMobileDatablock::mkSg |
float Ogre::HlmsPbsMobileDatablock::mkSr |
|
inherited |
float Ogre::HlmsPbsMobileDatablock::mRoughness |
|
inherited |
|
inherited |
|
inherited |