8#include <boost/format.hpp>
9#include <boost/algorithm/string.hpp>
27SPass::SPass(
STechnique* technique, Ogre::Pass* ogrePassRef) :
SData(ogrePassRef->getName())
34 Ogre::ResourceGroupManager& resGrpMgr = Ogre::ResourceGroupManager::getSingleton();
37 const std::vector<Ogre::TextureUnitState*> texunits =
ogrePass->getTextureUnitStates();
38 for(
unsigned int t = 0; t < texunits.size(); t++)
40 Ogre::TextureUnitState* pTex = texunits[t];
41 Ogre::String tex_name = pTex->getTextureName();
43 if (!tex_name.empty())
47 Ogre::String res_group = resGrpMgr.findGroupContainingResource(tex_name);
48 Ogre::FileInfoListPtr file_list = resGrpMgr.findResourceFileInfo(res_group, tex_name);
49 Ogre::VectorIterator<Ogre::FileInfoList> file_list_itr(*file_list);
50 if (!file_list_itr.hasMoreElements())
52 Ogre::LogManager::getSingleton().getDefaultLog()->logMessage(
"[WARNING] Could not find the texture file : " + tex_name);
56 catch (Ogre::Exception &)
58 Ogre::LogManager::getSingleton().getDefaultLog()->logMessage(
"[WARNING] Could not find the texture file : " + tex_name);
74SPass::SPass() :
SData(
"")
81 Ogre::Any bindedSPass =
ogrePass->getUserObjectBindings().getUserAny(
"SPass");
82 if(bindedSPass.has_value())
83 ogrePass->getUserObjectBindings().eraseUserAny(
"SPass");
90 Ogre::String tex_name = unit->getName();
92 Ogre::StringUtil::toLowerCase(tex_name);
93 if ((tex_name.find(
"ambient") != Ogre::String::npos) ||
94 (tex_name.find(
"lightmap") != Ogre::String::npos) ||
95 (tex_name.find(
"occlusion") != Ogre::String::npos) ||
96 (tex_name.find(
"diffuse") != Ogre::String::npos) ||
97 (tex_name.find(
"bump") != Ogre::String::npos) ||
98 (tex_name.find(
"normal") != Ogre::String::npos) ||
99 (tex_name.find(
"emissive") != Ogre::String::npos) ||
100 (tex_name.find(
"opacity") != Ogre::String::npos) ||
101 (tex_name.find(
"reflection_mask") != Ogre::String::npos) ||
102 (tex_name.find(
"reflection") != Ogre::String::npos) ||
103 (tex_name.find(
"shininess") != Ogre::String::npos) ||
104 (tex_name.find(
"specular") != Ogre::String::npos) ||
105 (tex_name.find(
"opacity") != Ogre::String::npos) ||
106 (tex_name.find(
"roughness") != Ogre::String::npos))
110 tex_name = unit->getTextureName();
111 Ogre::StringUtil::toLowerCase(tex_name);
119 Ogre::TextureUnitState::EffectMap effects = unit->getEffects();
120 Ogre::TextureUnitState::EffectMap::const_iterator effectEnd = effects.end();
122 if (!effects.empty() && (effects.find(Ogre::TextureUnitState::ET_ENVIRONMENT_MAP) != effectEnd))
127 if (!envMap && ((tex_name.find(
"ambient") != Ogre::String::npos) || (tex_name.find(
"lightmap") != Ogre::String::npos) || (tex_name.find(
"occlusion") != Ogre::String::npos) || (tex_name.find(
"_occ") != Ogre::String::npos)))
129 else if (!envMap && ((tex_name.find(
"diffuse") != Ogre::String::npos) || (tex_name.find(
"albedo") != Ogre::String::npos) || (tex_name.find(
"color") != Ogre::String::npos) || (tex_name.find(
"colour") != Ogre::String::npos)))
131 else if ((tex_name.find(
"normal") != Ogre::String::npos) || (tex_name.find(
"nrm") != Ogre::String::npos) || (tex_name.find(
"norm") != Ogre::String::npos) || (tex_name.find(
"_nm") != Ogre::String::npos) || (tex_name.find(
"_nmap") != Ogre::String::npos) || (tex_name.find(
"_ddn") != Ogre::String::npos))
133 else if ((tex_name.find(
"emissive") != Ogre::String::npos) || (tex_name.find(
"illum") != Ogre::String::npos))
135 else if ((tex_name.find(
"reflection_mask") != Ogre::String::npos) || (tex_name.find(
"refmask") != Ogre::String::npos))
137 else if (envMap || (tex_name.find(
"reflection") != Ogre::String::npos) || (tex_name.find(
"reflect") != Ogre::String::npos))
139 else if (tex_name.find(
"opacity") != Ogre::String::npos)
141 else if ((tex_name.find(
"specular") != Ogre::String::npos) || (tex_name.find(
"spec") != Ogre::String::npos))
143 else if (tex_name.find(
"shininess") != Ogre::String::npos)
145 else if ((tex_name.find(
"metallic") != Ogre::String::npos) || (tex_name.find(
"metalness") != Ogre::String::npos) || (tex_name.find(
"roughness") != Ogre::String::npos) || (tex_name.find(
"metallicroughness") != Ogre::String::npos) || (tex_name.find(
"_orm") != Ogre::String::npos))
171 bool isSupported = tech->isSupported() &&
ogrePass->hasVertexProgram() &&
ogrePass->hasFragmentProgram();
174 Ogre::StringStream errors;
175 isSupported = tech->checkGPURules(errors) && tech->checkHardwareSupport(
true, errors) &&
ogrePass->hasVertexProgram() &&
ogrePass->hasFragmentProgram();
203 if (rendererName ==
"OpenGL ES 2.x Rendering Subsystem" || rendererName ==
"Metal Rendering Subsystem")
217 else if (rendererName ==
"Direct3D9 Rendering Subsystem" || rendererName ==
"Direct3D11 Rendering Subsystem" || rendererName ==
"OpenGL Rendering Subsystem" || rendererName ==
"Vulkan Rendering Subsystem")
243 catch (Ogre::Exception& e)
248 Ogre::LogManager::getSingleton().getDefaultLog()->logMessage(
"[ERROR] Could not compute shader : " + e.getFullDescription());
254 isSupported = tech->isSupported();
257 Ogre::StringStream errors;
258 isSupported = tech->checkGPURules(errors) && tech->checkHardwareSupport(
true, errors);
284 return ogrePass->getNumTextureUnitStates();
289 std::string returnValue(
"");
290 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
291 if (tmpTextureUnit != 0)
293 returnValue = tmpTextureUnit->getName();
294 if(returnValue.empty())
295 returnValue = boost::str(boost::format(
"%1%") %textureUnit);
302 return ogrePass->getTextureUnitStateIndex(
ogrePass->getTextureUnitState(texname));
308 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
309 if (tmpTextureUnit != 0)
310 texname = tmpTextureUnit->getTextureName();
317 std::string texFile =
"";
318 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
319 if (tmpTextureUnit != 0)
321 Ogre::ResourceGroupManager& resGrpMgr = Ogre::ResourceGroupManager::getSingleton();
322 Ogre::String tex_name = tmpTextureUnit->getTextureName();
323 Ogre::String res_group = resGrpMgr.findGroupContainingResource(tex_name);
324 Ogre::FileInfoListPtr file_list = resGrpMgr.findResourceFileInfo(res_group, tex_name);
325 Ogre::VectorIterator<Ogre::FileInfoList> file_list_itr(*file_list);
326 if (file_list_itr.hasMoreElements())
328 Ogre::FileInfo file_info = file_list_itr.getNext();
329 texFile = file_info.filename;
337 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
338 if(tmpTextureUnit != 0)
339 tmpTextureUnit->setTextureUScroll(Ogre::Real(value));
341 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS,
"Texture unit not found on material.",
"SMaterial::SetTextureUScroll");
348 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
349 if(tmpTextureUnit != 0)
350 return static_cast <float> (tmpTextureUnit->getTextureUScroll());
352 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS,
"Texture unit not found on material.",
"SMaterial::GetTextureUScroll");
359 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
360 if(tmpTextureUnit != 0)
361 tmpTextureUnit->setTextureVScroll(Ogre::Real(value));
363 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS,
"Texture unit not found on material.",
"SMaterial::SetTextureVScroll");
370 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
371 if(tmpTextureUnit != 0)
372 return static_cast <float> (tmpTextureUnit->getTextureVScroll());
374 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS,
"Texture unit not found on material.",
"SMaterial::GetTextureVScroll");
381 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
382 if(tmpTextureUnit != 0)
383 tmpTextureUnit->setTextureUScale(Ogre::Real(value));
385 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS,
"Texture unit not found on material.",
"SMaterial::SetTextureUScale");
392 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
393 if(tmpTextureUnit != 0)
394 return static_cast <float> (tmpTextureUnit->getTextureUScale());
396 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS,
"Texture unit not found on material.",
"SMaterial::GetTextureUScale");
403 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
404 if(tmpTextureUnit != 0)
405 tmpTextureUnit->setTextureVScale(Ogre::Real(value));
407 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS,
"Texture unit not found on material.",
"SMaterial::SetTextureVScale");
414 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
415 if(tmpTextureUnit != 0)
416 return static_cast <float> (tmpTextureUnit->getTextureVScale());
418 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS,
"Texture unit not found on material.",
"SMaterial::GetTextureVScale");
425 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
426 if(tmpTextureUnit != 0)
427 tmpTextureUnit->setTextureRotate(Ogre::Radian(radianAngle));
429 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS,
"Texture unit not found on material.",
"SMaterial::SetTextureRotate");
436 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
437 if(tmpTextureUnit != 0)
438 return static_cast <float> (tmpTextureUnit->getTextureRotate().valueRadians());
440 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS,
"Texture unit not found on material.",
"SMaterial::GetTextureRotate");
447 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
448 if (tmpTextureUnit != 0)
449 tmpTextureUnit->setScrollAnimation(Ogre::Real(uSpeed), Ogre::Real(vSpeed));
451 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS,
"Texture unit not found on material.",
"SMaterial::SetScrollAnimation");
458 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
459 if(tmpTextureUnit != 0)
460 tmpTextureUnit->setRotateAnimation(Ogre::Real(speed));
462 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS,
"Texture unit not found on material.",
"SMaterial::SetRotateAnimation");
469 return ogrePass->getLightingEnabled();
474 ogrePass->setLightingEnabled(state);
545 ogrePass->setSelfIllumination(color);
573 ogrePass->setVertexColourTracking(Ogre::TVC_AMBIENT | Ogre::TVC_DIFFUSE);
575 ogrePass->setVertexColourTracking(Ogre::TVC_NONE);
582 return (
bool)((
ogrePass->getVertexColourTracking() & Ogre::TVC_AMBIENT) || (
ogrePass->getVertexColourTracking() == Ogre::TVC_DIFFUSE));
587 bool unitsUpdated =
false;
588 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
592 if (tmpTextureUnit != 0)
597 tmpTextureUnit->setBlank();
602 tmpTextureUnit->setName(
name);
603 tmpTextureUnit->retryTextureLoad();
607 if (textureUnit == (
ogrePass->getNumTextureUnitStates() - 1))
609 ogrePass->removeTextureUnitState(textureUnit);
614 else if (texture != 0)
616 while (
ogrePass->getNumTextureUnitStates() < (textureUnit + 1))
618 tmpTextureUnit =
ogrePass->createTextureUnitState();
623 tmpTextureUnit->setName(
name);
626 tmpTextureUnit->setBlank();
629 tmpTextureUnit->retryTextureLoad();
632 catch (Ogre::Exception &)
634 Ogre::LogManager::getSingleton().getDefaultLog()->logMessage(
"[WARNING] Could not apply the texture file");
635 if (tmpTextureUnit != 0)
636 tmpTextureUnit->setBlank();
648 std::string texfile = texname;
663 Ogre::TextureUnitState* foundTex = 0;
666 Ogre::Pass::TextureUnitStates units =
ogrePass->getTextureUnitStates();
667 for (
unsigned int i = 0; i < units.size() && !foundTex; i++)
669 Ogre::TextureUnitState* pTex = units[i];
672 Ogre::TextureUnitState::EffectMap effects = pTex->getEffects();
673 Ogre::TextureUnitState::EffectMap::const_iterator effectEnd = effects.end();
675 if (!effects.empty() && (effects.find(Ogre::TextureUnitState::ET_ENVIRONMENT_MAP) != effectEnd))
680 if (!envMap && ((tex_name.find(
"ambient") != Ogre::String::npos) || (tex_name.find(
"lightmap") != Ogre::String::npos) || (tex_name.find(
"occlusion") != Ogre::String::npos) || (tex_name.find(
"_occ") != Ogre::String::npos)))
682 else if ((tex_name.find(
"normal") != Ogre::String::npos) || (tex_name.find(
"nrm") != Ogre::String::npos) || (tex_name.find(
"norm") != Ogre::String::npos) || (tex_name.find(
"_nm") != Ogre::String::npos) || (tex_name.find(
"_nmap") != Ogre::String::npos))
684 else if ((tex_name.find(
"emissive") != Ogre::String::npos) || (tex_name.find(
"illum") != Ogre::String::npos))
686 else if ((tex_name.find(
"reflection_mask") != Ogre::String::npos) || (tex_name.find(
"refmask") != Ogre::String::npos))
688 else if (envMap || (tex_name.find(
"reflection") != Ogre::String::npos) || (tex_name.find(
"reflect") != Ogre::String::npos))
690 else if (tex_name.find(
"opacity") != Ogre::String::npos)
692 else if ((tex_name.find(
"specular") != Ogre::String::npos) || (tex_name.find(
"spec") != Ogre::String::npos))
694 else if (tex_name.find(
"shininess") != Ogre::String::npos)
696 else if ((tex_name.find(
"metallic") != Ogre::String::npos) || (tex_name.find(
"metalness") != Ogre::String::npos) || (tex_name.find(
"roughness") != Ogre::String::npos) || (tex_name.find(
"metallicroughness") != Ogre::String::npos) || (tex_name.find(
"_orm") != Ogre::String::npos))
713Ogre::TextureUnitState* SPass::GetTextureUnitState(
const unsigned int& textureUnit)
716 Ogre::TextureUnitState* returnValue = 0;
719 size_t numTextureUnits =
ogrePass->getNumTextureUnitStates();
720 if ((numTextureUnits > 0) && (textureUnit < numTextureUnits))
721 returnValue =
ogrePass->getTextureUnitState(textureUnit);
728 Ogre::GpuNamedConstants paramList;
732 Ogre::GpuProgramParametersSharedPtr vertexProgramParameters =
ogrePass->getVertexProgramParameters();
733 paramList = vertexProgramParameters->getConstantDefinitions();
736 Ogre::GpuConstantDefinitionMap::iterator it = paramList.map.begin();
737 while(it != paramList.map.end())
739 if(boost::algorithm::ends_with(it->first,
"[0]"))
742 it = paramList.map.erase(it);
755 Ogre::GpuProgramParametersSharedPtr vertexProgramParameters =
ogrePass->getVertexProgramParameters();
756 if(vertexProgramParameters->_findNamedConstantDefinition(paramName))
757 vertexProgramParameters->setNamedAutoConstant(paramName, paramType, paramExtraInfos);
765 Ogre::GpuProgramParametersSharedPtr vertexProgramParameters =
ogrePass->getVertexProgramParameters();
766 const Ogre::GpuConstantDefinition* constantDefinition = vertexProgramParameters->_findNamedConstantDefinition(paramName);
767 if(constantDefinition != 0)
770 switch(constantDefinition->constType)
773 if(Ogre::StringConverter::isNumber(value))
774 vertexProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseInt(value));
780 vertexProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseVector3(value));
783 vertexProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseVector4(value));
785 case Ogre::GCT_FLOAT1:
786 if(Ogre::StringConverter::isNumber(value))
787 vertexProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseReal(value));
792 case Ogre::GCT_FLOAT3:
793 vertexProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseVector3(value));
795 case Ogre::GCT_FLOAT4:
796 vertexProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseVector4(value));
798 case Ogre::GCT_MATRIX_4X4:
799 vertexProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseMatrix4(value));
808 Ogre::GpuNamedConstants paramList;
812 Ogre::GpuProgramParametersSharedPtr fragmentProgramParameters =
ogrePass->getFragmentProgramParameters();
813 paramList = fragmentProgramParameters->getConstantDefinitions();
816 Ogre::GpuConstantDefinitionMap::iterator it = paramList.map.begin();
817 while(it != paramList.map.end())
819 if(boost::algorithm::ends_with(it->first,
"[0]"))
822 it = paramList.map.erase(it);
835 Ogre::GpuProgramParametersSharedPtr fragmentProgramParameters =
ogrePass->getFragmentProgramParameters();
836 if(fragmentProgramParameters->_findNamedConstantDefinition(paramName))
837 fragmentProgramParameters->setNamedAutoConstant(paramName, paramType, paramExtraInfos);
845 Ogre::GpuProgramParametersSharedPtr fragmentProgramParameters =
ogrePass->getFragmentProgramParameters();
846 const Ogre::GpuConstantDefinition* constantDefinition = fragmentProgramParameters->_findNamedConstantDefinition(paramName);
847 if(constantDefinition != 0)
850 switch(constantDefinition->constType)
853 if(Ogre::StringConverter::isNumber(value))
854 fragmentProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseInt(value));
860 fragmentProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseVector3(value));
863 fragmentProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseVector4(value));
865 case Ogre::GCT_FLOAT1:
866 if(Ogre::StringConverter::isNumber(value))
867 fragmentProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseReal(value));
872 case Ogre::GCT_FLOAT3:
873 fragmentProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseVector3(value));
875 case Ogre::GCT_FLOAT4:
876 fragmentProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseVector4(value));
878 case Ogre::GCT_MATRIX_4X4:
879 fragmentProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseMatrix4(value));
908 ogrePass->setSceneBlending(
static_cast<Ogre::SceneBlendFactor
>(
static_cast<int>(sourceFactor)),
909 static_cast<Ogre::SceneBlendFactor
>(
static_cast<int>(destFactor)));
916 ogrePass->setSeparateSceneBlending(
static_cast<Ogre::SceneBlendFactor
>(
static_cast<int>(sourceFactor)),
917 static_cast<Ogre::SceneBlendFactor
>(
static_cast<int>(destFactor)),
918 static_cast<Ogre::SceneBlendFactor
>(
static_cast<int>(sourceFactorAlpha)),
919 static_cast<Ogre::SceneBlendFactor
>(
static_cast<int>(destFactorAlpha)));
936 ogrePass->setSeparateSceneBlendingOperation(
static_cast<Ogre::SceneBlendOperation
>(
static_cast<int>(op)),
937 static_cast<Ogre::SceneBlendOperation
>(
static_cast<int>(alphaOp)));
944 ogrePass->setDepthCheckEnabled(enabled);
951 return ogrePass->getDepthCheckEnabled();
956 ogrePass->setDepthWriteEnabled(enabled);
957 ogrePass->getParent()->getParent()->setTransparencyCastsShadows(!enabled);
964 return ogrePass->getDepthWriteEnabled();
969 ogrePass->setDepthFunction(
static_cast<Ogre::CompareFunction
>(
static_cast<int>(func)));
981 ogrePass->setAlphaRejectSettings(
static_cast<Ogre::CompareFunction
>(
static_cast<int>(func)), value, alphaToCoverageEnabled);
993 return ogrePass->getAlphaRejectValue();
998 return ogrePass->isAlphaToCoverageEnabled();
1003 ogrePass->setColourWriteEnabled(state);
1010 return ogrePass->getColourWriteEnabled();
1015 Ogre::CullingMode mode = (state) ? Ogre::CULL_CLOCKWISE : Ogre::CULL_NONE;
1018 ogrePass->getParent()->getParent()->setTransparencyCastsShadows(!state && !
ogrePass->getDepthWriteEnabled());
1025 if (
ogrePass->getCullingMode() == Ogre::CULL_NONE)
1035 if (
ogrePass->getPolygonMode() == Ogre::PM_POINTS)
1050 if (
ogrePass->getPolygonMode() == Ogre::PM_POINTS)
1058 ogrePass->setPolygonMode(
static_cast<Ogre::PolygonMode
>(mode));
1060 if (
ogrePass->getPolygonMode() == Ogre::PM_POINTS)
1072 ogrePass->setPolygonModeOverrideable(
false);
1074 ogrePass->setPolygonModeOverrideable(
true);
1086 if (textureUnit < ogrePass->getNumTextureUnitStates())
1088 Ogre::TextureUnitState* pTex =
ogrePass->getTextureUnitState(textureUnit);
1092 pTex->setColourOperationEx(Ogre::LBX_BLEND_MANUAL, Ogre::LBS_TEXTURE, Ogre::LBS_CURRENT, Ogre::ColourValue::Black, Ogre::ColourValue::White, factor);
1113 if (textureUnit < ogrePass->getNumTextureUnitStates())
1114 return ogrePass->getTextureUnitState(textureUnit)->getColourBlendMode().factor;
1121 if (textureUnit < ogrePass->getNumTextureUnitStates())
1123 ogrePass->removeTextureUnitState(textureUnit);
1132 const Ogre::Pass::TextureUnitStates& texunits =
ogrePass->getTextureUnitStates();
1134 if (texunits.size() <= 1)
1139 Ogre::TextureUnitState amb(
ogrePass, *texunits[0]);
1140 Ogre::TextureUnitState diff(
ogrePass, *texunits[0]);
1141 Ogre::TextureUnitState ref(
ogrePass, *texunits[0]);
1142 Ogre::TextureUnitState ill(
ogrePass, *texunits[0]);
1143 Ogre::TextureUnitState norm(
ogrePass, *texunits[0]);
1144 Ogre::TextureUnitState roughn(
ogrePass, *texunits[0]);
1145 Ogre::TextureUnitState opacity(
ogrePass, *texunits[0]);
1147 std::vector<Ogre::TextureUnitState> otherUnits;
1149 for (
unsigned int t = 0; t < texunits.size(); t++)
1151 Ogre::TextureUnitState* pTex = texunits[t];
1185 otherUnits.push_back(Ogre::TextureUnitState(
ogrePass, *pTex));
1192 ogrePass->removeAllTextureUnitStates();
1194 Ogre::TextureUnitState* newUnit = 0;
1197 newUnit =
ogrePass->createTextureUnitState();
1198 *newUnit = Ogre::TextureUnitState(amb);
1203 newUnit =
ogrePass->createTextureUnitState();
1204 *newUnit = Ogre::TextureUnitState(diff);
1209 newUnit =
ogrePass->createTextureUnitState();
1210 *newUnit = Ogre::TextureUnitState(norm);
1213 for (
auto u : otherUnits)
1215 newUnit =
ogrePass->createTextureUnitState();
1216 *newUnit = Ogre::TextureUnitState(u);
1221 newUnit =
ogrePass->createTextureUnitState();
1222 *newUnit = Ogre::TextureUnitState(ref);
1227 newUnit =
ogrePass->createTextureUnitState();
1228 *newUnit = Ogre::TextureUnitState(ill);
1233 newUnit =
ogrePass->createTextureUnitState();
1234 *newUnit = Ogre::TextureUnitState(roughn);
1239 newUnit =
ogrePass->createTextureUnitState();
1240 *newUnit = Ogre::TextureUnitState(opacity);
1247 Ogre::TextureUnitState* tunit = 0;
1249 bool newUnit =
false;
1252 tunit =
ogrePass->getTextureUnitState(tindex);
1256 tunit =
ogrePass->createTextureUnitState();
1269 tunit->setEnvironmentMap(
true, Ogre::TextureUnitState::ENV_REFLECTION);
1271 tunit->setEnvironmentMap(
true, Ogre::TextureUnitState::ENV_CURVED);
1282 std::string
name =
"";
1304 name =
"reflection_mask";
1307 name =
"reflection";
MMechostr(MSKDEBUG, " > Start loading Plugin SO3Engine dll\n")
std::string GetName() const
static void CleanUpGeneratedTechniques(Ogre::Material *mat)
Ogre::MaterialPtr getOgreMaterialPointer()
std::string GetGroupName()
bool GetIgnoreSlicePlane()
bool GetDepthCheckEnabled() const
void SetTextureRotateAnimation(const unsigned int &textureUnit, const float &speed)
void SetPolygonMode(PolygonMode mode)
void SetDepthFunction(CompareFunction func)
void SetVertexProgramParameter(const std::string ¶mName, const std::string &value)
void SetTextureRotate(const unsigned int &textureUnit, const float &radianAngle)
void SetTextureScrollAnimation(const unsigned int &textureUnit, const float &uSpeed, const float &vSpeed)
void RemoveTexture(const unsigned int &textureUnit)
std::string GetTextureUnitNameByType(SShaderGenerator::ShaderMapType type)
bool GetDepthWriteEnabled() const
void SetDepthCheckEnabled(bool enabled)
void SetPointSize(Ogre::Real size)
void SetTextureUnitColorBlendModeFactor(const unsigned int &textureUnit, float factor)
void SetSelfIlluminationColor(const int &color)
void SetShininess(const float &value)
void BuildShader(bool force=false)
void SetAmbientColor(const int &color)
void SetTextureVScroll(const unsigned int &textureUnit, const float &value)
std::string GetTextureName(const unsigned int &textureUnit)
const float GetTextureRotate(const unsigned int &textureUnit)
void SetColourWriteEnabled(bool state)
bool GetCullingMode() const
void SetVertexProgramAutoParameter(const std::string ¶mName, const Ogre::GpuProgramParameters::AutoConstantType ¶mType, const size_t ¶mExtraInfos)
float GetTextureUnitColorBlendModeFactor(const unsigned int &textureUnit)
void SetSceneBlendingOperation(SceneBlendOperation op, SceneBlendOperation alphaOp)
STexture * GetTexture(const unsigned int &textureUnit)
void SetSpecularColor(const int &color)
int GetTextureUnitIndexByName(const std::string &texname)
void SetAlphaRejection(CompareFunction func, unsigned char value, bool alphaToCoverageEnabled=false)
SceneBlendFactor GetSourceBlendFactor() const
static std::string GetTextureUnitTypedName(Ogre::TextureUnitState *unit)
void SetLightingEnabled(const bool &state)
CompareFunction GetDepthFunction() const
void SetTextureUScroll(const unsigned int &textureUnit, const float &value)
void SetSceneBlending(const SPass::SceneBlendFactor sourceFactor, const SPass::SceneBlendFactor destFactor)
PolygonMode GetPolygonMode()
void SetTextureUScale(const unsigned int &textureUnit, const float &value)
unsigned char GetAlphaRejectionValue() const
void SetDepthWriteEnabled(bool enabled)
void SetTextureByType(STexture *tex, SShaderGenerator::ShaderMapType type)
float GetTextureUScroll(const unsigned int &textureUnit)
float GetTextureUScale(const unsigned int &textureUnit)
bool GetAlphaToCoverage() const
int GetTextureUnitByType(SShaderGenerator::ShaderMapType type)
SceneBlendOperation GetSceneBlendingOperationAlpha() const
int GetSelfIlluminationColor()
void SetFragmentProgramParameter(const std::string ¶mName, const std::string &value)
std::string GetTextureFileName(const unsigned int &textureUnit)
std::string GetTextureUnitName(const unsigned int &textureUnit)
void SetUseVertexColor(bool state)
bool GetColourWriteEnabled() const
void SetTextureVScale(const unsigned int &textureUnit, const float &value)
void SetCullingMode(const bool state)
CompareFunction GetAlphaRejectionFunction() const
float GetTextureVScale(const unsigned int &textureUnit)
SceneBlendFactor GetSourceBlendFactorAlpha() const
void SetFragmentProgramAutoParameter(const std::string ¶mName, const Ogre::GpuProgramParameters::AutoConstantType ¶mType, const size_t ¶mExtraInfos)
STechnique * parentTechnique
float GetTextureVScroll(const unsigned int &textureUnit)
void OrderTexturesUnitsByType()
SceneBlendFactor GetDestBlendFactorAlpha() const
SceneBlendOperation GetSceneBlendingOperation() const
const Ogre::GpuNamedConstants GetFragmentProgramParameters()
void SetTexture(const unsigned int &textureUnit, STexture *texture, std::string name="")
void SetDiffuseColor(const int &color)
const Ogre::GpuNamedConstants GetVertexProgramParameters()
static SShaderGenerator::ShaderMapType GetTextureUnitType(Ogre::TextureUnitState *unit)
void CleanGeneratedShader()
STechnique * GetTechnique()
SceneBlendFactor GetDestBlendFactor() const
void UpdateGeneratedPass(bool full=false)
int GetNumTextureUnitStates()
bool GetLightingEnabled()
Ogre::Pass * GetOgrePassPointer()
bool GetSlicePlaneState()
Ogre::RenderSystem * GetOgreRenderSystem()
static SRoot * getSingletonPtr()
void InvalidateGeneratedMaterial(Ogre::Material *mat)
SShadowManager * GetShadowManager()
STexture * CreateTexture(const std::string &groupname, const std::string &texname, const std::string &path, const int &w=0, const int &h=0)
STexture * GetTexture(const std::string &groupName, const std::string &texName)
std::string GetShaderName()
virtual void ApplyShader()
void UpdateShadowMaterial(Ogre::Technique *tech)
SMaterial * GetParentMaterial()
Ogre::Technique * GetOgreTechniquePointer()
Ogre::TexturePtr getOgreTexturePointer()