Changeset 2366 for GTP/trunk/Lib/Illum
- Timestamp:
- 05/12/07 14:21:03 (18 years ago)
- Location:
- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderingRun.h
r2355 r2366 11 11 class OgreRenderingRun : virtual public RenderingRun 12 12 { 13 friend class OgreIlluminationManager; 13 14 public: 14 15 /** … … 57 58 */ 58 59 static Entity* fullScreenQuadEntity; 59 /**60 @brief fulls screen quad SceneNode used in full screen quad rendering61 62 @see renderFullscreenQuad63 */64 static SceneNode* fullScreenQuadNode;65 60 /** 66 61 @brief SpriteSet used in pixel sprite rendering -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreTechniqueGroup.h
r2355 r2366 35 35 else return triggeredMaterials[trigger]; 36 36 } 37 void setMaterialForTrigger(String trigger, String material) 38 { 39 triggeredMaterials[trigger] = material; 40 } 37 41 38 42 protected: -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreCausticReceiverRenderTechnique.h
r2320 r2366 50 50 SceneBlendFactor passBlendingSRC, 51 51 SceneBlendFactor passBlendingDEST, 52 bool createNewPasses, 53 int startTextureUnitID, 54 String casterCenterVariableName, 55 String attenuationVariableName, 52 56 Pass* pass, 53 57 OgreRenderable* parentRenderable, … … 93 97 */ 94 98 SceneBlendFactor passBlendingDEST; 99 bool createNewPasses; 100 int startTextureUnitID; 101 String casterCenterVariableName; 102 String attenuationVariableName; 95 103 }; 96 104 … … 115 123 SceneBlendFactor passBlendingSRC; 116 124 SceneBlendFactor passBlendingDEST; 125 bool createNewPasses; 126 int startTextureUnitID; 127 String casterCenterVariableName; 128 String attenuationVariableName; 117 129 }; 118 130 -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgreDepthShadowReceiverRenderTechnique.h
r2320 r2366 67 67 SceneBlendFactor passBlendingSRC, 68 68 SceneBlendFactor passBlendingDEST, 69 bool createNewPasses, 70 int startTextureUnitID, 69 71 Pass* pass, 70 72 OgreRenderable* parentRenderable, … … 139 141 @brief destination blend factor of the new passes 140 142 */ 141 SceneBlendFactor passBlendingDEST; 143 SceneBlendFactor passBlendingDEST; 144 bool createNewPasses; 145 int startTextureUnitID; 142 146 }; 143 147 … … 170 174 SceneBlendFactor passBlendingSRC; 171 175 SceneBlendFactor passBlendingDEST; 176 bool createNewPasses; 177 int startTextureUnitID; 172 178 }; 173 179 -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgrePathMapRenderTechnique.h
r2320 r2366 34 34 SceneBlendFactor passBlendingSRC, 35 35 SceneBlendFactor passBlendingDEST, 36 bool createNewPasses, 37 int startTextureUnitID, 36 38 Pass* pass, 37 39 OgreRenderable* parentRenderable, … … 71 73 */ 72 74 SceneBlendFactor passBlendingDEST; 75 bool createNewPasses; 76 int startTextureUnitID; 73 77 }; 74 78 … … 89 93 SceneBlendFactor passBlendingSRC; 90 94 SceneBlendFactor passBlendingDEST; 95 bool createNewPasses; 96 int startTextureUnitID; 91 97 }; 92 98 -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/scripts/OgreIllumModule.7.10.vcproj
r2333 r2366 282 282 RelativePath="..\include\RenderTechniques\OgreSBBRenderTechnique.h"> 283 283 </File> 284 <File 285 RelativePath="..\include\RenderTechniques\OgreTriggersRenderTechnique.h"> 286 </File> 284 287 </Filter> 285 288 <Filter -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreIlluminationManager.cpp
r2333 r2366 5 5 #include "OgrePMEntryPointMapRenderingRun.h" 6 6 #include "OgrePMWeightComputeRenderingRun.h" 7 #include "OgreTriggersRenderTechnique.h" 7 8 8 9 OgreIlluminationManager* OgreIlluminationManager::instance = NULL; … … 120 121 OgrePathMapRenderTechniqueFactory* pathmap = new OgrePathMapRenderTechniqueFactory(); 121 122 addRenderTechniqueFactory(pathmap); 123 OgreTriggersRenderTechniqueFactory* triggers = new OgreTriggersRenderTechniqueFactory(); 124 addRenderTechniqueFactory(triggers); 122 125 } 123 126 … … 262 265 } 263 266 } 264 265 266 267 267 268 SceneManager* sm = Root::getSingleton()._getCurrentSceneManager(); 269 if(OgreRenderingRun::fullScreenQuad) 270 MeshManager::getSingleton().remove("PASS_FULLSCREENQUAD_MESH"); 271 OgreRenderingRun::fullScreenQuad = 0; 272 if(OgreRenderingRun::fullScreenQuadEntity) 273 sm->destroyEntity(OgreRenderingRun::fullScreenQuadEntity); 274 OgreRenderingRun::fullScreenQuadEntity = 0; 275 if(OgreRenderingRun::pixelSprites) 276 sm->destroyBillboardSet(OgreRenderingRun::pixelSprites); 277 OgreRenderingRun::pixelSprites = 0; 278 if(OgreRenderingRun::fullscreenGrid) 279 sm->destroyEntity(OgreRenderingRun::fullscreenGrid); 280 OgreRenderingRun::fullscreenGrid = 0; 268 281 } 269 282 -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderingRun.cpp
r2355 r2366 4 4 MovablePlane* OgreRenderingRun::fullScreenQuad = NULL; 5 5 Entity* OgreRenderingRun::fullScreenQuadEntity = NULL; 6 SceneNode* OgreRenderingRun::fullScreenQuadNode = NULL;7 6 BillboardSet* OgreRenderingRun::pixelSprites = NULL; 8 7 Entity* OgreRenderingRun::fullscreenGrid = NULL; … … 21 20 this->materialName = materialName; 22 21 this->visibleObjects = visibleObjects; 22 triggerName = trigger; 23 23 } 24 24 … … 33 33 if(triggerName != "")//we have a trigger here 34 34 { 35 String triggeredMaterial = 36 ((OgreTechniqueGroup*)rend->getRenderTechniqueGroup()) 37 ->getMaterialNameForTrigger(triggerName); 38 if(triggeredMaterial != "")//a trigger is associated 39 materialToSet = triggeredMaterial; 35 OgreTechniqueGroup* tg = (OgreTechniqueGroup*)rend->getRenderTechniqueGroup(); 36 if(tg) 37 { 38 String triggeredMaterial = tg->getMaterialNameForTrigger(triggerName); 39 if(triggeredMaterial != "")//a trigger is associated 40 materialToSet = triggeredMaterial; 41 } 40 42 } 41 43 rend->setMaterialName(materialToSet); -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreCausticReceiverRenderTechnique.cpp
r2299 r2366 11 11 SceneBlendFactor passBlendingSRC, 12 12 SceneBlendFactor passBlendingDEST, 13 bool createNewPasses, 14 int startTextureUnitID, 15 String casterCenterVariableName, 16 String attenuationVariableName, 13 17 Pass* pass, 14 18 OgreRenderable* parentRenderable, … … 23 27 this->causticVertexProgram = causticVertexProgram; 24 28 this->causticFragmentProgram = causticFragmentProgram; 25 26 //insert new passes 27 Ogre::Technique* techn = pass->getParent(); 28 Technique::PassIterator it = techn->getPassIterator(); 29 30 int index = 0; 31 while(it.hasMoreElements()) 32 { 33 if( it.getNext() == pass) 34 break; 29 this->createNewPasses = createNewPasses; 30 this->startTextureUnitID = startTextureUnitID; 31 this->casterCenterVariableName = casterCenterVariableName; 32 this->attenuationVariableName = attenuationVariableName; 33 34 if(createNewPasses) 35 { 36 //insert new passes 37 Ogre::Technique* techn = pass->getParent(); 38 Technique::PassIterator it = techn->getPassIterator(); 39 40 int index = 0; 41 while(it.hasMoreElements()) 42 { 43 if( it.getNext() == pass) 44 break; 45 index++; 46 it.moveNext(); 47 } 48 35 49 index++; 36 it.moveNext(); 37 } 38 39 index++; 40 for(int i = 0; i < maxcasters; i++) 41 { 42 int lastpass = techn->getNumPasses(); 43 Pass* newpass = techn->createPass(); 44 passes.push_back(newpass); 45 46 newpass->setVertexProgram(causticVertexProgram); 47 newpass->setFragmentProgram(causticFragmentProgram); 48 49 GpuProgramParameters* Vparams = newpass->getVertexProgramParameters().getPointer(); 50 Vparams->setNamedAutoConstant("WorldViewProj", 51 GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX); 52 Vparams->setNamedAutoConstant("World", 53 GpuProgramParameters::ACT_WORLD_MATRIX); 54 GpuProgramParameters* Fparams = newpass->getFragmentProgramParameters().getPointer(); 55 //Fparams->setNamedConstant("cubeMapCameraPosition", Vector3(0,0,0)); 56 57 TextureUnitState* st = newpass->createTextureUnitState(); 58 TextureUnitState* st2 = newpass->createTextureUnitState(); 59 60 st->setTextureFiltering(TFO_BILINEAR); 61 st2->setTextureFiltering(TFO_BILINEAR); 62 63 newpass->setSceneBlending(passBlendingSRC, passBlendingDEST); 64 newpass->setDepthBias(1); 65 66 techn->movePass(lastpass, index); 50 for(int i = 0; i < maxcasters; i++) 51 { 52 int lastpass = techn->getNumPasses(); 53 Pass* newpass = techn->createPass(); 54 passes.push_back(newpass); 55 56 newpass->setVertexProgram(causticVertexProgram); 57 newpass->setFragmentProgram(causticFragmentProgram); 58 59 GpuProgramParameters* Vparams = newpass->getVertexProgramParameters().getPointer(); 60 Vparams->setNamedAutoConstant("WorldViewProj", 61 GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX); 62 Vparams->setNamedAutoConstant("World", 63 GpuProgramParameters::ACT_WORLD_MATRIX); 64 GpuProgramParameters* Fparams = newpass->getFragmentProgramParameters().getPointer(); 65 //Fparams->setNamedConstant("cubeMapCameraPosition", Vector3(0,0,0)); 66 67 TextureUnitState* st = newpass->createTextureUnitState(); 68 TextureUnitState* st2 = newpass->createTextureUnitState(); 69 70 st->setTextureFiltering(TFO_BILINEAR); 71 st2->setTextureFiltering(TFO_BILINEAR); 72 73 newpass->setSceneBlending(passBlendingSRC, passBlendingDEST); 74 newpass->setDepthBias(1); 75 76 techn->movePass(lastpass, index); 77 } 67 78 } 68 79 … … 82 93 &causticCasters, 83 94 maxcasters); 95 84 96 //fill passes 85 for(unsigned int i = 0; i < passes.size(); i++)97 for(unsigned int i = 0; i < maxcasters; i++) 86 98 { 87 99 if(causticCasters.size() > i) 88 100 { 89 90 101 //update caustic caster 91 102 causticCasters.at(i)->updateRun(ILLUMRUN_PHOTONMAP, frameNum); … … 96 107 (OgreCausticCubeMapRenderingRun*) causticCasters.at(i)-> 97 108 getRun(ILLUMRUN_CAUSTIC_CUBEMAP)->asOgreRenderingRun(); 98 passes.at(i)->getTextureUnitState(0)->setTextureName( 109 110 Pass* passToSet = this->pass; 111 int textureUnit = startTextureUnitID + i; 112 if(createNewPasses) 113 { 114 passToSet = passes.at(i); 115 passToSet->setActive(true); 116 textureUnit = 0; 117 } 118 119 passToSet->getTextureUnitState(textureUnit)->setTextureName( 99 120 cauCubeRun->getCausticCubeMapTextureName()); 100 101 OgreCubeMapRenderingRun* distCubeRun = 102 (OgreCubeMapRenderingRun*) causticCasters.at(i)-> 103 getRun(ILLUMRUN_DISTANCE_CUBEMAP)->asOgreRenderingRun(); 104 passes.at(i)->getTextureUnitState(1)->setTextureName( 105 distCubeRun->getCubeMapTextureName()); 106 107 //set caster position 108 GpuProgramParameters* Fparams = passes.at(i)->getFragmentProgramParameters().getPointer(); 109 Fparams->setNamedConstant("cubeMapCameraPosition", 110 causticCasters.at(i)->getRootPosition(ILLUMRUN_CAUSTIC_CUBEMAP)); 111 Fparams->setNamedConstant("attenuation", cauCubeRun->getAttenuation()); 112 passes.at(i)->setActive(true); 121 122 //set caster position nad caustic attenuation 123 GpuProgramParameters* Fparams = passToSet->getFragmentProgramParameters().getPointer(); 124 String centerVarName = casterCenterVariableName; 125 String attenuationVarName = attenuationVariableName; 126 if(!createNewPasses) 127 { 128 centerVarName += String("[") + StringConverter::toString(i) + String("]"); 129 attenuationVarName += String("[") + StringConverter::toString(i) + String("]"); 130 } 131 Fparams->setNamedConstant(centerVarName, 132 causticCasters.at(i)->getRootPosition(ILLUMRUN_CAUSTIC_CUBEMAP)); 133 Fparams->setNamedConstant(attenuationVarName, 134 cauCubeRun->getAttenuation()); 113 135 } 114 else 136 else if(createNewPasses) 115 137 passes.at(i)->setActive(false); 116 117 138 } 118 139 } … … 201 222 f->passBlendingDEST = convertBlendFactor(vecparams[1]) ; 202 223 } 203 } 204 } 224 } 225 226 void parseCreateNewPasses(String& params, RenderTechniqueFactory* factory) 227 { 228 OgreCausticReceiverRenderTechniqueFactory* f = (OgreCausticReceiverRenderTechniqueFactory*) factory; 229 f->createNewPasses = StringConverter::parseBool(params); 230 } 231 232 void parseStartTexID(String& params, RenderTechniqueFactory* factory) 233 { 234 OgreCausticReceiverRenderTechniqueFactory* f = (OgreCausticReceiverRenderTechniqueFactory*) factory; 235 f->startTextureUnitID = StringConverter::parseInt(params); 236 } 237 238 void parseCenterVarName(String& params, RenderTechniqueFactory* factory) 239 { 240 OgreCausticReceiverRenderTechniqueFactory* f = (OgreCausticReceiverRenderTechniqueFactory*) factory; 241 f->casterCenterVariableName = params; 242 } 243 244 void parseAttenuationVarName(String& params, RenderTechniqueFactory* factory) 245 { 246 OgreCausticReceiverRenderTechniqueFactory* f = (OgreCausticReceiverRenderTechniqueFactory*) factory; 247 f->attenuationVariableName = params; 248 } 249 } 250 205 251 OgreCausticReceiverRenderTechniqueFactory::OgreCausticReceiverRenderTechniqueFactory() 206 252 { … … 213 259 this->attributeParsers.insert(AttribParserList::value_type("fragment_program_name", (ILLUM_ATTRIBUTE_PARSER) parseFragmentProgram)); 214 260 this->attributeParsers.insert(AttribParserList::value_type("pass_blending", (ILLUM_ATTRIBUTE_PARSER) parsePassBlending)); 215 261 this->attributeParsers.insert(AttribParserList::value_type("new_passes", (ILLUM_ATTRIBUTE_PARSER) parseCreateNewPasses)); 262 this->attributeParsers.insert(AttribParserList::value_type("start_tex_id", (ILLUM_ATTRIBUTE_PARSER) parseStartTexID)); 263 this->attributeParsers.insert(AttribParserList::value_type("center_var_name", (ILLUM_ATTRIBUTE_PARSER) parseCenterVarName)); 264 this->attributeParsers.insert(AttribParserList::value_type("attenuation_var_name", (ILLUM_ATTRIBUTE_PARSER) parseAttenuationVarName)); 216 265 } 217 266 … … 228 277 passBlendingSRC = SBF_DEST_COLOUR; 229 278 passBlendingDEST = SBF_ONE; 279 createNewPasses = true; 280 startTextureUnitID = 0; 281 casterCenterVariableName = "cubeMapCameraPosition"; 282 String attenuationVariableName = "attenuation"; 230 283 231 284 parseParams(params); … … 237 290 passBlendingSRC, 238 291 passBlendingDEST, 292 createNewPasses, 293 startTextureUnitID, 294 casterCenterVariableName, 295 attenuationVariableName, 239 296 pass, 240 297 parentRenderable, -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDepthShadowReceiverRenderTechnique.cpp
r2355 r2366 18 18 SceneBlendFactor passBlendingSRC, 19 19 SceneBlendFactor passBlendingDEST, 20 bool createNewPasses, 21 int startTextureUnitID, 20 22 Pass* pass, 21 23 OgreRenderable* parentRenderable, … … 38 40 this->WorldParamName = WorldParamName; 39 41 this->WorldViewProjParamName = WorldViewProjParamName; 42 this->createNewPasses = createNewPasses; 43 this->startTextureUnitID = startTextureUnitID; 44 45 if(createNewPasses) 46 { 47 //insert new passes 48 Ogre::Technique* techn = pass->getParent(); 49 Technique::PassIterator it = techn->getPassIterator(); 40 50 41 //insert new passes42 Ogre::Technique* techn = pass->getParent();43 Technique::PassIterator it = techn->getPassIterator();44 45 int index = 0;46 while(it.hasMoreElements())47 {48 if( it.getNext() == pass)49 break;51 int index = 0; 52 while(it.hasMoreElements()) 53 { 54 if( it.getNext() == pass) 55 break; 56 index++; 57 it.moveNext(); 58 } 59 50 60 index++; 51 it.moveNext(); 52 } 53 54 index++; 55 for(int i = 0; i < maxlights; i++) 56 { 57 int lastpass = techn->getNumPasses(); 58 Pass* newpass = techn->createPass(); 59 passes.push_back(newpass); 60 61 TextureUnitState* st = newpass->createTextureUnitState(); 62 st->setTextureFiltering(TFO_NONE); 63 st->setTextureAddressingMode(TextureUnitState::TAM_BORDER); 64 st->setTextureBorderColour(ColourValue::White); 65 66 newpass->setSceneBlending(passBlendingSRC, passBlendingDEST); 67 68 newpass->setDepthBias(1); 69 techn->movePass(lastpass, index); 70 } 71 61 for(int i = 0; i < maxlights; i++) 62 { 63 int lastpass = techn->getNumPasses(); 64 Pass* newpass = techn->createPass(); 65 passes.push_back(newpass); 66 67 TextureUnitState* st = newpass->createTextureUnitState(); 68 st->setTextureFiltering(TFO_NONE); 69 st->setTextureAddressingMode(TextureUnitState::TAM_BORDER); 70 st->setTextureBorderColour(ColourValue::White); 71 72 newpass->setSceneBlending(passBlendingSRC, passBlendingDEST); 73 74 newpass->setDepthBias(1); 75 techn->movePass(lastpass, index); 76 } 77 } 72 78 } 73 79 … … 87 93 //fill passes 88 94 unsigned int l = 0; 89 for(unsigned int i = 0; i < passes.size(); i++)95 for(unsigned int i = 0; i < maxlights; i++) 90 96 { 91 97 while(lights.size() != l && !lights.at(l)->getCastShadows()) … … 108 114 .getPerLightRun(lights.at(l)->getName(), 109 115 ILLUMRUN_DEPTH_SHADOWMAP)->asOgreRenderingRun(); 110 111 passes.at(i)->getTextureUnitState(0)->setTextureName( 116 117 Pass* passToSet = this->pass; 118 int textureUnit = startTextureUnitID + i; 119 if(createNewPasses) 120 { 121 passToSet = passes.at(i); 122 passToSet->setActive(true); 123 textureUnit = 0; 124 passes.at(i)->setActive(true); 125 } 126 passToSet->getTextureUnitState(textureUnit)->setTextureName( 112 127 depthRun->getDepthMapTextureName()); 113 128 114 //TODO: ask programs from illummanager 115 passes.at(i)->setVertexProgram(shadowVertexProgram); 116 passes.at(i)->setFragmentProgram(shadowFragmentProgram); 129 if(createNewPasses) 130 { 131 //TODO: ask programs from illummanager 132 passes.at(i)->setVertexProgram(shadowVertexProgram); 133 passes.at(i)->setFragmentProgram(shadowFragmentProgram); 134 } 117 135 118 GpuProgramParametersSharedPtr fpParams = passes.at(i)->getFragmentProgramParameters(); 119 GpuProgramParametersSharedPtr vpParams = passes.at(i)->getVertexProgramParameters(); 120 121 122 vpParams->setNamedAutoConstant(WorldViewProjParamName, 123 GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX); 124 vpParams->setNamedAutoConstant(WorldParamName, 125 GpuProgramParameters::ACT_WORLD_MATRIX); 136 GpuProgramParametersSharedPtr fpParams = passToSet->getFragmentProgramParameters(); 137 GpuProgramParametersSharedPtr vpParams = passToSet->getVertexProgramParameters(); 138 139 String LightViewProjParamName = lightViewProjParamName; 140 String LightViewParamName = lightViewParamName; 141 String LightFarPlaneParamName = lightFarPlaneParamName; 142 if(!createNewPasses) 143 { 144 LightViewProjParamName += String("[") + StringConverter::toString(i) + String("]"); 145 LightViewParamName += String("[") + StringConverter::toString(i) + String("]"); 146 LightFarPlaneParamName += String("[") + StringConverter::toString(i) + String("]"); 147 } 148 else 149 { 150 vpParams->setNamedAutoConstant(WorldViewProjParamName, 151 GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX); 152 vpParams->setNamedAutoConstant(WorldParamName, 153 GpuProgramParameters::ACT_WORLD_MATRIX); 154 } 126 155 127 156 if(setLightViewProjMatrix) 128 vpParams->setNamedConstant(lightViewProjParamName, depthRun->getLightViewProjMatrix()); 157 { 158 if(createNewPasses) 159 vpParams->setNamedConstant(LightViewProjParamName, depthRun->getLightViewProjMatrix()); 160 else 161 fpParams->setNamedConstant(LightViewProjParamName, depthRun->getLightViewProjMatrix()); 162 } 129 163 if(setLightViewMatrix) 130 vpParams->setNamedConstant(lightViewParamName, depthRun->getLightViewMatrix()); 164 { 165 if(createNewPasses) 166 vpParams->setNamedConstant(LightViewParamName, depthRun->getLightViewMatrix()); 167 else 168 fpParams->setNamedConstant(LightViewParamName, depthRun->getLightViewMatrix()); 169 } 131 170 if(setLightProjFarPlane) 132 fpParams->setNamedConstant(lightFarPlaneParamName, depthRun->getLightFarPlane()); 133 134 135 passes.at(i)->setActive(true); 136 171 { 172 if(createNewPasses) 173 fpParams->setNamedConstant(LightFarPlaneParamName, depthRun->getLightFarPlane()); 174 else 175 fpParams->setNamedConstant(LightFarPlaneParamName, depthRun->getLightFarPlane()); 176 } 137 177 } 138 else 178 else if(createNewPasses) 139 179 passes.at(i)->setActive(false); 140 180 … … 282 322 f->passBlendingDEST = convertBlendFactor(vecparams[1]) ; 283 323 } 284 } 324 } 325 326 void parseCreateNewPasses(String& params, RenderTechniqueFactory* factory) 327 { 328 OgreDepthShadowReceiverRenderTechniqueFactory* f = (OgreDepthShadowReceiverRenderTechniqueFactory*) factory; 329 f->createNewPasses = StringConverter::parseBool(params); 330 } 331 332 void parseStartTexID(String& params, RenderTechniqueFactory* factory) 333 { 334 OgreDepthShadowReceiverRenderTechniqueFactory* f = (OgreDepthShadowReceiverRenderTechniqueFactory*) factory; 335 f->startTextureUnitID = StringConverter::parseInt(params); 336 } 285 337 } 286 338 … … 303 355 this->attributeParsers.insert(AttribParserList::value_type("light_farplane_param_name", (ILLUM_ATTRIBUTE_PARSER) parseLightFarPlaneParamName)); 304 356 this->attributeParsers.insert(AttribParserList::value_type("pass_blending", (ILLUM_ATTRIBUTE_PARSER) parsePassBlending)); 357 this->attributeParsers.insert(AttribParserList::value_type("new_passes", (ILLUM_ATTRIBUTE_PARSER) parseCreateNewPasses)); 358 this->attributeParsers.insert(AttribParserList::value_type("start_tex_id", (ILLUM_ATTRIBUTE_PARSER) parseStartTexID)); 305 359 } 306 360 … … 325 379 passBlendingSRC = SBF_DEST_COLOUR; 326 380 passBlendingDEST = SBF_ZERO; 327 381 createNewPasses = true; 382 startTextureUnitID = 0; 383 328 384 parseParams(params); 329 385 … … 342 398 passBlendingSRC, 343 399 passBlendingDEST, 400 createNewPasses, 401 startTextureUnitID, 344 402 pass, 345 403 parentRenderable, -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgrePathMapRenderTechnique.cpp
r2333 r2366 9 9 SceneBlendFactor passBlendingSRC, 10 10 SceneBlendFactor passBlendingDEST, 11 bool createNewPasses, 12 int startTextureUnitID, 11 13 Pass* pass, 12 14 OgreRenderable* parentRenderable, … … 17 19 this->passBlendingSRC = passBlendingSRC; 18 20 this->passBlendingDEST = passBlendingDEST; 21 this->createNewPasses = createNewPasses; 22 this->startTextureUnitID = startTextureUnitID; 19 23 20 24 this->clusters = OgreIlluminationManager::getSingleton().getPathMapClusters(parentRenderable->getName()); 21 25 26 Pass* passToSet = pass; 27 22 28 //insert new pass 23 Ogre::Technique* techn = pass->getParent(); 24 Technique::PassIterator it = techn->getPassIterator(); 25 26 int index = 0; 27 while(it.hasMoreElements()) 28 { 29 if( it.getNext() == pass) 30 break; 31 index++; 32 it.moveNext(); 33 } 34 35 Pass* newpass = pathMapPass = techn->createPass(); 36 37 newpass->setVertexProgram("GTP/PathMap_VS"); 38 newpass->setFragmentProgram("GTP/PathMap_PS"); 39 40 //bind vertex program parameters 41 GpuProgramParameters* Vparams = newpass->getVertexProgramParameters().getPointer(); 42 Vparams->setNamedAutoConstant("WorldViewProj", GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX); 29 if(createNewPasses) 30 { 31 Ogre::Technique* techn = pass->getParent(); 32 Technique::PassIterator it = techn->getPassIterator(); 33 34 int index = 0; 35 while(it.hasMoreElements()) 36 { 37 if( it.getNext() == pass) 38 break; 39 index++; 40 it.moveNext(); 41 } 42 43 Pass* newpass = pathMapPass = passToSet = techn->createPass(); 44 45 newpass->setVertexProgram("GTP/PathMap_VS"); 46 newpass->setFragmentProgram("GTP/PathMap_PS"); 47 48 GpuProgramParameters* Vparams = passToSet->getVertexProgramParameters().getPointer(); 49 Vparams->setNamedAutoConstant("WorldViewProj", GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX); 50 } 51 43 52 //bind fragment program parameters 44 GpuProgramParameters* Fparams = newpass->getFragmentProgramParameters().getPointer(); 53 GpuProgramParameters* Fparams = passToSet->getFragmentProgramParameters().getPointer(); 54 45 55 int prmxres = clusters->pathMapResolution * clusters->count; 46 56 int prmyres = clusters->pathMapResolution; … … 55 65 Vector4 pathMapParameters(prmnt[0],prmnt[1],halfPixel[0],halfPixel[1]); 56 66 Fparams->setNamedConstant("prmAtlasTilesHalfPixel",pathMapParameters); 57 67 58 68 unsigned int clustercount = OgreIlluminationManager::getSingleton().getPathMapClusterLengthsSize(); 59 69 Fparams->setNamedConstant("allClusterCount", (float) clustercount); … … 61 71 Fparams->setNamedConstant("clusterCount", (float) clusters->count); 62 72 63 TextureUnitState* st = newpass->createTextureUnitState(); 64 st->setTextureFiltering(TFO_BILINEAR); 65 st->setTextureAddressingMode(TextureUnitState::TAM_CLAMP); 66 st->setTextureBorderColour(ColourValue::Green); 67 st->setTextureName(clusters->pathMapTextureFilename); 68 73 TextureUnitState* st1;//path map texture 74 TextureUnitState* st2;//weight index texture 75 TextureUnitState* st3;//weight texture 76 69 77 createWeightIndexTexture(); 70 78 71 st = newpass->createTextureUnitState(); 72 st->setTextureFiltering(TFO_NONE); 73 st->setTextureAddressingMode(TextureUnitState::TAM_CLAMP); 74 st->setTextureBorderColour(ColourValue::Red); 75 st->setTextureName(weightIndexTexture->getName()); 76 77 st = newpass->createTextureUnitState(); 78 st->setTextureFiltering(TFO_NONE); 79 st->setTextureAddressingMode(TextureUnitState::TAM_CLAMP); 80 st->setTextureBorderColour(ColourValue::Blue); 81 82 st = newpass->createTextureUnitState(); 83 st->setTextureFiltering(TFO_BILINEAR); 84 st->setTextureAddressingMode(TextureUnitState::TAM_WRAP); 85 st->setTextureBorderColour(ColourValue::Blue); 86 st->setTextureName(pass->getTextureUnitState(0)->getTextureName()); 87 88 newpass->setSceneBlending(passBlendingSRC, passBlendingDEST); 89 newpass->setDepthBias(1); 79 if(createNewPasses) 80 { 81 st1 = passToSet->createTextureUnitState(); 82 st1->setTextureFiltering(TFO_BILINEAR); 83 st1->setTextureAddressingMode(TextureUnitState::TAM_CLAMP); 84 st1->setTextureBorderColour(ColourValue::Green); 85 86 st2 = passToSet->createTextureUnitState(); 87 st2->setTextureFiltering(TFO_NONE); 88 st2->setTextureAddressingMode(TextureUnitState::TAM_CLAMP); 89 st2->setTextureBorderColour(ColourValue::Red); 90 91 st3 = passToSet->createTextureUnitState(); 92 st3->setTextureFiltering(TFO_NONE); 93 st3->setTextureAddressingMode(TextureUnitState::TAM_CLAMP); 94 st3->setTextureBorderColour(ColourValue::Blue); 95 96 TextureUnitState* st4 = passToSet->createTextureUnitState(); 97 st4->setTextureFiltering(TFO_BILINEAR); 98 st4->setTextureAddressingMode(TextureUnitState::TAM_WRAP); 99 st4->setTextureBorderColour(ColourValue::Blue); 100 st4->setTextureName(pass->getTextureUnitState(0)->getTextureName()); 101 102 passToSet->setSceneBlending(passBlendingSRC, passBlendingDEST); 103 passToSet->setDepthBias(1); 104 } 105 else 106 { 107 st1 = pass->getTextureUnitState(startTextureUnitID); 108 st2 = pass->getTextureUnitState(startTextureUnitID + 1); 109 st3 = pass->getTextureUnitState(startTextureUnitID + 2); 110 } 111 st1->setTextureName(clusters->pathMapTextureFilename); 112 st2->setTextureName(weightIndexTexture->getName()); 90 113 } 91 114 … … 131 154 } 132 155 OgrePMWeightComputeRenderingRun::sumWeights(frameNum); 133 TextureUnitState* st = pathMapPass->getTextureUnitState(2); 156 157 Pass* passToSet = pass; 158 int textureUnitID = startTextureUnitID + 2; 159 if(createNewPasses) 160 { 161 passToSet = pathMapPass; 162 textureUnitID = 2; 163 } 164 TextureUnitState* st = passToSet->getTextureUnitState(textureUnitID); 134 165 st->setTextureName(OgrePMWeightComputeRenderingRun::getPMWeightTextureName()); 135 166 } … … 200 231 f->passBlendingDEST = convertBlendFactor(vecparams[1]) ; 201 232 } 202 } 233 } 234 235 void parseCreateNewPasses(String& params, RenderTechniqueFactory* factory) 236 { 237 OgrePathMapRenderTechniqueFactory* f = (OgrePathMapRenderTechniqueFactory*) factory; 238 f->createNewPasses = StringConverter::parseBool(params); 239 } 240 241 void parseStartTexID(String& params, RenderTechniqueFactory* factory) 242 { 243 OgrePathMapRenderTechniqueFactory* f = (OgrePathMapRenderTechniqueFactory*) factory; 244 f->startTextureUnitID = StringConverter::parseInt(params); 245 } 203 246 } 204 247 … … 208 251 using namespace PathMapParsers; 209 252 this->attributeParsers.insert(AttribParserList::value_type("pass_blending", (ILLUM_ATTRIBUTE_PARSER) parsePassBlending)); 253 this->attributeParsers.insert(AttribParserList::value_type("new_passes", (ILLUM_ATTRIBUTE_PARSER) parseCreateNewPasses)); 254 this->attributeParsers.insert(AttribParserList::value_type("start_tex_id", (ILLUM_ATTRIBUTE_PARSER) parseStartTexID)); 210 255 } 211 256 … … 218 263 passBlendingSRC = SBF_ONE; 219 264 passBlendingDEST = SBF_ONE; 265 createNewPasses = true; 266 startTextureUnitID = 0; 220 267 221 268 parseParams(params); … … 224 271 passBlendingSRC, 225 272 passBlendingDEST, 273 createNewPasses, 274 startTextureUnitID, 226 275 pass, 227 276 parentRenderable, -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp
r2363 r2366 96 96 void OgreDepthShadowMapRenderingRun::updateDepthCubeFace(int facenum) 97 97 { 98 String triggerName = "ILLUM_TRIGGER_SM_POINT"; 99 98 100 Vector3 lightpos = light->getDerivedPosition(); 99 101 … … 103 105 cam->setFarClipDistance(lightFarPlane); 104 106 105 setMaterialForVisibles(materialName, cam, false);107 setMaterialForVisibles(materialName, cam, true, false, triggerName); 106 108 rt->update(); 107 109 restoreMaterials(); … … 132 134 case Light::LT_SPOTLIGHT: 133 135 triggerName = "ILLUM_TRIGGER_SM_SPOT"; 134 break; 135 case Light::LT_POINT: 136 triggerName = "ILLUM_TRIGGER_SM_POINT"; 137 break; 136 break; 138 137 } 139 138 setMaterialForVisibles(materialName, depthMapCamera, true, false, triggerName);
Note: See TracChangeset
for help on using the changeset viewer.