203 Ogre::MaterialManager* materialManager = Ogre::MaterialManager::getSingletonPtr();
204 Ogre::HighLevelGpuProgramManager* programManager = Ogre::HighLevelGpuProgramManager::getSingletonPtr();
208 if(iTemplateMaterials != templateMaterials.end())
210 typename SMaterialGenerator<PERMUTATION_CLASS, PERMUTATION_TYPE>::MaterialPermMap* materialPermMap = iTemplateMaterials->second;
212 while(iTemplatePermutations != materialPermMap->end())
214 materialManager->remove(iTemplatePermutations->second->getHandle());
215 iTemplatePermutations++;
219 SO3_SAFE_DELETE(iTemplateMaterials->second);
220 templateMaterials.erase(iTemplateMaterials);
225 if(iMaterials != materials.end())
227 typename SMaterialGenerator<PERMUTATION_CLASS, PERMUTATION_TYPE>::MaterialPermMap* materialPermMap = iMaterials->second;
229 while(iPermutations != materialPermMap->end())
231 materialManager->remove(iPermutations->second->getHandle());
236 SO3_SAFE_DELETE(iMaterials->second);
237 materials.erase(iMaterials);
242 if(iVertex != mVs.end())
244 typename SMaterialGenerator<PERMUTATION_CLASS, PERMUTATION_TYPE>::ProgramPermMap* vertexPermMap = iVertex->second;
246 while(iPermutations != vertexPermMap->end())
248 programManager->remove(iPermutations->second->getHandle());
253 SO3_SAFE_DELETE(iVertex->second);
259 if(iFragment != mFs.end())
261 typename SMaterialGenerator<PERMUTATION_CLASS, PERMUTATION_TYPE>::ProgramPermMap* fragmentPermMap = iFragment->second;
263 while(iPermutations != fragmentPermMap->end())
265 programManager->remove(iPermutations->second->getHandle());
270 SO3_SAFE_DELETE(iFragment->second);
271 mFs.erase(iFragment);
278 typename SMaterialGenerator<PERMUTATION_CLASS, PERMUTATION_TYPE>::MaterialPermMap* materialPermMap = 0;
280 if(i == materials.end())
283 materialPermMap =
new SMaterialGenerator<PERMUTATION_CLASS, PERMUTATION_TYPE>::MaterialPermMap();
284 materials[gbuffer] = materialPermMap;
288 materialPermMap = i->second;
292 PERMUTATION_TYPE permutationValue = permutation.GetPermutations();
294 if(j != materialPermMap->end())
301 Ogre::MaterialPtr templ = GetTemplateMaterial(gbuffer, permutation.GetMaterialPermutations());
302 Ogre::GpuProgramPtr vs = GetVertexShader(gbuffer, permutation.GetVertexPermutations());
303 Ogre::GpuProgramPtr fs = GetFragmentShader(gbuffer, permutation.GetFragmentPermutations());
306 Ogre::String name = materialBaseName + permutation.ToString();
307 std::cerr << name <<
" " << vs->getName() <<
" " << fs->getName() << std::endl;
310 Ogre::MaterialPtr mat = templ->clone(name);
311 Ogre::Technique* tech = mat->getTechnique(0);
312 Ogre::Pass* pass = tech->getPass(0);
313 pass->setFragmentProgram(fs->getName());
314 pass->setVertexProgram(vs->getName());
318 materialPermMap->insert(materialPermMap->begin(), val);
326 typename SMaterialGenerator<PERMUTATION_CLASS, PERMUTATION_TYPE>::ProgramPermMap* programPermMap = 0;
331 programPermMap =
new SMaterialGenerator<PERMUTATION_CLASS, PERMUTATION_TYPE>::ProgramPermMap();
332 mVs[gbuffer] = programPermMap;
336 programPermMap = i->second;
340 if(j != programPermMap->end())
347 Ogre::GpuProgramPtr progptr = GenerateVertexShader(gbuffer, permutationValue);
349 programPermMap->insert(programPermMap->begin(), val);
357 typename SMaterialGenerator<PERMUTATION_CLASS, PERMUTATION_TYPE>::ProgramPermMap* programPermMap = 0;
362 programPermMap =
new SMaterialGenerator<PERMUTATION_CLASS, PERMUTATION_TYPE>::ProgramPermMap();
363 mFs[gbuffer] = programPermMap;
367 programPermMap = i->second;
371 if(j != programPermMap->end())
378 Ogre::GpuProgramPtr progptr = GenerateFragmentShader(gbuffer, permutationValue);
380 programPermMap->insert(programPermMap->begin(), val);
388 typename SMaterialGenerator<PERMUTATION_CLASS, PERMUTATION_TYPE>::MaterialPermMap* materialPermMap = 0;
390 if(i == templateMaterials.end())
393 materialPermMap =
new SMaterialGenerator<PERMUTATION_CLASS, PERMUTATION_TYPE>::MaterialPermMap();
394 templateMaterials[gbuffer] = materialPermMap;
398 materialPermMap = i->second;
402 if(j != materialPermMap->end())
409 Ogre::MaterialPtr matptr = GenerateTemplateMaterial(gbuffer, permutationValue);
411 materialPermMap->insert(materialPermMap->begin(), val);