SO3Engine
SO3Pass.cpp
Go to the documentation of this file.
1
8#include <boost/format.hpp>
9#include <boost/algorithm/string.hpp>
10
11#include "SO3Renderer/SO3Root.h"
14#include "SO3Material/SO3Pass.h"
17//#include "SO3Material/SO3ShaderGeneratorCG.h"
18//#include "SO3Material/SO3ShaderGeneratorGLES.h"
19//#include "SO3Material/SO3ShaderGeneratorGLSL.h"
20//#include "SO3Material/SO3ShaderGeneratorHLSL.h"
23
24namespace SO3
25{
26
27SPass::SPass(STechnique* technique, Ogre::Pass* ogrePassRef) : SData(ogrePassRef->getName())
28{
29 ogrePass = ogrePassRef;
30 parentTechnique = technique;
31 mGeneratedShader = false;
32 mPointSize = 1.0f;
33
34 Ogre::ResourceGroupManager& resGrpMgr = Ogre::ResourceGroupManager::getSingleton();
35
36 //remove not found textures to avoid strange behavior or crash later
37 const std::vector<Ogre::TextureUnitState*> texunits = ogrePass->getTextureUnitStates();
38 for(unsigned int t = 0; t < texunits.size(); t++)
39 {
40 Ogre::TextureUnitState* pTex = texunits[t];
41 Ogre::String tex_name = pTex->getTextureName();
42 //test filename validity
43 if (!tex_name.empty())
44 {
45 try
46 {
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())
51 {
52 Ogre::LogManager::getSingleton().getDefaultLog()->logMessage("[WARNING] Could not find the texture file : " + tex_name);
53 pTex->setBlank();
54 }
55 }
56 catch (Ogre::Exception &)
57 {
58 Ogre::LogManager::getSingleton().getDefaultLog()->logMessage("[WARNING] Could not find the texture file : " + tex_name);
59 pTex->setBlank();
60 }
61 }
62 }
63
64 if (ogrePass->getShininess() == 0.0)
65 ogrePass->setShininess(0.01f);
66
67 //ogrePass->setPointAttenuation(true);
68
69 //build shader if needed
71 BuildShader(true);
72}
73
74SPass::SPass() : SData("")
75{
76 // Forbiden (private)
77}
78
80{
81 Ogre::Any bindedSPass = ogrePass->getUserObjectBindings().getUserAny("SPass");
82 if(bindedSPass.has_value())
83 ogrePass->getUserObjectBindings().eraseUserAny("SPass");
84
86}
87
88std::string SPass::GetTextureUnitTypedName(Ogre::TextureUnitState* unit)
89{
90 Ogre::String tex_name = unit->getName();
91
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))
107 return tex_name;
108
109 // use texture name if no unit name
110 tex_name = unit->getTextureName();
111 Ogre::StringUtil::toLowerCase(tex_name);
112 return tex_name;
113}
114
116{
117 Ogre::String tex_name = GetTextureUnitTypedName(unit);
118
119 Ogre::TextureUnitState::EffectMap effects = unit->getEffects();
120 Ogre::TextureUnitState::EffectMap::const_iterator effectEnd = effects.end();
121 bool envMap = false;
122 if (!effects.empty() && (effects.find(Ogre::TextureUnitState::ET_ENVIRONMENT_MAP) != effectEnd))
123 envMap = true;
124
126
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))
147
148 return curType;
149}
150
152{
153 return mGeneratedShader;
154}
155
157{
158 if (!mGeneratedShader)
159 return;
160
161 ogrePass->setVertexProgram("");
162 ogrePass->setFragmentProgram("");
163}
164
165void SPass::BuildShader(bool force)
166{
167 //Ogre::RTShader::ShaderGenerator* shaderGen = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
168 Ogre::Technique* tech = parentTechnique->GetOgreTechniquePointer();
169
170 //check if technique is supported before the technique compilation
171 bool isSupported = tech->isSupported() && ogrePass->hasVertexProgram() && ogrePass->hasFragmentProgram();
172 if (!isSupported)
173 {
174 Ogre::StringStream errors;
175 isSupported = tech->checkGPURules(errors) && tech->checkHardwareSupport(true, errors) && ogrePass->hasVertexProgram() && ogrePass->hasFragmentProgram();
176 }
177
178 // ignore material pass with working shaders
179 if (isSupported && (!mGeneratedShader || !force))
180 return;
181
182 bool needed = false;
183 if ((ogrePass->getIlluminationStage() == Ogre::IS_UNKNOWN) && (tech->getSchemeName() != "basic") && (tech->getSchemeName() != "basic_mat") && (!ogrePass->hasVertexProgram() || !ogrePass->hasFragmentProgram() || !isSupported || (!parentTechnique->GetParentMaterial()->GetIgnoreSlicePlane() && SRoot::getSingletonPtr()->GetSlicePlaneState())))
184 needed = true;
185
186 if (needed || mGeneratedShader || force)
187 {
188 try
189 {
190 ogrePass->setVertexProgram("");
191 ogrePass->setFragmentProgram("");
192 Ogre::String rendererName = SRoot::getSingletonPtr()->GetOgreRenderSystem()->getName();
193
194 /*
195 // add RTSS params
196 if (!mGeneratedShader || force)
197 {
198 SShaderGenerator shaderRTSS(parentTechnique->GetOgreTechniquePointer(), ogrePass, SShaderGenerator::ShaderGeneratorRTSS, parentTechnique->GetParentMaterial()->GetIgnoreSlicePlane() || !SRoot::getSingletonPtr()->GetSlicePlaneState());
199 shaderRTSS.ApplyShader();
200 }
201 */
202
203 if (rendererName == "OpenGL ES 2.x Rendering Subsystem" || rendererName == "Metal Rendering Subsystem")
204 {
206 MMechostr(MSKDEBUG, ">> Vertex Shader for material %s : %s\n", parentTechnique->GetParentMaterial()->GetName().c_str(), VPshader.GetShaderName().c_str());
207 VPshader.ApplyShader();
208
210 MMechostr(MSKDEBUG, ">> Fragment Shader for material %s : %s\n", parentTechnique->GetParentMaterial()->GetName().c_str(), FPshader.GetShaderName().c_str());
211 FPshader.ApplyShader();
212
213 mGeneratedShader = true;
214 }
215#ifdef _WIN32
216 // INTEL HD fail with GLSL shaders ?!
217 else if (rendererName == "Direct3D9 Rendering Subsystem" || rendererName == "Direct3D11 Rendering Subsystem" || rendererName == "OpenGL Rendering Subsystem" || rendererName == "Vulkan Rendering Subsystem")
218 {
220 MMechostr(MSKDEBUG, ">> Vertex Shader for material %s : %s\n", parentTechnique->GetParentMaterial()->GetName().c_str(), VPshader.GetShaderName().c_str());
221 VPshader.ApplyShader();
222
224 MMechostr(MSKDEBUG, ">> Fragment Shader for material %s : %s\n", parentTechnique->GetParentMaterial()->GetName().c_str(), FPshader.GetShaderName().c_str());
225 FPshader.ApplyShader();
226
227 mGeneratedShader = true;
228 }
229#endif
230 else
231 {
233 MMechostr(MSKDEBUG, ">> Vertex Shader for material %s : %s\n", parentTechnique->GetParentMaterial()->GetName().c_str(), VPshader.GetShaderName().c_str());
234 VPshader.ApplyShader();
235
237 MMechostr(MSKDEBUG, ">> Fragment Shader for material %s : %s\n", parentTechnique->GetParentMaterial()->GetName().c_str(), FPshader.GetShaderName().c_str());
238 FPshader.ApplyShader();
239
240 mGeneratedShader = true;
241 }
242 }
243 catch (Ogre::Exception& e)
244 {
245 //not supported shader
246 ogrePass->setVertexProgram("");
247 ogrePass->setFragmentProgram("");
248 Ogre::LogManager::getSingleton().getDefaultLog()->logMessage("[ERROR] Could not compute shader : " + e.getFullDescription());
249 }
250
251 //check that new technique is supported
252 Ogre::Technique* tech = parentTechnique->GetOgreTechniquePointer();
253 //check if technique is supported before the technique compilation
254 isSupported = tech->isSupported();
255 if (!isSupported)
256 {
257 Ogre::StringStream errors;
258 isSupported = tech->checkGPURules(errors) && tech->checkHardwareSupport(true, errors);
259 }
260
261 if (!isSupported)
262 {
263 //remove shaders
264 ogrePass->setVertexProgram("");
265 ogrePass->setFragmentProgram("");
266 }
267
268 parentTechnique->GetParentMaterial()->getOgreMaterialPointer()->_notifyNeedsRecompile();
269 }
270}
271
273{
274 return ogrePass;
275}
276
281
283{
284 return ogrePass->getNumTextureUnitStates();
285}
286
287std::string SPass::GetTextureUnitName(const unsigned int& textureUnit)
288{
289 std::string returnValue("");
290 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
291 if (tmpTextureUnit != 0)
292 {
293 returnValue = tmpTextureUnit->getName();
294 if(returnValue.empty())
295 returnValue = boost::str(boost::format("%1%") %textureUnit);
296 }
297 return returnValue;
298}
299
300int SPass::GetTextureUnitIndexByName(const std::string& texname)
301{
302 return ogrePass->getTextureUnitStateIndex(ogrePass->getTextureUnitState(texname));
303}
304
305std::string SPass::GetTextureName(const unsigned int& textureUnit)
306{
307 std::string texname;
308 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
309 if (tmpTextureUnit != 0)
310 texname = tmpTextureUnit->getTextureName();
311
312 return texname;
313}
314
315std::string SPass::GetTextureFileName(const unsigned int& textureUnit)
316{
317 std::string texFile = "";
318 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
319 if (tmpTextureUnit != 0)
320 {
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())
327 {
328 Ogre::FileInfo file_info = file_list_itr.getNext();
329 texFile = file_info.filename;
330 }
331 }
332 return texFile;
333}
334
335void SPass::SetTextureUScroll(const unsigned int& textureUnit, const float& value)
336{
337 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
338 if(tmpTextureUnit != 0)
339 tmpTextureUnit->setTextureUScroll(Ogre::Real(value));
340 else
341 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Texture unit not found on material.", "SMaterial::SetTextureUScroll");
342
344}
345
346float SPass::GetTextureUScroll(const unsigned int& textureUnit)
347{
348 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
349 if(tmpTextureUnit != 0)
350 return static_cast <float> (tmpTextureUnit->getTextureUScroll());
351 else
352 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Texture unit not found on material.", "SMaterial::GetTextureUScroll");
353
354 return 0.0f;
355}
356
357void SPass::SetTextureVScroll(const unsigned int& textureUnit, const float& value)
358{
359 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
360 if(tmpTextureUnit != 0)
361 tmpTextureUnit->setTextureVScroll(Ogre::Real(value));
362 else
363 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Texture unit not found on material.", "SMaterial::SetTextureVScroll");
364
366}
367
368float SPass::GetTextureVScroll(const unsigned int& textureUnit)
369{
370 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
371 if(tmpTextureUnit != 0)
372 return static_cast <float> (tmpTextureUnit->getTextureVScroll());
373 else
374 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Texture unit not found on material.", "SMaterial::GetTextureVScroll");
375
376 return 0.0f;
377}
378
379void SPass::SetTextureUScale(const unsigned int& textureUnit, const float& value)
380{
381 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
382 if(tmpTextureUnit != 0)
383 tmpTextureUnit->setTextureUScale(Ogre::Real(value));
384 else
385 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Texture unit not found on material.", "SMaterial::SetTextureUScale");
386
388}
389
390float SPass::GetTextureUScale(const unsigned int& textureUnit)
391{
392 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
393 if(tmpTextureUnit != 0)
394 return static_cast <float> (tmpTextureUnit->getTextureUScale());
395 else
396 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Texture unit not found on material.", "SMaterial::GetTextureUScale");
397
398 return 0.0f;
399}
400
401void SPass::SetTextureVScale(const unsigned int& textureUnit, const float& value)
402{
403 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
404 if(tmpTextureUnit != 0)
405 tmpTextureUnit->setTextureVScale(Ogre::Real(value));
406 else
407 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Texture unit not found on material.", "SMaterial::SetTextureVScale");
408
410}
411
412float SPass::GetTextureVScale(const unsigned int& textureUnit)
413{
414 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
415 if(tmpTextureUnit != 0)
416 return static_cast <float> (tmpTextureUnit->getTextureVScale());
417 else
418 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Texture unit not found on material.", "SMaterial::GetTextureVScale");
419
420 return 0.0f;
421}
422
423void SPass::SetTextureRotate(const unsigned int& textureUnit, const float& radianAngle)
424{
425 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
426 if(tmpTextureUnit != 0)
427 tmpTextureUnit->setTextureRotate(Ogre::Radian(radianAngle));
428 else
429 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Texture unit not found on material.", "SMaterial::SetTextureRotate");
430
432}
433
434const float SPass::GetTextureRotate(const unsigned int& textureUnit)
435{
436 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
437 if(tmpTextureUnit != 0)
438 return static_cast <float> (tmpTextureUnit->getTextureRotate().valueRadians());
439 else
440 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Texture unit not found on material.", "SMaterial::GetTextureRotate");
441
442 return 0.0f;
443}
444
445void SPass::SetTextureScrollAnimation(const unsigned int& textureUnit, const float& uSpeed, const float& vSpeed)
446{
447 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
448 if (tmpTextureUnit != 0)
449 tmpTextureUnit->setScrollAnimation(Ogre::Real(uSpeed), Ogre::Real(vSpeed));
450 else
451 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Texture unit not found on material.", "SMaterial::SetScrollAnimation");
452
454}
455
456void SPass::SetTextureRotateAnimation(const unsigned int& textureUnit, const float& speed)
457{
458 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
459 if(tmpTextureUnit != 0)
460 tmpTextureUnit->setRotateAnimation(Ogre::Real(speed));
461 else
462 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Texture unit not found on material.", "SMaterial::SetRotateAnimation");
463
465}
466
468{
469 return ogrePass->getLightingEnabled();
470}
471
472void SPass::SetLightingEnabled(const bool& state)
473{
474 ogrePass->setLightingEnabled(state);
475
477}
478
479void SPass::SetAmbientColor(const int& color)
480{
482
484}
485
486void SPass::SetAmbientColor(Ogre::ColourValue color)
487{
488 ogrePass->setAmbient(color);
489
491}
492
497
498void SPass::SetDiffuseColor(const int& color)
499{
501
503}
504
505void SPass::SetDiffuseColor(Ogre::ColourValue color)
506{
507 ogrePass->setDiffuse(color);
508
510}
511
516
517void SPass::SetSpecularColor(const int& color)
518{
520
522}
523
524void SPass::SetSpecularColor(Ogre::ColourValue color)
525{
526 ogrePass->setSpecular(color);
527
529}
530
535
537{
538 ogrePass->setSelfIllumination(ConversionTools::ScolToOgreColorRGBA(color));
539
541}
542
543void SPass::SetSelfIlluminationColor(Ogre::ColourValue color)
544{
545 ogrePass->setSelfIllumination(color);
546
548}
549
551{
552 return ConversionTools::OgreToScolColorRGBA(ogrePass->getSelfIllumination());
553}
554
555void SPass::SetShininess(const float& value)
556{
557 if (value == 0.0f)
558 ogrePass->setShininess(0.01f);
559 else
560 ogrePass->setShininess(value);
561
563}
564
566{
567 return ogrePass->getShininess();
568}
569
571{
572 if (state)
573 ogrePass->setVertexColourTracking(Ogre::TVC_AMBIENT | Ogre::TVC_DIFFUSE);
574 else
575 ogrePass->setVertexColourTracking(Ogre::TVC_NONE);
576
578}
579
581{
582 return (bool)((ogrePass->getVertexColourTracking() & Ogre::TVC_AMBIENT) || (ogrePass->getVertexColourTracking() == Ogre::TVC_DIFFUSE));
583}
584
585void SPass::SetTexture(const unsigned int& textureUnit, STexture* texture, std::string name)
586{
587 bool unitsUpdated = false;
588 Ogre::TextureUnitState* tmpTextureUnit = GetTextureUnitState(textureUnit);
589
590 try
591 {
592 if (tmpTextureUnit != 0)
593 {
594 if ((texture != 0) /*&& (tmpTextureUnit->_getTexturePtr() != texture->getOgreTexturePointer())*/) // this test crash on deleted textures
595 {
596 if (!texture->getOgreTexturePointer())
597 tmpTextureUnit->setBlank();
598 else
599 tmpTextureUnit->setTexture(texture->getOgreTexturePointer());
600
601 if (!name.empty())
602 tmpTextureUnit->setName(name);
603 tmpTextureUnit->retryTextureLoad();
604 }
605 else
606 {
607 if (textureUnit == (ogrePass->getNumTextureUnitStates() - 1))
608 {
609 ogrePass->removeTextureUnitState(textureUnit);
610 unitsUpdated = true;
611 }
612 }
613 }
614 else if (texture != 0)
615 {
616 while (ogrePass->getNumTextureUnitStates() < (textureUnit + 1))
617 {
618 tmpTextureUnit = ogrePass->createTextureUnitState();
619 unitsUpdated = true;
620 }
621
622 if (!name.empty())
623 tmpTextureUnit->setName(name);
624
625 if (!texture->getOgreTexturePointer())
626 tmpTextureUnit->setBlank();
627 else
628 tmpTextureUnit->setTexture(texture->getOgreTexturePointer());
629 tmpTextureUnit->retryTextureLoad();
630 }
631 }
632 catch (Ogre::Exception &)
633 {
634 Ogre::LogManager::getSingleton().getDefaultLog()->logMessage("[WARNING] Could not apply the texture file");
635 if (tmpTextureUnit != 0)
636 tmpTextureUnit->setBlank();
637 }
638
639 if (unitsUpdated)
641
642 UpdateGeneratedPass(unitsUpdated);
643}
644
645STexture* SPass::GetTexture(const unsigned int& textureUnit)
646{
647 std::string texname = GetTextureName(textureUnit);
648 std::string texfile = texname; //;GetTextureFileName(textureUnit); // this bug on android
649 if (texname.empty())
650 return 0;
651
653 std::string groupName = parentTechnique->GetParentMaterial()->GetGroupName();
654 STexture* newTex = scene->GetTexture(groupName, texname);
655 if (newTex == 0) // && (!texfile.empty()))
656 newTex = scene->CreateTexture(groupName, texname, texfile);
657
658 return newTex;
659}
660
662{
663 Ogre::TextureUnitState* foundTex = 0;
664 int unitId = -1;
665
666 Ogre::Pass::TextureUnitStates units = ogrePass->getTextureUnitStates();
667 for (unsigned int i = 0; i < units.size() && !foundTex; i++)
668 {
669 Ogre::TextureUnitState* pTex = units[i];
670 Ogre::String tex_name = GetTextureUnitTypedName(pTex);
671
672 Ogre::TextureUnitState::EffectMap effects = pTex->getEffects();
673 Ogre::TextureUnitState::EffectMap::const_iterator effectEnd = effects.end();
674 bool envMap = false;
675 if (!effects.empty() && (effects.find(Ogre::TextureUnitState::ET_ENVIRONMENT_MAP) != effectEnd))
676 envMap = true;
677
679
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))
698 else
700
701 if (curType == type)
702 foundTex = pTex;
703
704 unitId++;
705 }
706
707 if (foundTex)
708 return unitId;
709 else
710 return -1;
711}
712
713Ogre::TextureUnitState* SPass::GetTextureUnitState(const unsigned int& textureUnit)
714{
715 // Check if the targetTextureUnit is inbound
716 Ogre::TextureUnitState* returnValue = 0;
717
718 // Check if inbound
719 size_t numTextureUnits = ogrePass->getNumTextureUnitStates();
720 if ((numTextureUnits > 0) && (textureUnit < numTextureUnits))
721 returnValue = ogrePass->getTextureUnitState(textureUnit);
722
723 return returnValue;
724}
725
726const Ogre::GpuNamedConstants SPass::GetVertexProgramParameters()
727{
728 Ogre::GpuNamedConstants paramList;
729 if(ogrePass->hasVertexProgram())
730 {
731 // Get param list
732 Ogre::GpuProgramParametersSharedPtr vertexProgramParameters = ogrePass->getVertexProgramParameters();
733 paramList = vertexProgramParameters->getConstantDefinitions();
734
735 // Filter the list
736 Ogre::GpuConstantDefinitionMap::iterator it = paramList.map.begin();
737 while(it != paramList.map.end())
738 {
739 if(boost::algorithm::ends_with(it->first, "[0]"))
740 {
741 // Erase duplicate entry
742 it = paramList.map.erase(it);
743 }
744 else
745 it++;
746 }
747 }
748 return paramList;
749}
750
751void SPass::SetVertexProgramAutoParameter(const std::string& paramName, const Ogre::GpuProgramParameters::AutoConstantType& paramType, const size_t& paramExtraInfos)
752{
753 if(ogrePass->hasVertexProgram())
754 {
755 Ogre::GpuProgramParametersSharedPtr vertexProgramParameters = ogrePass->getVertexProgramParameters();
756 if(vertexProgramParameters->_findNamedConstantDefinition(paramName))
757 vertexProgramParameters->setNamedAutoConstant(paramName, paramType, paramExtraInfos);
758 }
759}
760
761void SPass::SetVertexProgramParameter(const std::string& paramName, const std::string& value)
762{
763 if(ogrePass->hasVertexProgram())
764 {
765 Ogre::GpuProgramParametersSharedPtr vertexProgramParameters = ogrePass->getVertexProgramParameters();
766 const Ogre::GpuConstantDefinition* constantDefinition = vertexProgramParameters->_findNamedConstantDefinition(paramName);
767 if(constantDefinition != 0)
768 {
769 // Try to convert from string to constant definition type.
770 switch(constantDefinition->constType)
771 {
772 case Ogre::GCT_INT1:
773 if(Ogre::StringConverter::isNumber(value))
774 vertexProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseInt(value));
775 break;
776 /*case Ogre::GCT_INT2:
777 vertexProgramParameters->setNamedConstant((paramName, Ogre::StringConverter::parseVector2(value));
778 break;*/
779 case Ogre::GCT_INT3:
780 vertexProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseVector3(value));
781 break;
782 case Ogre::GCT_INT4:
783 vertexProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseVector4(value));
784 break;
785 case Ogre::GCT_FLOAT1:
786 if(Ogre::StringConverter::isNumber(value))
787 vertexProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseReal(value));
788 break;
789 /*case Ogre::GCT_FLOAT2:
790 vertexProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseVector2(value));
791 break;*/
792 case Ogre::GCT_FLOAT3:
793 vertexProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseVector3(value));
794 break;
795 case Ogre::GCT_FLOAT4:
796 vertexProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseVector4(value));
797 break;
798 case Ogre::GCT_MATRIX_4X4:
799 vertexProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseMatrix4(value));
800 break;
801 };
802 }
803 }
804}
805
806const Ogre::GpuNamedConstants SPass::GetFragmentProgramParameters()
807{
808 Ogre::GpuNamedConstants paramList;
809 if(ogrePass->hasFragmentProgram())
810 {
811 // Get param list
812 Ogre::GpuProgramParametersSharedPtr fragmentProgramParameters = ogrePass->getFragmentProgramParameters();
813 paramList = fragmentProgramParameters->getConstantDefinitions();
814
815 // Filter the list
816 Ogre::GpuConstantDefinitionMap::iterator it = paramList.map.begin();
817 while(it != paramList.map.end())
818 {
819 if(boost::algorithm::ends_with(it->first, "[0]"))
820 {
821 // Erase duplicate entry
822 it = paramList.map.erase(it);
823 }
824 else
825 it++;
826 }
827 }
828 return paramList;
829}
830
831void SPass::SetFragmentProgramAutoParameter(const std::string& paramName, const Ogre::GpuProgramParameters::AutoConstantType& paramType, const size_t& paramExtraInfos)
832{
833 if(ogrePass->hasFragmentProgram())
834 {
835 Ogre::GpuProgramParametersSharedPtr fragmentProgramParameters = ogrePass->getFragmentProgramParameters();
836 if(fragmentProgramParameters->_findNamedConstantDefinition(paramName))
837 fragmentProgramParameters->setNamedAutoConstant(paramName, paramType, paramExtraInfos);
838 }
839}
840
841void SPass::SetFragmentProgramParameter(const std::string& paramName, const std::string& value)
842{
843 if(ogrePass->hasFragmentProgram())
844 {
845 Ogre::GpuProgramParametersSharedPtr fragmentProgramParameters = ogrePass->getFragmentProgramParameters();
846 const Ogre::GpuConstantDefinition* constantDefinition = fragmentProgramParameters->_findNamedConstantDefinition(paramName);
847 if(constantDefinition != 0)
848 {
849 // Try to convert from string to constant definition type.
850 switch(constantDefinition->constType)
851 {
852 case Ogre::GCT_INT1:
853 if(Ogre::StringConverter::isNumber(value))
854 fragmentProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseInt(value));
855 break;
856 /*case Ogre::GCT_INT2:
857 fragmentProgramParameters->setNamedConstant((paramName, Ogre::StringConverter::parseVector2(value));
858 break;*/
859 case Ogre::GCT_INT3:
860 fragmentProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseVector3(value));
861 break;
862 case Ogre::GCT_INT4:
863 fragmentProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseVector4(value));
864 break;
865 case Ogre::GCT_FLOAT1:
866 if(Ogre::StringConverter::isNumber(value))
867 fragmentProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseReal(value));
868 break;
869 /*case Ogre::GCT_FLOAT2:
870 fragmentProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseVector2(value));
871 break;*/
872 case Ogre::GCT_FLOAT3:
873 fragmentProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseVector3(value));
874 break;
875 case Ogre::GCT_FLOAT4:
876 fragmentProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseVector4(value));
877 break;
878 case Ogre::GCT_MATRIX_4X4:
879 fragmentProgramParameters->setNamedConstant(paramName, Ogre::StringConverter::parseMatrix4(value));
880 break;
881 };
882 }
883 }
884}
885
887{
888 return static_cast<SPass::SceneBlendFactor>(static_cast<int>(ogrePass->getSourceBlendFactor()));
889}
890
892{
893 return static_cast<SPass::SceneBlendFactor>(static_cast<int>(ogrePass->getDestBlendFactor()));
894}
895
897{
898 return static_cast<SPass::SceneBlendFactor>(static_cast<int>(ogrePass->getSourceBlendFactorAlpha()));
899}
900
902{
903 return static_cast<SPass::SceneBlendFactor>(static_cast<int>(ogrePass->getDestBlendFactorAlpha()));
904}
905
907{
908 ogrePass->setSceneBlending(static_cast<Ogre::SceneBlendFactor>(static_cast<int>(sourceFactor)),
909 static_cast<Ogre::SceneBlendFactor>(static_cast<int>(destFactor)));
910
911 UpdateGeneratedPass(true);
912}
913
914void SPass::SetSceneBlending(const SPass::SceneBlendFactor sourceFactor, const SPass::SceneBlendFactor destFactor, const SPass::SceneBlendFactor sourceFactorAlpha, const SPass::SceneBlendFactor destFactorAlpha)
915{
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)));
920
922}
923
925{
926 return static_cast<SPass::SceneBlendOperation>(static_cast<int>(ogrePass->getSceneBlendingOperation()));
927}
928
930{
931 return static_cast<SPass::SceneBlendOperation>(static_cast<int>(ogrePass->getSceneBlendingOperationAlpha()));
932}
933
935{
936 ogrePass->setSeparateSceneBlendingOperation(static_cast<Ogre::SceneBlendOperation>(static_cast<int>(op)),
937 static_cast<Ogre::SceneBlendOperation>(static_cast<int>(alphaOp)));
938
940}
941
943{
944 ogrePass->setDepthCheckEnabled(enabled);
945
947}
948
950{
951 return ogrePass->getDepthCheckEnabled();
952}
953
955{
956 ogrePass->setDepthWriteEnabled(enabled);
957 ogrePass->getParent()->getParent()->setTransparencyCastsShadows(!enabled);
958
960}
961
963{
964 return ogrePass->getDepthWriteEnabled();
965}
966
968{
969 ogrePass->setDepthFunction(static_cast<Ogre::CompareFunction>(static_cast<int>(func)));
970
972}
973
975{
976 return static_cast<SPass::CompareFunction>(static_cast<int>(ogrePass->getDepthFunction()));
977}
978
979void SPass::SetAlphaRejection(CompareFunction func, unsigned char value, bool alphaToCoverageEnabled)
980{
981 ogrePass->setAlphaRejectSettings(static_cast<Ogre::CompareFunction>(static_cast<int>(func)), value, alphaToCoverageEnabled);
982
984}
985
987{
988 return static_cast<SPass::CompareFunction>(static_cast<int>(ogrePass->getAlphaRejectFunction()));
989}
990
991unsigned char SPass::GetAlphaRejectionValue() const
992{
993 return ogrePass->getAlphaRejectValue();
994}
995
997{
998 return ogrePass->isAlphaToCoverageEnabled();
999}
1000
1002{
1003 ogrePass->setColourWriteEnabled(state);
1004
1005 UpdateGeneratedPass(true);
1006}
1007
1009{
1010 return ogrePass->getColourWriteEnabled();
1011}
1012
1013void SPass::SetCullingMode(const bool state)
1014{
1015 Ogre::CullingMode mode = (state) ? Ogre::CULL_CLOCKWISE : Ogre::CULL_NONE;
1016 ogrePass->setCullingMode(mode);
1017
1018 ogrePass->getParent()->getParent()->setTransparencyCastsShadows(!state && !ogrePass->getDepthWriteEnabled());
1019
1020 UpdateGeneratedPass(true);
1021}
1022
1024{
1025 if (ogrePass->getCullingMode() == Ogre::CULL_NONE)
1026 return false;
1027 else
1028 return true;
1029}
1030
1031void SPass::SetPointSize(Ogre::Real size)
1032{
1033 mPointSize = size;
1034
1035 if (ogrePass->getPolygonMode() == Ogre::PM_POINTS)
1036 {
1037 ogrePass->setPointSize(mPointSize);
1038 //ogrePass->setPointAttenuation(true);
1039 }
1041}
1042
1044{
1045 return ogrePass->getPointSize();
1046}
1047
1049{
1050 if (ogrePass->getPolygonMode() == Ogre::PM_POINTS)
1051 return true;
1052
1053 return false;
1054}
1055
1057{
1058 ogrePass->setPolygonMode(static_cast<Ogre::PolygonMode>(mode));
1059
1060 if (ogrePass->getPolygonMode() == Ogre::PM_POINTS)
1061 {
1062 ogrePass->setPointSize(mPointSize);
1063 //ogrePass->setPointAttenuation(true);
1064 }
1065 else
1066 {
1067 ogrePass->setPointSize(1.0f);
1068 //ogrePass->setPointAttenuation(false);
1069 }
1070
1071 if (mode == SO3_POLYGONMODE_POINTS)
1072 ogrePass->setPolygonModeOverrideable(false);
1073 else
1074 ogrePass->setPolygonModeOverrideable(true);
1075
1076 UpdateGeneratedPass(true);
1077}
1078
1080{
1081 return static_cast<SPass::PolygonMode>(ogrePass->getPolygonMode());
1082}
1083
1084void SPass::SetTextureUnitColorBlendModeFactor(const unsigned int& textureUnit, float factor)
1085{
1086 if (textureUnit < ogrePass->getNumTextureUnitStates())
1087 {
1088 Ogre::TextureUnitState* pTex = ogrePass->getTextureUnitState(textureUnit);
1089 if (!pTex)
1090 return;
1091
1092 pTex->setColourOperationEx(Ogre::LBX_BLEND_MANUAL, Ogre::LBS_TEXTURE, Ogre::LBS_CURRENT, Ogre::ColourValue::Black, Ogre::ColourValue::White, factor);
1093
1094 /*
1095 Ogre::RTShader::ShaderGenerator* shaderGen = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
1096 Ogre::RTShader::RenderState* rs = shaderGen->getRenderState(Ogre::MSN_SHADERGEN, *(parentTechnique->GetOgreTechniquePointer()->getParent()), ogrePass->getIndex());
1097
1098 if (rs)
1099 {
1100 Ogre::RTShader::SubRenderState* srs = rs->getSubRenderState(Ogre::RTShader::SRS_IMAGE_BASED_LIGHTING);
1101
1102 const Ogre::LayerBlendModeEx& bl = ogrePass->getTextureUnitState(textureUnit)->getColourBlendMode();
1103 if (srs)
1104 srs->setParameter("luminance", std::to_string((bl.factor == 0.0) ? 1.0 : bl.factor));
1105 }*/
1106
1107 UpdateGeneratedPass(true);
1108 }
1109}
1110
1111float SPass::GetTextureUnitColorBlendModeFactor(const unsigned int& textureUnit)
1112{
1113 if (textureUnit < ogrePass->getNumTextureUnitStates())
1114 return ogrePass->getTextureUnitState(textureUnit)->getColourBlendMode().factor;
1115
1116 return 1.0f;
1117}
1118
1119void SPass::RemoveTexture(const unsigned int& textureUnit)
1120{
1121 if (textureUnit < ogrePass->getNumTextureUnitStates())
1122 {
1123 ogrePass->removeTextureUnitState(textureUnit);
1125 }
1126
1127 UpdateGeneratedPass(true);
1128}
1129
1131{
1132 const Ogre::Pass::TextureUnitStates& texunits = ogrePass->getTextureUnitStates();
1133
1134 if (texunits.size() <= 1)
1135 return;
1136
1137 int passConf = 0;
1138
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]);
1146
1147 std::vector<Ogre::TextureUnitState> otherUnits;
1148
1149 for (unsigned int t = 0; t < texunits.size(); t++)
1150 {
1151 Ogre::TextureUnitState* pTex = texunits[t];
1153
1154 switch (type)
1155 {
1157 amb = *pTex;
1159 break;
1161 diff = *pTex;
1163 break;
1165 ill = *pTex;
1167 break;
1169 norm = *pTex;
1170 passConf |= SShaderGenerator::MAP_NORMAL;
1171 break;
1173 ref = *pTex;
1175 break;
1177 roughn = *pTex;
1179 break;
1181 opacity = *pTex;
1183 break;
1184 default:
1185 otherUnits.push_back(Ogre::TextureUnitState(ogrePass, *pTex));
1186 }
1187 }
1188
1189 if (passConf == 0)
1190 return;
1191
1192 ogrePass->removeAllTextureUnitStates();
1193
1194 Ogre::TextureUnitState* newUnit = 0;
1195 if (passConf & SShaderGenerator::MAP_AMBIENT)
1196 {
1197 newUnit = ogrePass->createTextureUnitState();
1198 *newUnit = Ogre::TextureUnitState(amb);
1199 }
1200
1201 if (passConf & SShaderGenerator::MAP_DIFFUSE)
1202 {
1203 newUnit = ogrePass->createTextureUnitState();
1204 *newUnit = Ogre::TextureUnitState(diff);
1205 }
1206
1207 if (passConf & SShaderGenerator::MAP_NORMAL)
1208 {
1209 newUnit = ogrePass->createTextureUnitState();
1210 *newUnit = Ogre::TextureUnitState(norm);
1211 }
1212
1213 for (auto u : otherUnits)
1214 {
1215 newUnit = ogrePass->createTextureUnitState();
1216 *newUnit = Ogre::TextureUnitState(u);
1217 }
1218
1219 if (passConf & SShaderGenerator::MAP_REFLECTION)
1220 {
1221 newUnit = ogrePass->createTextureUnitState();
1222 *newUnit = Ogre::TextureUnitState(ref);
1223 }
1224
1225 if (passConf & SShaderGenerator::MAP_EMISSIVE)
1226 {
1227 newUnit = ogrePass->createTextureUnitState();
1228 *newUnit = Ogre::TextureUnitState(ill);
1229 }
1230
1231 if (passConf & SShaderGenerator::MAP_ROUGHNESS)
1232 {
1233 newUnit = ogrePass->createTextureUnitState();
1234 *newUnit = Ogre::TextureUnitState(roughn);
1235 }
1236
1237 if (passConf & SShaderGenerator::MAP_OPACITY)
1238 {
1239 newUnit = ogrePass->createTextureUnitState();
1240 *newUnit = Ogre::TextureUnitState(opacity);
1241 }
1242}
1243
1245{
1246 int tindex = GetTextureUnitByType(type);
1247 Ogre::TextureUnitState* tunit = 0;
1248
1249 bool newUnit = false;
1250 if (tindex >= 0)
1251 {
1252 tunit = ogrePass->getTextureUnitState(tindex);
1253 }
1254 else
1255 {
1256 tunit = ogrePass->createTextureUnitState();
1257 tunit->setName(GetTextureUnitNameByType(type));
1258 newUnit = true;
1259 }
1260
1261 if (!tex || !tex->getOgreTexturePointer())
1262 tunit->setBlank();
1263 else
1264 tunit->setTexture(tex->getOgreTexturePointer());
1265
1267 {
1268 if (tex && tex->getOgreTexturePointer() && tex->getOgreTexturePointer()->getNumFaces() == 6)
1269 tunit->setEnvironmentMap(true, Ogre::TextureUnitState::ENV_REFLECTION);
1270 else
1271 tunit->setEnvironmentMap(true, Ogre::TextureUnitState::ENV_CURVED);
1272 }
1273
1274 if (newUnit)
1276
1277 UpdateGeneratedPass(true);
1278}
1279
1281{
1282 std::string name = "";
1283 switch (type)
1284 {
1286 name = "ambient";
1287 break;
1289 name = "diffuse";
1290 break;
1292 name = "bump";
1293 break;
1295 name = "emissive";
1296 break;
1298 name = "normal";
1299 break;
1301 name = "opacity";
1302 break;
1304 name = "reflection_mask";
1305 break;
1307 name = "reflection";
1308 break;
1310 name = "shininess";
1311 break;
1313 name = "specular";
1314 break;
1316 name = "roughness";
1317 break;
1318 }
1319
1320 return name;
1321}
1322
1349
1350}
MMechostr(MSKDEBUG, " > Start loading Plugin SO3Engine dll\n")
static Ogre::ColourValue ScolToOgreColorRGBA(const int &scolColor)
static int OgreToScolColorRGBA(const Ogre::ColourValue &ogreColor)
std::string GetName() const
std::string name
Definition SO3DataScol.h:44
static void CleanUpGeneratedTechniques(Ogre::Material *mat)
Ogre::MaterialPtr getOgreMaterialPointer()
SScene * GetScene()
std::string GetGroupName()
bool GetIgnoreSlicePlane()
bool GetDepthCheckEnabled() const
Definition SO3Pass.cpp:949
void SetTextureRotateAnimation(const unsigned int &textureUnit, const float &speed)
Definition SO3Pass.cpp:456
void SetPolygonMode(PolygonMode mode)
Definition SO3Pass.cpp:1056
bool mGeneratedShader
Definition SO3Pass.h:86
void SetDepthFunction(CompareFunction func)
Definition SO3Pass.cpp:967
bool IsShaderGenerated()
Definition SO3Pass.cpp:151
void SetVertexProgramParameter(const std::string &paramName, const std::string &value)
Definition SO3Pass.cpp:761
void SetTextureRotate(const unsigned int &textureUnit, const float &radianAngle)
Definition SO3Pass.cpp:423
void SetTextureScrollAnimation(const unsigned int &textureUnit, const float &uSpeed, const float &vSpeed)
Definition SO3Pass.cpp:445
void RemoveTexture(const unsigned int &textureUnit)
Definition SO3Pass.cpp:1119
std::string GetTextureUnitNameByType(SShaderGenerator::ShaderMapType type)
Definition SO3Pass.cpp:1280
bool GetDepthWriteEnabled() const
Definition SO3Pass.cpp:962
void SetDepthCheckEnabled(bool enabled)
Definition SO3Pass.cpp:942
void SetPointSize(Ogre::Real size)
Definition SO3Pass.cpp:1031
CompareFunction
Definition SO3Pass.h:73
void SetTextureUnitColorBlendModeFactor(const unsigned int &textureUnit, float factor)
Definition SO3Pass.cpp:1084
void SetSelfIlluminationColor(const int &color)
Definition SO3Pass.cpp:536
void SetShininess(const float &value)
Definition SO3Pass.cpp:555
void BuildShader(bool force=false)
Definition SO3Pass.cpp:165
void SetAmbientColor(const int &color)
Definition SO3Pass.cpp:479
void SetTextureVScroll(const unsigned int &textureUnit, const float &value)
Definition SO3Pass.cpp:357
std::string GetTextureName(const unsigned int &textureUnit)
Definition SO3Pass.cpp:305
const float GetTextureRotate(const unsigned int &textureUnit)
Definition SO3Pass.cpp:434
void SetColourWriteEnabled(bool state)
Definition SO3Pass.cpp:1001
float GetPointSize()
Definition SO3Pass.cpp:1043
float GetShininess()
Definition SO3Pass.cpp:565
bool GetCullingMode() const
Definition SO3Pass.cpp:1023
void SetVertexProgramAutoParameter(const std::string &paramName, const Ogre::GpuProgramParameters::AutoConstantType &paramType, const size_t &paramExtraInfos)
Definition SO3Pass.cpp:751
float GetTextureUnitColorBlendModeFactor(const unsigned int &textureUnit)
Definition SO3Pass.cpp:1111
void SetSceneBlendingOperation(SceneBlendOperation op, SceneBlendOperation alphaOp)
Definition SO3Pass.cpp:934
@ SO3_POLYGONMODE_POINTS
Definition SO3Pass.h:47
bool IsPointCloud()
Definition SO3Pass.cpp:1048
STexture * GetTexture(const unsigned int &textureUnit)
Definition SO3Pass.cpp:645
void SetSpecularColor(const int &color)
Definition SO3Pass.cpp:517
int GetTextureUnitIndexByName(const std::string &texname)
Definition SO3Pass.cpp:300
void SetAlphaRejection(CompareFunction func, unsigned char value, bool alphaToCoverageEnabled=false)
Definition SO3Pass.cpp:979
SceneBlendFactor GetSourceBlendFactor() const
Definition SO3Pass.cpp:886
static std::string GetTextureUnitTypedName(Ogre::TextureUnitState *unit)
Definition SO3Pass.cpp:88
void SetLightingEnabled(const bool &state)
Definition SO3Pass.cpp:472
CompareFunction GetDepthFunction() const
Definition SO3Pass.cpp:974
void SetTextureUScroll(const unsigned int &textureUnit, const float &value)
Definition SO3Pass.cpp:335
void SetSceneBlending(const SPass::SceneBlendFactor sourceFactor, const SPass::SceneBlendFactor destFactor)
Definition SO3Pass.cpp:906
PolygonMode GetPolygonMode()
Definition SO3Pass.cpp:1079
void SetTextureUScale(const unsigned int &textureUnit, const float &value)
Definition SO3Pass.cpp:379
unsigned char GetAlphaRejectionValue() const
Definition SO3Pass.cpp:991
void SetDepthWriteEnabled(bool enabled)
Definition SO3Pass.cpp:954
void SetTextureByType(STexture *tex, SShaderGenerator::ShaderMapType type)
Definition SO3Pass.cpp:1244
float GetTextureUScroll(const unsigned int &textureUnit)
Definition SO3Pass.cpp:346
float GetTextureUScale(const unsigned int &textureUnit)
Definition SO3Pass.cpp:390
bool GetAlphaToCoverage() const
Definition SO3Pass.cpp:996
int GetTextureUnitByType(SShaderGenerator::ShaderMapType type)
Definition SO3Pass.cpp:661
SceneBlendOperation GetSceneBlendingOperationAlpha() const
Definition SO3Pass.cpp:929
int GetSpecularColor()
Definition SO3Pass.cpp:531
int GetSelfIlluminationColor()
Definition SO3Pass.cpp:550
void SetFragmentProgramParameter(const std::string &paramName, const std::string &value)
Definition SO3Pass.cpp:841
float mPointSize
Definition SO3Pass.h:87
bool GetUseVertexColor()
Definition SO3Pass.cpp:580
std::string GetTextureFileName(const unsigned int &textureUnit)
Definition SO3Pass.cpp:315
std::string GetTextureUnitName(const unsigned int &textureUnit)
Definition SO3Pass.cpp:287
int GetDiffuseColor()
Definition SO3Pass.cpp:512
void SetUseVertexColor(bool state)
Definition SO3Pass.cpp:570
bool GetColourWriteEnabled() const
Definition SO3Pass.cpp:1008
SceneBlendOperation
Definition SO3Pass.h:52
void SetTextureVScale(const unsigned int &textureUnit, const float &value)
Definition SO3Pass.cpp:401
void SetCullingMode(const bool state)
Definition SO3Pass.cpp:1013
CompareFunction GetAlphaRejectionFunction() const
Definition SO3Pass.cpp:986
float GetTextureVScale(const unsigned int &textureUnit)
Definition SO3Pass.cpp:412
int GetAmbientColor()
Definition SO3Pass.cpp:493
SceneBlendFactor GetSourceBlendFactorAlpha() const
Definition SO3Pass.cpp:896
void SetFragmentProgramAutoParameter(const std::string &paramName, const Ogre::GpuProgramParameters::AutoConstantType &paramType, const size_t &paramExtraInfos)
Definition SO3Pass.cpp:831
STechnique * parentTechnique
Definition SO3Pass.h:85
float GetTextureVScroll(const unsigned int &textureUnit)
Definition SO3Pass.cpp:368
void OrderTexturesUnitsByType()
Definition SO3Pass.cpp:1130
SceneBlendFactor GetDestBlendFactorAlpha() const
Definition SO3Pass.cpp:901
SceneBlendOperation GetSceneBlendingOperation() const
Definition SO3Pass.cpp:924
const Ogre::GpuNamedConstants GetFragmentProgramParameters()
Definition SO3Pass.cpp:806
void SetTexture(const unsigned int &textureUnit, STexture *texture, std::string name="")
Definition SO3Pass.cpp:585
void SetDiffuseColor(const int &color)
Definition SO3Pass.cpp:498
const Ogre::GpuNamedConstants GetVertexProgramParameters()
Definition SO3Pass.cpp:726
Ogre::Pass * ogrePass
Definition SO3Pass.h:84
static SShaderGenerator::ShaderMapType GetTextureUnitType(Ogre::TextureUnitState *unit)
Definition SO3Pass.cpp:115
void CleanGeneratedShader()
Definition SO3Pass.cpp:156
STechnique * GetTechnique()
Definition SO3Pass.cpp:277
SceneBlendFactor GetDestBlendFactor() const
Definition SO3Pass.cpp:891
void UpdateGeneratedPass(bool full=false)
Definition SO3Pass.cpp:1323
int GetNumTextureUnitStates()
Definition SO3Pass.cpp:282
bool GetLightingEnabled()
Definition SO3Pass.cpp:467
Ogre::Pass * GetOgrePassPointer()
Definition SO3Pass.cpp:272
SceneBlendFactor
Definition SO3Pass.h:60
bool GetSlicePlaneState()
Definition SO3Root.cpp:2797
Ogre::RenderSystem * GetOgreRenderSystem()
Definition SO3Root.cpp:865
static SRoot * getSingletonPtr()
Definition SO3Root.cpp:111
void InvalidateGeneratedMaterial(Ogre::Material *mat)
Definition SO3Root.cpp:2350
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)
void UpdateShadowMaterial(Ogre::Technique *tech)
SMaterial * GetParentMaterial()
Ogre::Technique * GetOgreTechniquePointer()
Ogre::TexturePtr getOgreTexturePointer()