Go to the documentation of this file.
27 #ifndef _ShaderGenerator_
28 #define _ShaderGenerator_
360 const String& srcGroupName,
const String& dstMaterialName,
const String& dstGroupName);
478 int cmpVal = strcmp(p1.first.c_str(),p2.first.c_str());
479 return (cmpVal < 0) || ((cmpVal == 0) && (strcmp(p1.second.c_str(),p2.second.c_str()) < 0));
676 bool empty()
const {
return mTechniqueEntries.empty(); }
754 const LightList* pLightList,
bool suppressRenderStateChanges)
756 mOwner->notifyRenderSingleObject(rend, pass, source, pLightList, suppressRenderStateChanges);
778 mOwner->preFindVisibleObjects(source, irs, v);
793 Camera* camera,
size_t iteration)
821 return mOwner->getNumTranslators();
827 return mOwner->getTranslator(node);
1011 friend class FFPRenderStateBuilder;
const String & getFragmentShaderProfiles() const
Get the output fragment shader target profiles.
Technique * mDstTechnique
Technique * findSourceTechnique(const String &materialName, const String &groupName, const String &srcTechniqueSchemeName, bool allowProgrammable)
Find source technique to generate shader based technique based on it.
SGTechniqueList mTechniqueEntries
SubRenderState * createSubRenderState(const String &type)
Create an instance of sub render state from a given type.
bool mCreateShaderOverProgrammablePass
This utility class is used to hold the information used to generate the matrices and other informatio...
FileSystemLayer * mFSLayer
Class representing the state of a single texture unit during a Pass of a Technique,...
void removeSubRenderStateFactory(SubRenderStateFactory *factory)
Remove sub render state factory.
const String & getGroupName() const
Get the group name.
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.
SGTechniqueList mTechniqueEntries
const String & getDestinationTechniqueSchemeName() const
Get the destination technique scheme name.
map< SGTechnique *, SGTechnique * >::type SGTechniqueMap
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
IlluminationRenderStage
Describes the stage of rendering when performing complex illumination.
RenderStateCreateOrRetrieveResult createOrRetrieveRenderState(const String &schemeName)
Returns a requested render state.
SGScriptTranslatorMap::iterator SGScriptTranslatorIterator
This class translates script AST (abstract syntax tree) into Ogre resources.
SceneManager * mActiveSceneMgr
map< String, SGScheme * >::type SGSchemeMap
SGSceneManagerListener * mSceneManagerListener
static ShaderGenerator & getSingleton()
Override standard Singleton retrieval.
Class that allows listening in on the various stages of SceneManager processing, so that custom behav...
SGPassList::iterator SGPassIterator
This class is the base interface of sub part from a shader based rendering pipeline.
SGScriptTranslatorMap mScriptTranslatorsMap
SGScriptTranslatorManager(ShaderGenerator *owner)
void buildTargetRenderState()
Build the render state.
const String & getMaterialName() const
Get the material name.
SGPass(SGTechnique *parent, Pass *srcPass, Pass *dstPass)
void addSceneManager(SceneManager *sceneMgr)
Add a scene manager to the shader generator scene managers list.
std::pair< RenderState *, bool > RenderStateCreateOrRetrieveResult
A viewpoint from which the scene will be rendered.
map< String, ScriptTranslator * >::type SGScriptTranslatorMap
bool _initialize()
Initialize the shader generator instance.
SGSceneManagerListener(ShaderGenerator *owner)
void setVertexShaderProfiles(const String &vertexShaderProfiles)
Set the output vertex shader target profiles.
SubRenderStateFactory * getSubRenderStateFactory(const String &type)
Returns a sub render state factory by name.
bool removeShaderBasedTechnique(const String &materialName, const String &groupName, const String &srcTechniqueSchemeName, const String &dstTechniqueSchemeName)
Remove shader based technique from a given technique.
void releasePrograms()
Release the CPU/GPU programs of this pass.
vector< String >::type StringVector
const StringVector & getVertexShaderProfilesList() const
Get the output vertex shader target profiles as list of strings.
void createSubRenderStateExFactories()
Create sub render state core extensions factories.
void invalidate()
Invalidate the whole scheme.
SGMaterialSerializerListener * mMaterialSerializerListener
Shader generator technique wrapper class.
ProgramManager * mProgramManager
SubRenderStateFactoryMap mSubRenderStateFactories
SubRenderStateFactoryMap::const_iterator SubRenderStateFactoryConstIterator
Representation of a dynamic light source in the scene.
SubRenderState * getCustomFFPSubState(int subStateOrder, const RenderState *renderState)
bool validateMaterial(const String &schemeName, const String &materialName, const String &groupName=ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME)
Validate specific material scheme.
virtual size_t getNumTranslators() const
Returns the number of translators being managed.
const StringVector & getFragmentShaderProfilesList() const
Get the output fragment shader target profiles as list of strings.
RenderStateList mCustomRenderStates
void buildTargetRenderState()
Build the render state.
void releasePrograms()
Release the CPU/GPU programs of this technique.
SGTechniqueList & getTechniqueList()
Get the techniques list of this material.
SGMaterial(const String &materialName, const String &groupName)
Class constructor.
RenderState * getRenderState(const String &schemeName, const String &materialName, const String &groupName, unsigned short passIndex)
Get render state of specific pass.
void addSubRenderStateFactory(SubRenderStateFactory *factory)
Add sub render state factory.
String mFragmentShaderProfiles
SubRenderState * createSubRenderState(ScriptCompiler *compiler, PropertyAbstractNode *prop, TextureUnitState *texState, SGScriptTranslator *translator)
Create an instance of the SubRenderState based on script properties using the current sub render stat...
SGPassList::const_iterator SGPassConstIterator
Technique * mSrcTechnique
Pass * getDstPass()
Get destination pass.
bool hasRenderState(const String &schemeName) const
Tells if a given render state exists.
static void destroy()
Destroy the Shader Generator instance.
static String AUTODETECT_RESOURCE_GROUP_NAME
Special resource group name which causes resource group to be automatically determined based on searc...
map< MatGroupPair, SGMaterial *, MatGroupPair_less >::type SGMaterialMap
void invalidateScheme(const String &schemeName)
Invalidate a given scheme.
SGSchemeMap mSchemeEntriesMap
void destroySubRenderStateExFactories()
Destroy sub render state core extensions factories.
void createSGPasses()
Create the passes entries.
const SGTechniqueList & getTechniqueList() const
Get the const techniques list of this material.
SchemeCreateOrRetrieveResult createOrRetrieveScheme(const String &schemeName)
Returns a requested scheme.
Abstract factory interface for creating SubRenderState implementation instances.
bool getBuildDestinationTechnique() const
Tells if the destination technique should be build.
SGScriptTranslatorMap::const_iterator SGScriptTranslatorConstIterator
bool getIsFinalizing() const
Used to check if finalizing.
Class defining a single pass of a Technique (of a Material), i.e.
Class representing an approach to rendering this particular Material.
virtual ScriptTranslator * getTranslator(const AbstractNodePtr &node)
Returns a manager for the given object abstract node, or null if it is not supported.
~ShaderGenerator()
Class destructor.
TargetRenderState * mTargetRenderState
RenderState * getRenderState()
Get global render state of this scheme.
bool getCreateShaderOverProgrammablePass() const
Returns whether shaders are created for passes with shaders.
const String & getShaderCachePath() const
Get the output shader cache path.
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 createShaderBasedTechnique(const String &materialName, const String &groupName, const String &srcTechniqueSchemeName, const String &dstTechniqueSchemeName, bool overProgrammable=false)
Create shader based technique from a given technique.
SGScriptTranslator mCoreScriptTranslator
ProgramWriterManager * mProgramWriterManager
Abstract interface which classes must implement if they wish to receive events from the scene manager...
StringVector mFragmentShaderProfilesList
bool isProgrammable(Technique *tech) const
Checks if a given technique has passes with shaders.
SGMaterialIterator findMaterialEntryIt(const String &materialName, const String &groupName)
Finds an entry iterator in the mMaterialEntriesMap map.
bool removeCustomScriptTranslator(const String &key)
Remove custom script translator.
virtual void notifyRenderSingleObject(Renderable *rend, const Pass *pass, const AutoParamDataSource *source, const LightList *pLightList, bool suppressRenderStateChanges)
Listener overridden function notify the shader generator when rendering single object.
void acquirePrograms()
Acquire the CPU/GPU programs for this technique.
SGSchemeMap::const_iterator SGSchemeConstIterator
SubRenderStateFactory * getSubRenderStateFactory(size_t index)
Returns a sub render state factory by index.
vector< SGPass * >::type SGPassList
void notifyRenderSingleObject(Renderable *rend, const AutoParamDataSource *source, const LightList *pLightList, bool suppressRenderStateChanges)
Called when a single object is about to be rendered.
bool empty() const
Return true if this scheme dose not contains any techniques.
RenderState * getCustomRenderState()
Get custom render state of this pass.
RenderState * getRenderState(const String &schemeName)
Return a global render state associated with the given scheme name.
Shader generator scene manager sub class.
bool createShaderBasedTechnique(const String &materialName, const String &srcTechniqueSchemeName, const String &dstTechniqueSchemeName, bool overProgrammable=false)
Create shader based technique from a given technique.
bool validate(const String &materialName, const String &groupName=ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME)
Validate specific material.
ScriptTranslator * getTranslator(const AbstractNodePtr &node)
Return a matching script translator.
Manages the organisation and rendering of a 'scene' i.e.
virtual void shadowTexturesUpdated(size_t numberOfShadowTextures)
Event raised after all shadow textures have been rendered into for all queues / targets but before an...
void invalidateMaterial(const String &schemeName, const String &materialName, const String &groupName=ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME)
Invalidate specific material scheme.
An abstraction of a viewport, i.e.
static ShaderGenerator * getSingletonPtr()
Override standard Singleton retrieval.
void setTargetLanguage(const String &shaderLanguage)
Set the target shader language.
SGTechnique(SGMaterial *parent, Technique *srcTechnique, const String &dstTechniqueSchemeName)
This is the main class for the compiler.
SGRenderObjectListener * mRenderObjectListener
SGMaterialConstIterator findMaterialEntryIt(const String &materialName, const String &groupName) const
The ScriptTranslatorManager manages the lifetime and access to script translators.
This is a container class for sub render state class.
Technique * getDestinationTechnique()
Get the destination technique.
StringVector mVertexShaderProfilesList
Class for serializing Materials to / from a .material script.
String mDstTechniqueSchemeName
Template class for creating single-instance global classes.
void setFragmentShaderProfiles(const String &fragmentShaderProfiles)
Set the output fragment shader target profiles.
void synchronizeWithFogSettings()
Synchronize the fog settings of this scheme with the current settings of the scene.
RenderState * getRenderState(unsigned short passIndex)
Get render state of specific pass.
RenderState * getRenderState(const String &materialName, const String &groupName, unsigned short passIndex)
Get specific pass render state.
SGSchemeMap::iterator SGSchemeIterator
void invalidate(const String &materialName, const String &groupName=ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME)
Invalidate specific material.
virtual void shadowTextureCasterPreViewProj(Light *light, Camera *camera, size_t iteration)
This event occurs just before the view & projection matrices are set for rendering into a shadow text...
SubRenderState * getCustomFFPSubState(int subStateOrder)
Get custom FPP sub state of this pass.
const SGMaterial * getParent() const
Get the parent SGMaterial.
SceneManagerMap mSceneManagerMap
bool mActiveViewportValid
bool validateScheme(const String &schemeName)
Validate a given scheme.
bool removeShaderBasedTechnique(const String &materialName, const String &srcTechniqueSchemeName, const String &dstTechniqueSchemeName)
Remove shader based technique from a given technique.
void setBuildDestinationTechnique(bool buildTechnique)
Tells the technique that it needs to generate shader code.
static bool initialize()
Initialize the Shader Generator System.
void synchronizeWithLightSettings()
Synchronize the current light settings of this scheme with the current settings of the scene.
void setCreateShaderOverProgrammablePass(bool value)
Sets whether shaders are created for passes with shaders.
const String & getRTShaderScheme(size_t index) const
Returns the scheme name used in the for RT shader generation by index.
A frustum represents a pyramid, capped at the near and far end which is used to represent either a vi...
void setShaderCachePath(const String &cachePath)
Set the output shader cache path.
Shader generator RenderObjectListener sub class.
void destroySGPasses()
Destroy the passes entries.
std::pair< SGScheme *, bool > SchemeCreateOrRetrieveResult
bool cloneShaderBasedTechniques(const String &srcMaterialName, const String &srcGroupName, const String &dstMaterialName, const String &dstGroupName)
Clone all shader based techniques from one material to another.
void setVertexShaderOutputsCompactPolicy(VSOutputCompactPolicy policy)
Set the vertex shader outputs compaction policy.
Reference-counted shared pointer, used for objects where implicit destruction is required.
void setCustomRenderState(RenderState *customRenderState)
Set the custom render state of this pass.
SGTechniqueList::iterator SGTechniqueIterator
SGTechniqueMap::iterator SGTechniqueMapIterator
Shader generator scheme class.
Shader generator ScriptTranslatorManager sub class.
const String & getVertexShaderProfiles() const
Get the output vertex shader target profiles.
void preFindVisibleObjects(SceneManager *source, SceneManager::IlluminationRenderStage irs, Viewport *v)
Called from the sub class of the SceneManager::Listener when finding visible object process starts.
void acquirePrograms()
Acquire the CPU/GPU programs for this pass.
A singleton manager class that manages shader based programs.
SGMaterialMap::const_iterator SGMaterialConstIterator
void validate()
Validate the whole scheme.
SGMaterialMap::iterator SGMaterialIterator
bool addCustomScriptTranslator(const String &key, ScriptTranslator *translator)
Add custom script translator.
VSOutputCompactPolicy getVertexShaderOutputsCompactPolicy() const
Get the vertex shader outputs compaction policy.
virtual void preFindVisibleObjects(SceneManager *source, SceneManager::IlluminationRenderStage irs, Viewport *v)
Listener overridden function notify the shader generator when finding visible objects process started...
SGScheme(const String &schemeName)
size_t getVertexShaderCount() const
Return the current number of generated vertex shaders.
void serializePassAttributes(MaterialSerializer *ser, SGPass *passEntry)
This method called by instance of SGMaterialSerializerListener and serialize a given pass entry attri...
SubRenderStateFactoryMap::iterator SubRenderStateFactoryIterator
String mVertexShaderProfiles
virtual void postFindVisibleObjects(SceneManager *source, SceneManager::IlluminationRenderStage irs, Viewport *v)
Called after searching for visible objects in this SceneManager.
Shader generator pass wrapper class.
SGTechniqueMap mTechniqueEntriesMap
Abstract class defining the interface all renderable objects must implement.
const String & getTargetLanguage() const
Return the target shader language currently in use.
Provides methods to find out where the Ogre config files are stored and where logs and settings files...
This is the target render state.
static String DEFAULT_SCHEME_NAME
Default material scheme of the shader generator.
map< String, SceneManager * >::type SceneManagerMap
SGTechniqueList::const_iterator SGTechniqueConstIterator
SGRenderObjectListener(ShaderGenerator *owner)
vector< SGTechnique * >::type SGTechniqueList
void serializeTextureUnitStateAttributes(MaterialSerializer *ser, SGPass *passEntry, const TextureUnitState *srcTextureUnit)
This method called by instance of SGMaterialSerializerListener and serialize a given textureUnitState...
size_t getNumSubRenderStateFactories() const
Returns the number of existing factories.
Shader generator material wrapper class.
RenderState * mCustomRenderState
VSOutputCompactPolicy mVSOutputCompactPolicy
This abstract node represents a script property.
virtual void shadowTextureReceiverPreViewProj(Light *light, Frustum *frustum)
This event occurs just before the view & projection matrices are set for re-rendering a shadow receiv...
SGMaterialSerializerListener * getMaterialSerializerListener()
Return custom material Serializer of the shader generator.
bool removeAllShaderBasedTechniques(const String &materialName, const String &groupName=ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME)
Remove all shader based techniques of the given material.
Technique * getSourceTechnique()
Get the source technique.
void removeAllShaderBasedTechniques()
Remove all shader based techniques that created by this shader generator.
SubRenderState * createSubRenderState(ScriptCompiler *compiler, PropertyAbstractNode *prop, Pass *pass, SGScriptTranslator *translator)
Create an instance of the SubRenderState based on script properties using the current sub render stat...
RenderState * getRenderState(const String &schemeName, const String &materialName, unsigned short passIndex)
Get render state of specific pass.
vector< RenderState * >::type RenderStateList
size_t getNumTranslators() const
Return number of script translators.
void destroySubRenderState(SubRenderState *subRenderState)
Destroy an instance of sub render state.
size_t getFragmentShaderCount() const
Return the current number of generated fragment shaders.
size_t getRTShaderSchemeCount() const
Returns the amount of schemes used in the for RT shader generation.
void removeTechniqueEntry(SGTechnique *techEntry)
Remove a technique from the current techniques list.
This class responsible for translating core features of the RT Shader System for Ogre material script...
This class responsible for translating core features of the RT Shader System for Ogre material script...
Shader generator system main interface.
SGMaterialMap mMaterialEntriesMap
FFPRenderStateBuilder * mFFPRenderStateBuilder
void createScheme(const String &schemeName)
Create a scheme.
ShaderGenerator()
Class default constructor.
bool hasRenderState(unsigned short passIndex)
Tells if a custom render state exists for the given pass.
void removeSceneManager(SceneManager *sceneMgr)
Remove a scene manager from the shader generator scene managers list.
void addTechniqueEntry(SGTechnique *techEntry)
Add a technique to current techniques list.
map< String, SubRenderStateFactory * >::type SubRenderStateFactoryMap
std::pair< String, String > MatGroupPair
SceneManagerMap::iterator SceneManagerIterator
RenderState * mRenderState
SceneManagerMap::const_iterator SceneManagerConstIterator
void notifyRenderSingleObject(Renderable *rend, const Pass *pass, const AutoParamDataSource *source, const LightList *pLightList, bool suppressRenderStateChanges)
Called from the sub class of the RenderObjectLister when single object is rendered.
void flushShaderCache()
Flush the shader cache.
void _destroy()
Destory the shader generator instance.
Pass * getSrcPass()
Get source pass.
SubRenderStateFactoryMap mSubRenderStateExFactories
bool operator()(const MatGroupPair &p1, const MatGroupPair &p2) const
SceneManager * getActiveSceneManager()
Get the active scene manager that is doint the actual scene rendering.
SGScriptTranslatorManager * mScriptTranslatorManager
Copyright © 2012 Torus Knot Software Ltd

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.