OGRE 2.1
Object-Oriented Graphics Rendering Engine
|
Shader generator system main interface. More...
#include <OgreShaderGenerator.h>
Public Types | |
typedef std::pair< RenderState *, bool > | RenderStateCreateOrRetrieveResult |
Public Member Functions | |
void | _setActiveSceneManager (SceneManager *sceneManager) |
Set the active scene manager against which new render states are compiled. | |
void | addSceneManager (SceneManager *sceneMgr) |
Add a scene manager to the shader generator scene managers list. | |
void | addSubRenderStateFactory (SubRenderStateFactory *factory) |
Add sub render state factory. | |
bool | cloneShaderBasedTechniques (const String &srcMaterialName, const String &srcGroupName, const String &dstMaterialName, const String &dstGroupName) |
Clone all shader based techniques from one material to another. | |
RenderStateCreateOrRetrieveResult | createOrRetrieveRenderState (const String &schemeName) |
Returns a requested render state. | |
void | createScheme (const String &schemeName) |
Create a scheme. | |
bool | createShaderBasedTechnique (const String &materialName, const String &groupName, const String &srcTechniqueSchemeName, const String &dstTechniqueSchemeName, bool overProgrammable=false) |
Create shader based technique from a given technique. | |
bool | createShaderBasedTechnique (const String &materialName, const String &srcTechniqueSchemeName, const String &dstTechniqueSchemeName, bool overProgrammable=false) |
Create shader based technique from a given technique. | |
SubRenderState * | createSubRenderState (const String &type) |
Create an instance of sub render state from a given type. | |
void | destroySubRenderState (SubRenderState *subRenderState) |
Destroy an instance of sub render state. | |
void | flushShaderCache () |
Flush the shader cache. | |
SceneManager * | getActiveSceneManager () |
Get the active scene manager that is doint the actual scene rendering. | |
bool | getCreateShaderOverProgrammablePass () const |
Returns whether shaders are created for passes with shaders. | |
size_t | getFragmentShaderCount () const |
Return the current number of generated fragment shaders. | |
const String & | getFragmentShaderProfiles () const |
Get the output fragment shader target profiles. | |
const StringVector & | getFragmentShaderProfilesList () const |
Get the output fragment shader target profiles as list of strings. | |
SGMaterialSerializerListener * | getMaterialSerializerListener () |
Return custom material Serializer of the shader generator. | |
size_t | getNumSubRenderStateFactories () const |
Returns the number of existing factories. | |
RenderState * | getRenderState (const String &schemeName) |
Return a global render state associated with the given scheme name. | |
RenderState * | getRenderState (const String &schemeName, const String &materialName, const String &groupName, unsigned short passIndex) |
Get render state of specific pass. | |
RenderState * | getRenderState (const String &schemeName, const String &materialName, unsigned short passIndex) |
Get render state of specific pass. | |
const String & | getRTShaderScheme (size_t index) const |
Returns the scheme name used in the for RT shader generation by index. | |
size_t | getRTShaderSchemeCount () const |
Returns the amount of schemes used in the for RT shader generation. | |
const String & | getShaderCachePath () const |
Get the output shader cache path. | |
SubRenderStateFactory * | getSubRenderStateFactory (const String &type) |
Returns a sub render state factory by name. | |
SubRenderStateFactory * | getSubRenderStateFactory (size_t index) |
Returns a sub render state factory by index. | |
const String & | getTargetLanguage () const |
Return the target shader language currently in use. | |
float | getTargetLanguageVersion () const |
Return the target shader language version currently in use. | |
size_t | getVertexShaderCount () const |
Return the current number of generated vertex shaders. | |
VSOutputCompactPolicy | getVertexShaderOutputsCompactPolicy () const |
Get the vertex shader outputs compaction policy. | |
const String & | getVertexShaderProfiles () const |
Get the output vertex shader target profiles. | |
const StringVector & | getVertexShaderProfilesList () const |
Get the output vertex shader target profiles as list of strings. | |
bool | hasRenderState (const String &schemeName) const |
Tells if a given render state exists. | |
bool | hasShaderBasedTechnique (const String &materialName, const String &groupName, const String &srcTechniqueSchemeName, const String &dstTechniqueSchemeName) const |
Checks if a shader based technique has been created for a given technique. | |
bool | hasShaderBasedTechnique (const String &materialName, const String &srcTechniqueSchemeName, const String &dstTechniqueSchemeName) const |
Checks if a shader based technique has been created for a given technique. | |
void | invalidateMaterial (const String &schemeName, const String &materialName, const String &groupName=ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME) |
Invalidate specific material scheme. | |
void | invalidateMaterialIlluminationPasses (const String &schemeName, const String &materialName, const String &groupName=ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME) |
Invalidate specific material scheme. | |
void | invalidateScheme (const String &schemeName) |
Invalidate a given scheme. | |
bool | IsHlsl4 () const |
Return if hlsl 4.0 shading language is currently in use. | |
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 *) |
void * | operator new (size_t sz) |
void * | operator new (size_t sz, const char *file, int line, const char *func) |
operator new, with debug line info | |
void * | operator new (size_t sz, void *ptr) |
placement operator new | |
void * | operator new[] (size_t sz) |
void * | operator new[] (size_t sz, const char *file, int line, const char *func) |
array operator new, with debug line info | |
void | removeAllShaderBasedTechniques () |
Remove all shader based techniques that created by this shader generator. | |
bool | removeAllShaderBasedTechniques (const String &materialName, const String &groupName=ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME) |
Remove all shader based techniques of the given material. | |
void | removeSceneManager (SceneManager *sceneMgr) |
Remove a scene manager from the shader generator scene managers list. | |
bool | removeShaderBasedTechnique (const String &materialName, const String &groupName, const String &srcTechniqueSchemeName, const String &dstTechniqueSchemeName) |
Remove shader based technique from a given technique. | |
bool | removeShaderBasedTechnique (const String &materialName, const String &srcTechniqueSchemeName, const String &dstTechniqueSchemeName) |
Remove shader based technique from a given technique. | |
void | removeSubRenderStateFactory (SubRenderStateFactory *factory) |
Remove sub render state factory. | |
void | setCreateShaderOverProgrammablePass (bool value) |
Sets whether shaders are created for passes with shaders. | |
void | setFragmentShaderProfiles (const String &fragmentShaderProfiles) |
Set the output fragment shader target profiles. | |
void | setShaderCachePath (const String &cachePath) |
Set the output shader cache path. | |
void | setTargetLanguage (const String &shaderLanguage, const float version=1.0) |
Set the target shader language. | |
void | setVertexShaderOutputsCompactPolicy (VSOutputCompactPolicy policy) |
Set the vertex shader outputs compaction policy. | |
void | setVertexShaderProfiles (const String &vertexShaderProfiles) |
Set the output vertex shader target profiles. | |
bool | validateMaterial (const String &schemeName, const String &materialName, const String &groupName=ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME) |
Validate specific material scheme. | |
bool | validateMaterialIlluminationPasses (const String &schemeName, const String &materialName, const String &groupName=ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME) |
Validate specific material scheme. | |
bool | validateScheme (const String &schemeName) |
Validate a given scheme. | |
Static Public Member Functions | |
static void | destroy () |
Destroy the Shader Generator instance. | |
static ShaderGenerator & | getSingleton () |
Override standard Singleton retrieval. | |
static ShaderGenerator * | getSingletonPtr () |
Override standard Singleton retrieval. | |
static bool | initialize () |
Initialize the Shader Generator System. | |
Static Public Attributes | |
static String | DEFAULT_SCHEME_NAME |
Default material scheme of the shader generator. | |
Friends | |
class | FFPRenderStateBuilder |
class | SGMaterialSerializerListener |
class | SGPass |
class | SGScriptTranslator |
class | SGScriptTranslatorManager |
Shader generator system main interface.
This singleton based class enables automatic generation of shader code based on existing material techniques.
typedef std::pair<RenderState*, bool> Ogre::RTShader::ShaderGenerator::RenderStateCreateOrRetrieveResult |
void Ogre::RTShader::ShaderGenerator::_setActiveSceneManager | ( | SceneManager * | sceneManager | ) |
Set the active scene manager against which new render states are compiled.
Note that normally the setting of the active scene manager is updated through the preFindVisibleObjects method.
void Ogre::RTShader::ShaderGenerator::addSceneManager | ( | SceneManager * | sceneMgr | ) |
Add a scene manager to the shader generator scene managers list.
sceneMgr | The scene manager to add to the list. |
void Ogre::RTShader::ShaderGenerator::addSubRenderStateFactory | ( | SubRenderStateFactory * | factory | ) |
Add sub render state factory.
Plugins or 3d party applications may implement sub classes of SubRenderState interface. Add the matching factory will allow the application to create instances of these sub classes.
factory | The factory to add. |
bool Ogre::RTShader::ShaderGenerator::cloneShaderBasedTechniques | ( | const String & | srcMaterialName, |
const String & | srcGroupName, | ||
const String & | dstMaterialName, | ||
const String & | dstGroupName | ||
) |
Clone all shader based techniques from one material to another.
This function can be used in conjunction with the Material::clone() function to copy both material properties and RTSS state from one material to another.
srcMaterialName | The source material name. |
srcGroupName | The source group name. |
dstMaterialName | The destination material name. |
dstGroupName | The destination group name. |
RenderStateCreateOrRetrieveResult Ogre::RTShader::ShaderGenerator::createOrRetrieveRenderState | ( | const String & | schemeName | ) |
Returns a requested render state.
If the render state does not exist this function creates it.
schemeName | The scheme name to retrieve. |
Create a scheme.
schemeName | The scheme name to create. |
bool Ogre::RTShader::ShaderGenerator::createShaderBasedTechnique | ( | const String & | materialName, |
const String & | groupName, | ||
const String & | srcTechniqueSchemeName, | ||
const String & | dstTechniqueSchemeName, | ||
bool | overProgrammable = false |
||
) |
Create shader based technique from a given technique.
Return true upon success. Failure may occur if the source technique is not FFP pure, or different source technique is mapped to the requested destination scheme.
materialName | The source material name. |
groupName | The source group name. |
srcTechniqueSchemeName | The source technique scheme name. |
dstTechniqueSchemeName | The destination shader based technique scheme name. |
overProgrammable | If true a shader will be created even if the material has shaders |
bool Ogre::RTShader::ShaderGenerator::createShaderBasedTechnique | ( | const String & | materialName, |
const String & | srcTechniqueSchemeName, | ||
const String & | dstTechniqueSchemeName, | ||
bool | overProgrammable = false |
||
) |
Create shader based technique from a given technique.
Return true upon success. Failure may occur if the source technique is not FFP pure, or different source technique is mapped to the requested destination scheme.
materialName | The source material name. |
srcTechniqueSchemeName | The source technique scheme name. |
dstTechniqueSchemeName | The destination shader based technique scheme name. |
overProgrammable | If true a shader will be created even if the material has shaders |
SubRenderState * Ogre::RTShader::ShaderGenerator::createSubRenderState | ( | const String & | type | ) |
Create an instance of sub render state from a given type.
type | The type of sub render state to create. |
Destroy the Shader Generator instance.
void Ogre::RTShader::ShaderGenerator::destroySubRenderState | ( | SubRenderState * | subRenderState | ) |
Destroy an instance of sub render state.
subRenderState | The instance to destroy. |
void Ogre::RTShader::ShaderGenerator::flushShaderCache | ( | ) |
Flush the shader cache.
This operation will cause all active sachems to be invalidated and will destroy any CPU/GPU program that created by this shader generator.
SceneManager * Ogre::RTShader::ShaderGenerator::getActiveSceneManager | ( | ) |
Get the active scene manager that is doint the actual scene rendering.
This attribute will be update on the call to preFindVisibleObjects.
|
inline |
Returns whether shaders are created for passes with shaders.
size_t Ogre::RTShader::ShaderGenerator::getFragmentShaderCount | ( | ) | const |
Return the current number of generated fragment shaders.
Get the output fragment shader target profiles.
|
inline |
Get the output fragment shader target profiles as list of strings.
SGMaterialSerializerListener * Ogre::RTShader::ShaderGenerator::getMaterialSerializerListener | ( | ) |
Return custom material Serializer of the shader generator.
This is useful when you'd like to export certain material that contains shader generator effects. I.E - when writing an exporter you may want mark your material as shader generated material so in the next time you will load it by your application it will automatically generate shaders with custom attributes you wanted. To do it you'll have to do the following steps:
size_t Ogre::RTShader::ShaderGenerator::getNumSubRenderStateFactories | ( | ) | const |
Returns the number of existing factories.
RenderState * Ogre::RTShader::ShaderGenerator::getRenderState | ( | const String & | schemeName | ) |
Return a global render state associated with the given scheme name.
Modifying this render state will affect all techniques that belongs to that scheme. This is the best way to apply global changes to all techniques. After altering the render state one should call invalidateScheme method in order to regenerate shaders.
schemeName | The destination scheme name. |
RenderState * Ogre::RTShader::ShaderGenerator::getRenderState | ( | const String & | schemeName, |
const String & | materialName, | ||
const String & | groupName, | ||
unsigned short | passIndex | ||
) |
Get render state of specific pass.
Using this method allows the user to customize the behavior of a specific pass.
schemeName | The destination scheme name. |
materialName | The specific material name. |
groupName | The specific material name. |
passIndex | The pass index. |
RenderState * Ogre::RTShader::ShaderGenerator::getRenderState | ( | const String & | schemeName, |
const String & | materialName, | ||
unsigned short | passIndex | ||
) |
Get render state of specific pass.
Using this method allows the user to customize the behavior of a specific pass.
schemeName | The destination scheme name. |
materialName | The specific material name. |
passIndex | The pass index. |
Returns the scheme name used in the for RT shader generation by index.
size_t Ogre::RTShader::ShaderGenerator::getRTShaderSchemeCount | ( | ) | const |
Returns the amount of schemes used in the for RT shader generation.
Get the output shader cache path.
|
static |
Override standard Singleton retrieval.
|
static |
Override standard Singleton retrieval.
SubRenderStateFactory * Ogre::RTShader::ShaderGenerator::getSubRenderStateFactory | ( | const String & | type | ) |
Returns a sub render state factory by name.
SubRenderStateFactory * Ogre::RTShader::ShaderGenerator::getSubRenderStateFactory | ( | size_t | index | ) |
Returns a sub render state factory by index.
Return the target shader language currently in use.
|
inline |
Return the target shader language version currently in use.
size_t Ogre::RTShader::ShaderGenerator::getVertexShaderCount | ( | ) | const |
Return the current number of generated vertex shaders.
|
inline |
Get the vertex shader outputs compaction policy.
Get the output vertex shader target profiles.
|
inline |
Get the output vertex shader target profiles as list of strings.
Tells if a given render state exists.
schemeName | The scheme name to check. |
bool Ogre::RTShader::ShaderGenerator::hasShaderBasedTechnique | ( | const String & | materialName, |
const String & | groupName, | ||
const String & | srcTechniqueSchemeName, | ||
const String & | dstTechniqueSchemeName | ||
) | const |
Checks if a shader based technique has been created for a given technique.
Return true if exist. False if not.
materialName | The source material name. |
groupName | The source group name. |
srcTechniqueSchemeName | The source technique scheme name. |
dstTechniqueSchemeName | The destination shader based technique scheme name. |
bool Ogre::RTShader::ShaderGenerator::hasShaderBasedTechnique | ( | const String & | materialName, |
const String & | srcTechniqueSchemeName, | ||
const String & | dstTechniqueSchemeName | ||
) | const |
Checks if a shader based technique has been created for a given technique.
Return true if exist. False if not.
materialName | The source material name. |
srcTechniqueSchemeName | The source technique scheme name. |
dstTechniqueSchemeName | The destination shader based technique scheme name. |
Initialize the Shader Generator System.
Return true upon success.
void Ogre::RTShader::ShaderGenerator::invalidateMaterial | ( | const String & | schemeName, |
const String & | materialName, | ||
const String & | groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME |
||
) |
Invalidate specific material scheme.
This action will lead to shader regeneration of the technique belongs to the given scheme name.
schemeName | The scheme to invalidate. |
materialName | The material to invalidate. |
groupName | The source group name. |
void Ogre::RTShader::ShaderGenerator::invalidateMaterialIlluminationPasses | ( | const String & | schemeName, |
const String & | materialName, | ||
const String & | groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME |
||
) |
Invalidate specific material scheme.
This action will lead to shader regeneration of the technique belongs to the given scheme name.
schemeName | The scheme to invalidate. |
materialName | The material to invalidate. |
groupName | The source group name. |
Invalidate a given scheme.
This action will lead to shader regeneration of all techniques belongs to the given scheme name.
schemeName | The scheme to invalidate. |
|
inline |
Return if hlsl 4.0 shading language is currently in use.
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
operator new, with debug line info
placement operator new
|
inlineinherited |
|
inlineinherited |
array operator new, with debug line info
void Ogre::RTShader::ShaderGenerator::removeAllShaderBasedTechniques | ( | ) |
Remove all shader based techniques that created by this shader generator.
bool Ogre::RTShader::ShaderGenerator::removeAllShaderBasedTechniques | ( | const String & | materialName, |
const String & | groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME |
||
) |
Remove all shader based techniques of the given material.
Return true upon success.
materialName | The source material name. |
groupName | The source group name. |
void Ogre::RTShader::ShaderGenerator::removeSceneManager | ( | SceneManager * | sceneMgr | ) |
Remove a scene manager from the shader generator scene managers list.
sceneMgr | The scene manager to remove from the list. |
bool Ogre::RTShader::ShaderGenerator::removeShaderBasedTechnique | ( | const String & | materialName, |
const String & | groupName, | ||
const String & | srcTechniqueSchemeName, | ||
const String & | dstTechniqueSchemeName | ||
) |
Remove shader based technique from a given technique.
Return true upon success. Failure may occur if the given source technique was not previously registered successfully using the createShaderBasedTechnique method.
materialName | The source material name. |
groupName | The source group name. |
srcTechniqueSchemeName | The source technique scheme name. |
dstTechniqueSchemeName | The destination shader based technique scheme name. |
bool Ogre::RTShader::ShaderGenerator::removeShaderBasedTechnique | ( | const String & | materialName, |
const String & | srcTechniqueSchemeName, | ||
const String & | dstTechniqueSchemeName | ||
) |
Remove shader based technique from a given technique.
Return true upon success. Failure may occur if the given source technique was not previously registered successfully using the createShaderBasedTechnique method.
materialName | The source material name. |
srcTechniqueSchemeName | The source technique scheme name. |
dstTechniqueSchemeName | The destination shader based technique scheme name. |
void Ogre::RTShader::ShaderGenerator::removeSubRenderStateFactory | ( | SubRenderStateFactory * | factory | ) |
Remove sub render state factory.
factory | The factory to remove. |
Sets whether shaders are created for passes with shaders.
Note that this only refers to when the system parses the materials itself. Not for when calling the createShaderBasedTechnique() function directly
value | The value to set this attribute pass. |
void Ogre::RTShader::ShaderGenerator::setFragmentShaderProfiles | ( | const String & | fragmentShaderProfiles | ) |
Set the output fragment shader target profiles.
fragmentShaderProfiles | The target profiles for the fragment shader. |
Set the output shader cache path.
Generated shader code will be written to this path. In case of empty cache path shaders will be generated directly from system memory.
cachePath | The cache path of the shader. The default is empty cache path. |
void Ogre::RTShader::ShaderGenerator::setTargetLanguage | ( | const String & | shaderLanguage, |
const float | version = 1.0 |
||
) |
Set the target shader language.
shaderLanguage | The output shader language to use. |
|
inline |
Set the vertex shader outputs compaction policy.
policy | The policy to set. |
void Ogre::RTShader::ShaderGenerator::setVertexShaderProfiles | ( | const String & | vertexShaderProfiles | ) |
Set the output vertex shader target profiles.
vertexShaderProfiles | The target profiles for the vertex shader. |
bool Ogre::RTShader::ShaderGenerator::validateMaterial | ( | const String & | schemeName, |
const String & | materialName, | ||
const String & | groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME |
||
) |
Validate specific material scheme.
This action will generate shader programs for the technique of the given scheme name.
schemeName | The scheme to validate. |
materialName | The material to validate. |
groupName | The source group name. |
bool Ogre::RTShader::ShaderGenerator::validateMaterialIlluminationPasses | ( | const String & | schemeName, |
const String & | materialName, | ||
const String & | groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME |
||
) |
Validate specific material scheme.
This action will generate shader programs illumination passes of the technique of the given scheme name.
schemeName | The scheme to validate. |
materialName | The material to validate. |
groupName | The source group name. |
Validate a given scheme.
This action will generate shader programs for all techniques of the given scheme name.
schemeName | The scheme to validate. |
|
friend |
|
friend |
|
static |
Default material scheme of the shader generator.