![]() |
RigsofRods
2023.09
Soft-body Physics Simulation
|
Material/Shader manager class. More...
#include <MaterialManager.h>
Data Structures | |
| struct | Options |
| Material options. More... | |
| class | UnderwaterCompositorListener |
| Underwater compositor listener. More... | |
Public Types | |
| enum | MaterialType { MAT_WATER = 0, MAT_DEPTH = 1, MAT_UNDERWATER = 2, MAT_UNDERWATER_COMPOSITOR = 3, MAT_SIMPLE_RED = 4, MAT_SIMPLE_BLACK = 5 } |
| Material type enum. More... | |
| enum | CompositorType { COMP_UNDERWATER = 0 } |
| Compositor type enum. More... | |
| enum | GpuProgram { GPUP_VERTEX = 0, GPUP_FRAGMENT = 1 } |
| Gpu program enum. More... | |
| enum | ShaderMode { SM_HLSL = 0, SM_CG = 1, SM_GLSL = 2 } |
| Shader mode. More... | |
| enum | NormalMode { NM_TEXTURE = 0, NM_VERTEX = 1, NM_RTT = 2 } |
| Normal generation mode. More... | |
Public Member Functions | |
| MaterialManager (Hydrax *h) | |
| Constructor. More... | |
| ~MaterialManager () | |
| Destructor. More... | |
| bool | createMaterials (const HydraxComponent &Components, const Options &Options) |
| Create materials. More... | |
| void | removeMaterials () |
| Remove materials. More... | |
| void | removeCompositor () |
| Remove compositor. More... | |
| void | reload (const MaterialType &Material) |
| Reload material. More... | |
| bool | fillGpuProgramsToPass (Ogre::Pass *Pass, const Ogre::String GpuProgramNames[2], const ShaderMode &SM, const Ogre::String EntryPoints[2], const Ogre::String Data[2]) |
| Fill GPU vertex and fragment program to a pass. More... | |
| bool | createGpuProgram (const Ogre::String &Name, const ShaderMode &SM, const GpuProgram &GPUP, const Ogre::String &EntryPoint, const Ogre::String &Data) |
| Create GPU program. More... | |
| const bool & | isCreated () const |
| Is createMaterials() already called? More... | |
| Ogre::MaterialPtr & | getMaterial (const MaterialType &Material) |
| Get material. More... | |
| Ogre::CompositorPtr & | getCompositor (const CompositorType &Compositor) |
| Get compositor. More... | |
| const bool & | isCompositorEnable (const CompositorType &Compositor) const |
| Is the compositor enable? More... | |
| void | setCompositorEnable (const CompositorType &Compositor, const bool &Enable) |
| Set a compositor enable/disable. More... | |
| const Options & | getLastOptions () const |
| Get the last MaterialManager::Options used in a material generation. More... | |
| void | addDepthTechnique (Ogre::Technique *Technique, const bool &AutoUpdate=true) |
| Add depth technique to an especified material. More... | |
| void | addDepthTextureTechnique (Ogre::Technique *Technique, const Ogre::String &TextureName, const Ogre::String &AlphaChannel="w", const bool &AutoUpdate=true) |
| Add depth texture technique to an especified material. More... | |
| std::vector< Ogre::Technique * > & | getDepthTechniques () |
| Get external depth techniques. More... | |
| void | setGpuProgramParameter (const GpuProgram &GpuP, const MaterialType &MType, const Ogre::String &Name, const Ogre::Real &Value) |
| Set gpu program Ogre::Real parameter. More... | |
| void | setGpuProgramParameter (const GpuProgram &GpuP, const MaterialType &MType, const Ogre::String &Name, const Ogre::Vector2 &Value) |
| Set gpu program Ogre::Vector2 parameter. More... | |
| void | setGpuProgramParameter (const GpuProgram &GpuP, const MaterialType &MType, const Ogre::String &Name, const Ogre::Vector3 &Value) |
| Set gpu program Ogre::Vector3 parameter. More... | |
| void | updateAnimatedTextures (float dt) |
| Animated textures must be updated manually to account for variable simulation time. More... | |
Private Member Functions | |
| bool | _isComponent (const HydraxComponent &List, const HydraxComponent &ToCheck) const |
| Is component in the given list? More... | |
| bool | _createWaterMaterial (const HydraxComponent &Components, const Options &Options) |
| Create water material. More... | |
| bool | _createDepthMaterial (const HydraxComponent &Components, const Options &Options) |
| Create depth material. More... | |
| bool | _createDepthTextureGPUPrograms (const HydraxComponent &Components, const Options &Options, const Ogre::String &AlphaChannel) |
| Create depth texture gpu programs. More... | |
| bool | _createUnderwaterMaterial (const HydraxComponent &Components, const Options &Options) |
| Create underwater material. More... | |
| bool | _createUnderwaterCompositor (const HydraxComponent &Components, const Options &Options) |
| Create underwater compositor. More... | |
| bool | _createSimpleColorMaterial (const Ogre::ColourValue &MaterialColor, const MaterialType &MT, const Ogre::String &MaterialName, const bool &DepthCheck=true, const bool &DepthWrite=true) |
Private Attributes | |
| bool | mCreated |
| Is createMaterials() already called? More... | |
| Ogre::MaterialPtr | mMaterials [6] |
| Hydrax materials vector. More... | |
| Ogre::CompositorPtr | mCompositors [1] |
| Hydrax compositors vector. More... | |
| bool | mCompositorsNeedToBeReloaded [1] |
| Hydrax compositors boolean: Need to be reloaded? More... | |
| bool | mCompositorsEnable [1] |
| Hydrax compostor enable vector. More... | |
| std::vector< Ogre::Technique * > | mDepthTechniques |
| Technique vector for addDepthTechnique(...) More... | |
| HydraxComponent | mComponents |
| Actual material components. More... | |
| Options | mOptions |
| Actual material options. More... | |
| UnderwaterCompositorListener | mUnderwaterCompositorListener |
| Underwater compositor listener. More... | |
| Hydrax * | mHydrax |
| Hydrax main pointer. More... | |
| std::vector< Ogre::TextureUnitState * > | mCausticsAnimTexVec |
| Caustics animated texture, for manual updating. More... | |
| unsigned int | mCausticsAnimCurrentFrame = 0 |
| float | mCausticsAnimCurrentFrameElapsedTime = 0.f |
| Time spent on current animation frame, cumulative. More... | |
Material/Shader manager class.
Definition at line 44 of file MaterialManager.h.
Compositor type enum.
| Enumerator | |
|---|---|
| COMP_UNDERWATER | |
Definition at line 69 of file MaterialManager.h.
Gpu program enum.
| Enumerator | |
|---|---|
| GPUP_VERTEX | |
| GPUP_FRAGMENT | |
Definition at line 78 of file MaterialManager.h.
Material type enum.
| Enumerator | |
|---|---|
| MAT_WATER | |
| MAT_DEPTH | |
| MAT_UNDERWATER | |
| MAT_UNDERWATER_COMPOSITOR | |
| MAT_SIMPLE_RED | |
| MAT_SIMPLE_BLACK | |
Definition at line 50 of file MaterialManager.h.
Normal generation mode.
| Enumerator | |
|---|---|
| NM_TEXTURE | |
| NM_VERTEX | |
| NM_RTT | |
Definition at line 100 of file MaterialManager.h.
| Hydrax::MaterialManager::MaterialManager | ( | Hydrax * | h | ) |
| Hydrax::MaterialManager::~MaterialManager | ( | ) |
Destructor.
Definition at line 81 of file MaterialManager.cpp.
|
private |
Create depth material.
| Components | Components of the shader |
| Options | Material options |
Definition at line 1202 of file MaterialManager.cpp.
|
private |
Create depth texture gpu programs.
| Components | Components of the sahder |
| Options | Material options |
| AlphaChannel | "x","y","z","w" or "r","g","b","a" (Channel where alpha information is stored) |
Definition at line 1569 of file MaterialManager.cpp.
|
private |
Definition at line 3150 of file MaterialManager.cpp.
|
private |
Create underwater compositor.
| Components | Components of the shader |
| Options | Material options |
Definition at line 2767 of file MaterialManager.cpp.
|
private |
Create underwater material.
| Components | Components of the shader |
| Options | Material options |
Definition at line 1808 of file MaterialManager.cpp.
|
private |
Create water material.
| Components | Components of the shader |
| Options | Material options |
Definition at line 349 of file MaterialManager.cpp.
|
private |
Is component in the given list?
| List | Components list |
| ToCheck | Component to check |
Definition at line 3538 of file MaterialManager.cpp.
| void Hydrax::MaterialManager::addDepthTechnique | ( | Ogre::Technique * | Technique, |
| const bool & | AutoUpdate = true |
||
| ) |
Add depth technique to an especified material.
| Technique | Technique where depth technique will be added |
| AutoUpdate | The technique will be automatically updated when water parameters change |
The technique will be automatically updated when water parameters change if parameter AutoUpdate == true
Add depth technique when a material is not an Ogre::Entity, such terrains, PLSM2 materials, etc.
This depth technique will be added with "HydraxDepth" scheme in ordeto can use it in the Depth RTT.
Definition at line 3398 of file MaterialManager.cpp.
| void Hydrax::MaterialManager::addDepthTextureTechnique | ( | Ogre::Technique * | Technique, |
| const Ogre::String & | TextureName, | ||
| const Ogre::String & | AlphaChannel = "w", |
||
| const bool & | AutoUpdate = true |
||
| ) |
Add depth texture technique to an especified material.
| Technique | Technique where depth technique will be added |
| TextureName | Texture name |
| AlphaChannel | "x","y","z","w" or "r","g","b","a" (Channel where alpha information is stored) |
| AutoUpdate | The technique will be automatically updated when water parameters change |
The technique will be automatically updated when water parameters change if parameter AutoUpdate == true
Add depth technique when a material is not an Ogre::Entity, such terrains, PLSM2 materials, etc.
This depth technique will be added with "HydraxDepth" scheme in ordeto can use it in the Depth RTT.
Definition at line 3453 of file MaterialManager.cpp.
| bool Hydrax::MaterialManager::createGpuProgram | ( | const Ogre::String & | Name, |
| const ShaderMode & | SM, | ||
| const GpuProgram & | GPUP, | ||
| const Ogre::String & | EntryPoint, | ||
| const Ogre::String & | Data | ||
| ) |
Create GPU program.
| Name | HighLevelGpuProgram name |
| SM | Shader mode |
| GPUP | GpuProgram type |
| EntryPoint | Entry point |
| Data |
Definition at line 261 of file MaterialManager.cpp.
| bool Hydrax::MaterialManager::createMaterials | ( | const HydraxComponent & | Components, |
| const Options & | Options | ||
| ) |
Create materials.
| Components | Components of the shader |
| Options | Material options |
Definition at line 163 of file MaterialManager.cpp.
| bool Hydrax::MaterialManager::fillGpuProgramsToPass | ( | Ogre::Pass * | Pass, |
| const Ogre::String | GpuProgramNames[2], | ||
| const ShaderMode & | SM, | ||
| const Ogre::String | EntryPoints[2], | ||
| const Ogre::String | Data[2] | ||
| ) |
Fill GPU vertex and fragment program to a pass.
| Pass | Pass to fill Gpu programs |
| GpuProgramNames | [0]: Vertex program name, [1]: Fragment program name |
| SM | Shader mode, note: Provided data strings will correspong with selected shader mode |
| EntryPoints | [0]: Vertex program entry point, [1]: Fragment program entry point |
| Data | [0] Vertex program data, [1]: Fragment program data |
Definition at line 239 of file MaterialManager.cpp.
|
inline |
Get compositor.
| Compositor | to get |
Definition at line 230 of file MaterialManager.h.
|
inline |
Get external depth techniques.
Definition at line 285 of file MaterialManager.h.
|
inline |
Get the last MaterialManager::Options used in a material generation.
Definition at line 253 of file MaterialManager.h.
|
inline |
Get material.
| Material | Material to get |
Definition at line 221 of file MaterialManager.h.
|
inline |
Is the compositor enable?
| Compositor | compositor to check |
Definition at line 239 of file MaterialManager.h.
|
inline |
Is createMaterials() already called?
Definition at line 212 of file MaterialManager.h.
| void Hydrax::MaterialManager::reload | ( | const MaterialType & | Material | ) |
Reload material.
| Material | Material to reload |
Definition at line 3170 of file MaterialManager.cpp.
| void Hydrax::MaterialManager::removeCompositor | ( | ) |
Remove compositor.
Definition at line 147 of file MaterialManager.cpp.
| void Hydrax::MaterialManager::removeMaterials | ( | ) |
Remove materials.
Definition at line 86 of file MaterialManager.cpp.
| void Hydrax::MaterialManager::setCompositorEnable | ( | const CompositorType & | Compositor, |
| const bool & | Enable | ||
| ) |
Set a compositor enable/disable.
| Compositor | compositor to change |
| Enable | true to enable, false to disable |
Definition at line 3523 of file MaterialManager.cpp.
| void Hydrax::MaterialManager::setGpuProgramParameter | ( | const GpuProgram & | GpuP, |
| const MaterialType & | MType, | ||
| const Ogre::String & | Name, | ||
| const Ogre::Real & | Value | ||
| ) |
Set gpu program Ogre::Real parameter.
| GpuP | Gpu program type (Vertex/Fragment) |
| MType | Water/Depth material |
| Name | param name |
| Value | value |
Definition at line 3558 of file MaterialManager.cpp.
| void Hydrax::MaterialManager::setGpuProgramParameter | ( | const GpuProgram & | GpuP, |
| const MaterialType & | MType, | ||
| const Ogre::String & | Name, | ||
| const Ogre::Vector2 & | Value | ||
| ) |
Set gpu program Ogre::Vector2 parameter.
| GpuP | Gpu program type (Vertex/Fragment) |
| MType | Water/Depth material |
| Name | param name |
| Value | value |
Definition at line 3616 of file MaterialManager.cpp.
| void Hydrax::MaterialManager::setGpuProgramParameter | ( | const GpuProgram & | GpuP, |
| const MaterialType & | MType, | ||
| const Ogre::String & | Name, | ||
| const Ogre::Vector3 & | Value | ||
| ) |
Set gpu program Ogre::Vector3 parameter.
| GpuP | Gpu program type (Vertex/Fragment) |
| MType | Water/Depth material |
| Name | param name |
| Value | value |
Definition at line 3674 of file MaterialManager.cpp.
| void Hydrax::MaterialManager::updateAnimatedTextures | ( | float | dt | ) |
Animated textures must be updated manually to account for variable simulation time.
Definition at line 1547 of file MaterialManager.cpp.
|
private |
Definition at line 382 of file MaterialManager.h.
|
private |
Time spent on current animation frame, cumulative.
Definition at line 384 of file MaterialManager.h.
|
private |
Caustics animated texture, for manual updating.
Definition at line 381 of file MaterialManager.h.
|
private |
Actual material components.
Definition at line 373 of file MaterialManager.h.
|
private |
Hydrax compositors vector.
Definition at line 365 of file MaterialManager.h.
|
private |
Hydrax compostor enable vector.
Definition at line 369 of file MaterialManager.h.
|
private |
Hydrax compositors boolean: Need to be reloaded?
Definition at line 367 of file MaterialManager.h.
|
private |
Is createMaterials() already called?
Definition at line 361 of file MaterialManager.h.
|
private |
Technique vector for addDepthTechnique(...)
Definition at line 371 of file MaterialManager.h.
|
private |
Hydrax main pointer.
Definition at line 379 of file MaterialManager.h.
|
private |
Hydrax materials vector.
Definition at line 363 of file MaterialManager.h.
|
private |
Actual material options.
Definition at line 375 of file MaterialManager.h.
|
private |
Underwater compositor listener.
Definition at line 377 of file MaterialManager.h.
1.8.17