Changeset 1055 for GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src
- Timestamp:
- 06/26/06 09:52:08 (19 years ago)
- Location:
- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src
- Files:
-
- 4 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreIlluminationManager.cpp
r949 r1055 79 79 visitor = new VisibleFinderVisitor(&visibleObjects); 80 80 maxRad = 400; 81 82 for(int i = 0; i < RUN_TYPE_COUNT; i++) 83 { 84 maxRads[(RenderingRunType)i] = (float) maxRad; 85 } 81 86 82 87 //register rendertechnique factories … … 95 100 OgreSBBRenderTechniqueFactory* sbb = new OgreSBBRenderTechniqueFactory(); 96 101 addRenderTechniqueFactory(sbb); 102 OgreFireRenderTechniqueFactory* fire = new OgreFireRenderTechniqueFactory(); 103 addRenderTechniqueFactory(fire); 97 104 } 98 105 … … 160 167 void OgreIlluminationManager::initTechniques(Entity* e) 161 168 { 169 if( e->getParentSceneNode() == 0 )//Entity not attached 170 return; 171 162 172 OgreSharedRuns* sharedruns = 0; 163 173 … … 215 225 } 216 226 227 228 void OgreIlluminationManager::initTechniques(BillboardSet* bbs, ParticleSystem* sys) 229 { 230 if( bbs->getParentSceneNode() == 0 )//billboardset not attached 231 return; 232 233 OgreSharedRuns* sharedruns = 0; 234 235 Material* mat = bbs->getMaterial().getPointer(); 236 237 OgreRenderable* rend = 0; 238 OgreTechniqueGroup* group = 0; 239 240 for(unsigned int t = 0 ; t < mat->getNumTechniques() ; t++) 241 { 242 Technique* tech = mat->getTechnique(t); 243 244 for(unsigned int p = 0; p< tech->getNumPasses(); p++) 245 { 246 Pass* pass = tech->getPass(p); 247 248 std::vector<IllumTechniqueParams*>& techniques = pass->getIllumTechniques(); 249 std::vector<IllumTechniqueParams*>::iterator i = techniques.begin(); 250 std::vector<IllumTechniqueParams*>::iterator iend = techniques.end(); 251 252 while( i != iend) 253 { 254 IllumTechniqueParams* params = *i; 255 256 if(rend == 0) 257 { 258 rend = new OgreRenderable(bbs, sys); 259 group = new OgreTechniqueGroup(); 260 bbs->setRenderTechniqueGroup(group); 261 262 if( sharedruns == 0) 263 { 264 sharedruns = new OgreSharedRuns(); 265 addSharedRuns(sharedruns); 266 } 267 268 group->addSharedRun(sharedruns); 269 sharedruns->addRenderable(rend); 270 sharedruns->updateBounds(); 271 } 272 273 createTechnique(params, pass, rend, sharedruns); 274 275 i++; 276 } 277 } 278 } 279 280 } 281 217 282 void OgreIlluminationManager::initTechniques() 218 283 { … … 225 290 MovableObject* o = it.getNext(); 226 291 Entity* e = (Entity*) o; 227 228 /* OgreSharedRuns* sharedruns = 0; 229 230 for(unsigned int s = 0; s < e->getNumSubEntities(); s++) 231 { 232 SubEntity* sube = e->getSubEntity(s); 233 234 Material* mat = sube->getMaterial().getPointer(); 235 236 OgreRenderable* rend = 0; 237 OgreTechniqueGroup* group = 0; 238 239 for(unsigned int t = 0 ; t < mat->getNumTechniques() ; t++) 240 { 241 Technique* tech = mat->getTechnique(t); 242 243 for(unsigned int p = 0; p< tech->getNumPasses(); p++) 244 { 245 Pass* pass = tech->getPass(p); 246 247 std::vector<IllumTechniqueParams*>& techniques = pass->getIllumTechniques(); 248 std::vector<IllumTechniqueParams*>::iterator i = techniques.begin(); 249 std::vector<IllumTechniqueParams*>::iterator iend = techniques.end(); 250 251 while( i != iend) 252 { 253 IllumTechniqueParams* params = *i; 254 255 if(rend == 0) 256 { 257 rend = new OgreRenderable(e, s); 258 group = new OgreTechniqueGroup(); 259 sube->setRenderTechniqueGroup(group); 260 261 if( sharedruns == 0) 262 { 263 sharedruns = new OgreSharedRuns(); 264 addSharedRuns(sharedruns); 265 } 266 267 group->addSharedRun(sharedruns); 268 sharedruns->addRenderable(rend); 269 sharedruns->updateBounds(); 270 } 271 272 createTechnique(params, pass, rend, sharedruns); 273 274 i++; 275 } 276 } 277 } 278 } 279 280 */ 292 281 293 initTechniques(e); 282 294 } … … 290 302 MovableObject* o = it.getNext(); 291 303 ParticleSystem* psys = (ParticleSystem*) o; 292 293 BillboardSet* bbset = findRenderableInParticleSystem(psys); 294 295 OgreTechniqueGroup* group = 0; 296 OgreSharedRuns* sharedruns = 0; 297 OgreRenderable* rend = 0; 298 299 String matName = psys->getMaterialName(); 300 Material* mat = (Material*) MaterialManager::getSingleton().getByName(matName).getPointer(); 301 302 for(unsigned int t = 0 ; t < mat->getNumTechniques() ; t++) 304 305 try 303 306 { 304 Technique* tech = mat->getTechnique(t); 305 306 for(unsigned int p = 0; p< tech->getNumPasses(); p++) 307 { 308 Pass* pass = tech->getPass(p); 309 310 std::vector<IllumTechniqueParams*>& techniques = pass->getIllumTechniques(); 311 std::vector<IllumTechniqueParams*>::iterator i = techniques.begin(); 312 std::vector<IllumTechniqueParams*>::iterator iend = techniques.end(); 313 314 315 while( i != iend) 316 { 317 IllumTechniqueParams* params = *i; 318 319 if(rend == 0) 320 { 321 rend = new OgreRenderable(bbset); 322 group = new OgreTechniqueGroup(); 323 bbset->setRenderTechniqueGroup(group); 324 325 if( sharedruns == 0) 326 { 327 sharedruns = new OgreSharedRuns(); 328 addSharedRuns(sharedruns); 329 } 330 331 group->addSharedRun(sharedruns); 332 sharedruns->addRenderable(rend); 333 sharedruns->updateBounds(); 334 } 335 336 createTechnique(params, pass, rend, sharedruns); 337 338 i++; 339 } 340 } 307 BillboardSet* bbset = findRenderableInParticleSystem(psys); 308 bbset->setMaterialName(psys->getMaterialName()); 309 initTechniques(bbset, psys); 341 310 } 342 343 311 catch( ... ) 312 { 313 //unsupported particle renderer, skip init 314 } 344 315 } 345 316 } … … 371 342 } 372 343 344 it++; 345 } 346 } 347 void OgreIlluminationManager::preAllUpdates() 348 { 349 std::vector<UpdateListener*>::iterator it = updateListeners.begin(); 350 std::vector<UpdateListener*>::iterator itend = updateListeners.end(); 351 352 while(it != itend) 353 { 354 UpdateListener* l = *it; 355 l->preAllUpdates(); 356 it++; 357 } 358 } 359 360 void OgreIlluminationManager::postAllUpdates() 361 { 362 std::vector<UpdateListener*>::iterator it = updateListeners.begin(); 363 std::vector<UpdateListener*>::iterator itend = updateListeners.end(); 364 365 while(it != itend) 366 { 367 UpdateListener* l = *it; 368 l->postAllUpdates(); 373 369 it++; 374 370 } … … 406 402 std::vector<const Renderable*>::iterator iter = visibleObjects.begin(); 407 403 const std::vector<const Renderable*>::iterator iend = visibleObjects.end(); 404 405 preAllUpdates(); 408 406 409 407 while(iter != iend) … … 418 416 } 419 417 418 postAllUpdates(); 419 420 420 } 421 421 } … … 448 448 while(it2 != itend) 449 449 { 450 if( *it1 != *it2 && OgreSharedRuns::canJoin(*it1, *it2))450 if( it1 != it2 && OgreSharedRuns::canJoin(*it1, *it2)) 451 451 { 452 452 SharedRuns* newruns = (*it1)->joinRuns(*it2); … … 513 513 } 514 514 515 516 515 517 RenderingRun* OgreIlluminationManager::getGlobalRun(RenderingRunType runType) 516 518 { 517 519 return globalSharedRuns.getRun(runType); 520 } 521 522 GlobalUseRenderTarget* OgreIlluminationManager::getGlobalTarget(GlobalTargetType type) 523 { 524 std::map<GlobalTargetType, GlobalUseRenderTarget*>::iterator it = globalTargets.find(type); 525 526 if( it != globalTargets.end()) 527 return (*it).second; 528 529 return 0; 530 } 531 532 void OgreIlluminationManager::addGlobalTarget(GlobalTargetType type, GlobalUseRenderTarget* target) 533 { 534 globalTargets[type] = target; 518 535 } 519 536 … … 545 562 lightName + "DEPTH_SHADOW_MAP", 546 563 sm->getLight(lightName), 547 2048, //TODO548 2048, //TODO564 512, //TODO 565 512, //TODO 549 566 "GameTools/ShadowMapDepth" //TODO 550 567 ); -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderable.cpp
r790 r1055 29 29 } 30 30 31 OgreRenderable::OgreRenderable(BillboardSet* billboardset )31 OgreRenderable::OgreRenderable(BillboardSet* billboardset, ParticleSystem* sys) 32 32 { 33 33 renderableType = OGRE_RENDERABLETYPE_BILLBOARDSET; 34 34 billboardSetRenderable = billboardset; 35 parentParticleSystem = sys; 35 36 updateBounds(); 36 37 name = billboardset->getName(); … … 47 48 { 48 49 case OGRE_RENDERABLETYPE_SUBENTITY: 49 subEntityRenderable->setVisible(visible); 50 // subEntityRenderable->setVisible(visible); 51 parentEntity->setVisible(visible); 50 52 break; 51 53 case OGRE_RENDERABLETYPE_BILLBOARDSET: 52 billboardSetRenderable->setVisible(visible); 54 if(parentParticleSystem != 0) 55 parentParticleSystem->setVisible(visible); 56 else 57 billboardSetRenderable->setVisible(visible); 53 58 break; 54 59 default: -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderingRun.cpp
r808 r1055 214 214 int resolutionX = width; 215 215 int resolutionY = height; 216 pixelSprites = new SpriteSet(spriteSetName, resolutionX * resolutionY, true);216 pixelSprites = new BillboardSet(spriteSetName, resolutionX * resolutionY, true); 217 217 pixelSprites->setBillboardsInWorldSpace(true); 218 pixelSprites->setCullIndividually(false); 219 pixelSprites->setDefaultDimensions(1.0 / (float) resolutionX, 1.0 / resolutionY); 218 pixelSprites->setCullIndividually(false); 219 pixelSprites->setPointRenderingEnabled(true); 220 //pixelSprites->setDefaultDimensions(1.0 / (float) resolutionX, 1.0 / resolutionY); 220 221 pixelSprites->beginBillboards(); 221 222 for(int i = 0; i < resolutionX; i++) … … 223 224 for(int j = 0; j < resolutionY; j++) 224 225 { 225 Billboard bb ;226 227 bb.setPosition(228 ( (float)i + 0.5 )/ (float) resolutionX, //position x 229 ( (float)j + 0.5 )/ (float) resolutionY, //position y230 0); //position z226 Billboard bb( Vector3( 227 ( (float)i + 0.5 )/ (float) resolutionX, //position x 228 ( (float)j + 0.5 )/ (float) resolutionY, //position y 229 0), 230 pixelSprites); 231 bb.setDimensions(1.0 / (float) resolutionX, 1.0 / resolutionY); 231 232 pixelSprites->injectBillboard(bb); 232 233 } -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreSharedRuns.cpp
r949 r1055 1 1 #include "..\include\OgreSharedRuns.h" 2 2 #include "OgreIlluminationManager.h" 3 4 void OgreSharedRuns::runChanged(RenderingRunType runType, RenderingRun* run) 5 { 6 if(child1 != 0) child1->runChanged(runType, run); 7 if(child2 != 0) child2->runChanged(runType, run); 8 9 std::vector<TechniqueGroup*>::iterator it = childTechniqueGroups.begin(); 10 std::vector<TechniqueGroup*>::iterator itend = childTechniqueGroups.end(); 11 12 while(it != itend) 13 { 14 (*it)->runChanged(runType, run); 15 it++; 16 } 17 } 18 19 void OgreSharedRuns::runUpdated(RenderingRunType runType, RenderingRun* run) 20 { 21 if(child1 != 0) child1->runUpdated(runType, run); 22 if(child2 != 0) child2->runUpdated(runType, run); 23 24 25 std::vector<TechniqueGroup*>::iterator it = childTechniqueGroups.begin(); 26 std::vector<TechniqueGroup*>::iterator itend = childTechniqueGroups.end(); 27 28 while(it != itend) 29 { 30 (*it)->runUpdated(runType, run); 31 it++; 32 } 33 } 3 34 4 35 RenderingRun* OgreSharedRuns::getRun(RenderingRunType runType) … … 108 139 { 109 140 runChanged( (*it).first, (*it).second ); 110 runChanged( (*it).first, (*it).second );111 141 it++; 112 142 } … … 135 165 } 136 166 137 bool OgreSharedRuns::haveCommonRuns(SharedRuns* r1, SharedRuns* r2 )167 bool OgreSharedRuns::haveCommonRuns(SharedRuns* r1, SharedRuns* r2, std::vector<RenderingRunType>& commonruns) 138 168 { 139 169 OgreSharedRuns* run1 = (OgreSharedRuns*) r1; … … 143 173 std::map<RenderingRunType, RenderingRun*>::iterator itend = run1->sharedRuns.end(); 144 174 175 bool returnvalue = false; 145 176 while(it != itend) 146 177 { 147 178 if( run2->hasOwnRun((*it).first)) 148 return true; 149 it++; 150 } 151 152 return false; 179 { 180 if( run1->getRun((*it).first)->asOgreRenderingRun()-> 181 canJoin( run2->getRun((*it).first)->asOgreRenderingRun() ) 182 ) 183 { 184 returnvalue = true; 185 commonruns.push_back((*it).first); 186 } 187 } 188 it++; 189 } 190 191 return returnvalue; 153 192 } 154 193 155 194 bool OgreSharedRuns::canJoin(SharedRuns* r1, SharedRuns* r2) 156 195 { 196 std::vector<RenderingRunType> commonruns; 157 197 //check if they have common resources 158 if(!haveCommonRuns(r1, r2 ))198 if(!haveCommonRuns(r1, r2, commonruns)) 159 199 return false; 160 200 201 float MAXRAD = 0xffffffff; 161 202 //check bounds 162 float MAXRAD = OgreIlluminationManager::getSingleton().getMaxJoinRadius(); 203 for(int i = 0; i < commonruns.size(); i++) 204 { 205 206 RenderingRunType type = commonruns.at(i); 207 float marad = OgreIlluminationManager::getSingleton().getMaxJoinRadius(type); 208 209 MAXRAD = std::min(MAXRAD, marad); 210 } 163 211 164 212 Sphere bSphere1 = ((OgreSharedRuns*) r1)->getBoundingSphere(); -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreCausticCasterRenderTechnique.cpp
r949 r1055 15 15 bool updateAllFace, 16 16 bool useDistance, 17 float attenuation, 17 18 Pass* pass, 18 19 OgreRenderable* parentRenderable, … … 22 23 RenderTechnique( parentRenderable, parentTechniqueGroup) 23 24 { 25 this->attenuation = attenuation; 24 26 this->photonMapMaterialName = photonMapMaterialName; 25 27 … … 103 105 causticMapMaterialName, 104 106 photonMapTexID, 105 updateAllFace 107 updateAllFace, 108 attenuation 106 109 ); 107 110 … … 185 188 OgreCausticCasterRenderTechniqueFactory* f = (OgreCausticCasterRenderTechniqueFactory*) factory; 186 189 f->causticMapMaterialName = params; 190 } 191 192 void parseAttenuation(String& params, RenderTechniqueFactory* factory) 193 { 194 OgreCausticCasterRenderTechniqueFactory* f = (OgreCausticCasterRenderTechniqueFactory*) factory; 195 f->attenuation = StringConverter::parseReal(params); 187 196 } 188 197 } … … 206 215 this->attributeParsers.insert(AttribParserList::value_type("distance_impostor", (ILLUM_ATTRIBUTE_PARSER) parseUseDistance)); 207 216 this->attributeParsers.insert(AttribParserList::value_type("update_all_face", (ILLUM_ATTRIBUTE_PARSER) parseUpdateAllFace)); 208 217 this->attributeParsers.insert(AttribParserList::value_type("attenuation", (ILLUM_ATTRIBUTE_PARSER) parseAttenuation)); 218 209 219 } 210 220 … … 216 226 { 217 227 //reset parameters 228 attenuation = 1.0; 218 229 startFrame = 1; 219 230 photonMapUpdateInterval = 1; … … 237 248 photonMapTexID, 238 249 updateAllFace, 239 useDistance, 250 useDistance, 251 attenuation, 240 252 pass, 241 253 parentRenderable, -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreCausticRecieverRenderTechnique.cpp
r949 r1055 106 106 Fparams->setNamedConstant("cubeMapCameraPosition", 107 107 causticCasters.at(i)->getRootPosition(ILLUMRUN_CAUSTIC_CUBEMAP)); 108 Fparams->setNamedConstant("attenuation", cauCubeRun->getAttenuation()); 108 109 passes.at(i)->setActive(true); 109 110 } … … 135 136 f->causticFragmentProgram = params; 136 137 } 138 137 139 } 138 140 OgreCausticRecieverRenderTechniqueFactory::OgreCausticRecieverRenderTechniqueFactory() … … 145 147 this->attributeParsers.insert(AttribParserList::value_type("vertex_program_name", (ILLUM_ATTRIBUTE_PARSER) parseVertexProgram)); 146 148 this->attributeParsers.insert(AttribParserList::value_type("fragment_program_name", (ILLUM_ATTRIBUTE_PARSER) parseFragmentProgram)); 149 147 150 } 148 151 -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDepthShadowRecieverRenderTechnique.cpp
r949 r1055 52 52 TextureUnitState* st = newpass->createTextureUnitState(); 53 53 st->setTextureFiltering(TFO_BILINEAR); 54 st = newpass->createTextureUnitState(); 55 st->setTextureFiltering(TFO_BILINEAR); 54 56 55 57 newpass->setSceneBlending(SBT_MODULATE); 56 newpass->setDepthBias( 5);58 newpass->setDepthBias(7); 57 59 techn->movePass(lastpass, index); 58 60 } … … 93 95 94 96 passes.at(i)->getTextureUnitState(0)->setTextureName( 95 depthRun->getDepthMapTextureName()); 97 depthRun->getDepthMapTextureName(0)); 98 passes.at(i)->getTextureUnitState(1)->setTextureName( 99 depthRun->getDepthMapTextureName(1)); 96 100 97 101 //TODO: set matrices 98 102 GpuProgramParametersSharedPtr fpParams = passes.at(i)->getFragmentProgramParameters(); 99 fpParams->setNamedConstant("lightView", depthRun->getLightViewMatrix()); 100 fpParams->setNamedConstant("lightViewProj", depthRun->getLightViewProjMatrix()); 103 fpParams->setNamedConstant("lightView", depthRun->getLightViewMatrix(0)); 104 fpParams->setNamedConstant("lightViewProj", depthRun->getLightViewProjMatrix(0)); 105 fpParams->setNamedConstant("lightView2", depthRun->getLightViewMatrix(1)); 106 fpParams->setNamedConstant("lightViewProj2", depthRun->getLightViewProjMatrix(1)); 101 107 102 108 passes.at(i)->setActive(true); -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreSBBRenderTechnique.cpp
r874 r1055 13 13 { 14 14 this->depthTexID = depthTexID; 15 OgreIlluminationManager::getSingleton().createGlobalRun(ILLUMRUN_SCENE_CAMERA_DEPTH);16 15 16 OgreIlluminationManager::getSingleton().createGlobalRun(ILLUMRUN_SCENE_CAMERA_DEPTH); 17 17 18 18 OgreSceneCameraDepthRenderingRun* run = (OgreSceneCameraDepthRenderingRun*) 19 19 OgreIlluminationManager::getSingleton().getGlobalRun(ILLUMRUN_SCENE_CAMERA_DEPTH)->asOgreRenderingRun(); 20 21 Root::getSingleton().addFrameListener(this); 22 OgreIlluminationManager::getSingleton().getMainViewport() 23 ->getTarget()->addListener(this); 24 OgreIlluminationManager::getSingleton().addUpdateListener(this); 20 25 21 26 pass->getTextureUnitState(depthTexID)->setTextureName(run->getDepthTextureName()); 22 27 28 } 29 30 void OgreSBBRenderTechnique::preAllUpdates() 31 { 32 lastVisibility = parentOgreRenderable->isVisible(); 33 parentOgreRenderable->setVisible(false); 34 } 35 void OgreSBBRenderTechnique::preRenderTargetUpdate (const RenderTargetEvent &evt) 36 { 37 //parentOgreRenderable->setVisible(lastVisibility); 38 } 39 void OgreSBBRenderTechnique::postRenderTargetUpdate (const RenderTargetEvent &evt) 40 { 41 //parentOgreRenderable->setVisible(false); 42 } 43 bool OgreSBBRenderTechnique::frameEnded (const FrameEvent &evt) 44 { 45 46 return true; 47 } 48 void OgreSBBRenderTechnique::postAllUpdates() 49 { 50 parentOgreRenderable->setVisible(lastVisibility); 23 51 } 24 52 -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreCausticCubeMapRenderingRun.cpp
r949 r1055 12 12 String materialName, 13 13 unsigned char photonMapTexId, 14 bool updateAllFace) 14 bool updateAllFace, 15 float attenuation) 15 16 :CausticCubeMapRenderingRun(startFrame, updateInterval, resolution, updateAllFace) 16 17 , OgreRenderingRun(startFrame, updateInterval) 17 18 , RenderingRun(startFrame, updateInterval) 18 19 { 20 this->attenuation = attenuation; 19 21 this->sharedRuns = sharedRuns; 20 22 this->name = name; -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp
r874 r1055 1 1 #include "OgreDepthShadowMapRenderingRun.h" 2 #include "OgreIlluminationManager.h" 2 3 3 4 … … 15 16 this->light = light; 16 17 this->sharedRuns = sharedRuns; 17 this->name = name; 18 names[0] = name + "1"; 19 names[1] = name + "2"; 18 20 this->materialName = materialName; 19 21 … … 23 25 void OgreDepthShadowMapRenderingRun::createDepthMap() 24 26 { 25 TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name, 26 "default", 27 TEX_TYPE_2D, 28 resolutionX, 29 resolutionY, 30 0, 31 0, 32 PF_FLOAT16_RGBA, 33 TU_RENDERTARGET); 34 depthMapTexture = texPtr.getPointer(); 35 depthMapCamera = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_CAMERA"); 36 //add viewport to rendertarget 37 HardwarePixelBuffer* hpb = (depthMapTexture->getBuffer()).getPointer(); 38 RenderTarget* rt = hpb->getRenderTarget(); 39 Viewport* v = rt->addViewport(depthMapCamera); 40 v->setOverlaysEnabled(false); 41 rt->setAutoUpdated(false); 27 for(int i = 0; i < 2; i++) 28 { 29 TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(names[i], 30 "default", 31 TEX_TYPE_2D, 32 resolutionX, 33 resolutionY, 34 0, 35 0, 36 PF_FLOAT16_RGBA, 37 TU_RENDERTARGET); 38 depthMapTextures[i] = texPtr.getPointer(); 39 depthMapCameras[i] = Root::getSingleton()._getCurrentSceneManager()->createCamera(names[i] + "_CAMERA"); 40 //add viewport to rendertarget 41 HardwarePixelBuffer* hpb = (depthMapTextures[i]->getBuffer()).getPointer(); 42 RenderTarget* rt = hpb->getRenderTarget(); 43 Viewport* v = rt->addViewport(depthMapCameras[i]); 44 v->setOverlaysEnabled(false); 45 rt->setAutoUpdated(false); 46 } 42 47 } 43 48 … … 64 69 void OgreDepthShadowMapRenderingRun::updateDepthMap() 65 70 { 66 setMaterialForVisibles(materialName, depthMapCamera, true); 67 68 RenderTarget* rt = depthMapTexture->getBuffer().getPointer()->getRenderTarget(); 69 70 SceneManager* sm = Root::getSingleton()._getCurrentSceneManager(); 71 72 rt->update(); 73 74 //rt->writeContentsToFile("shadowmap.dds"); 75 71 setMaterialForVisibles(materialName, depthMapCameras[0], true); 72 RenderTarget* rt = depthMapTextures[0]->getBuffer().getPointer()->getRenderTarget(); 73 rt->update(); 74 //restoreMaterials(); 75 //rt->writeContentsToFile("shadowmap1.dds"); 76 77 //setMaterialForVisibles(materialName, depthMapCameras[1], true); 78 RenderTarget* rt2 = depthMapTextures[1]->getBuffer().getPointer()->getRenderTarget(); 79 rt2->update(); 76 80 restoreMaterials(); 81 //rt2->writeContentsToFile("shadowmap2.dds"); 82 83 84 } 85 86 void setnear() 87 { 88 77 89 } 78 90 … … 84 96 if(light->getType() == Light::LT_DIRECTIONAL) 85 97 { 86 Vector3 dir = light->getDirection(); 87 depthMapCamera->setDirection( dir ); 98 //Vector3 dir = light->getDirection(); 99 Vector3 dir = Vector3(0,-1,-1); 100 Vector3 pos; 101 float size; 102 103 Camera* viewcam = OgreIlluminationManager::getSingleton().getMainCamera(); 104 105 //Matrix4 camView = viewcam->getViewMatrix(); 106 //Matrix4 camViewI = camView.inverse(); 107 //const AxisAlignedBox bt = viewcam->getWorldBoundingBox(true); 108 //AxisAlignedBox b = bt; 109 //b.transform(camView); 110 //SceneManager* sm = Root::getSingleton()._getCurrentSceneManager(); 111 //SceneNode* node = sm->getRootSceneNode(); 112 //const AxisAlignedBox bs(-35,-5 ,-75, 35, 15, 75);// = node->_getWorldAABB(); 113 //AxisAlignedBox intersection = b.intersection(bs); 114 //pos = intersection.getCenter(); 115 //size = (intersection.getMaximum() - pos).length(); 116 88 117 //TODO: where to put light 89 depthMapCamera->setPosition( - dir * 100000 ); 90 depthMapCamera->setProjectionType(PT_ORTHOGRAPHIC); 118 size = 30; 119 pos = Vector3(0,0,0); 120 121 depthMapCameras[0]->setDirection( dir ); 122 pos = pos - size * dir; 123 depthMapCameras[0]->setPosition( pos ); 124 depthMapCameras[0]->setProjectionType(PT_ORTHOGRAPHIC); 125 Matrix4 fproj; 126 fproj = depthMapCameras[0]->getProjectionMatrix(); 127 fproj = Matrix4::IDENTITY; 128 fproj.setScale(Vector3(1.0/20, 1.0/25, -1.0/100)); 129 //fproj.setTrans(Vector3(0,0,-50)); 130 depthMapCameras[0]->setCustomProjectionMatrix(true,fproj); 131 132 133 //camera2 134 dir.normalise(); 135 size = abs(dir.crossProduct(Vector3(0,0,1)).length() * 2); 136 Vector3 viewDir = viewcam->getDirection(); 137 float y = viewDir.y; 138 viewDir.y = std::min(0.0f, y); 139 viewDir.normalise(); 140 Vector3 down(0,-1,0); 141 float cosA = viewDir.dotProduct(down); 142 Vector3 newDir = viewDir + down * 0.4; 143 newDir.normalise(); 144 pos = viewcam->getPosition(); 145 size *= pos.y * 0.5 + 1; 146 pos += newDir * viewcam->getPosition().y 147 / newDir.dotProduct(down); 148 //pos.y = 0; 149 150 151 152 depthMapCameras[1]->setDirection( dir ); 153 pos = pos - 30 * dir; 154 depthMapCameras[1]->setPosition( pos ); 155 depthMapCameras[1]->setProjectionType(PT_ORTHOGRAPHIC); 156 Matrix4 fproj2; 157 fproj2 = depthMapCameras[1]->getProjectionMatrix(); 158 fproj2 = Matrix4::IDENTITY; 159 fproj2.setScale(Vector3(1.0/size, 1.0/size, -1.0/100)); 160 //fproj.setTrans(Vector3(0,0,-50)); 161 depthMapCameras[1]->setCustomProjectionMatrix(true,fproj2); 162 163 164 /*LISPSM 165 Vector3 viewdir = viewcam->getDirection(); 166 Vector3 lightdir = dir; 167 168 float dotProd = viewdir.dotProduct(lightdir); 169 float sinGamma; 170 sinGamma = sqrt(1.0-dotProd*dotProd); 171 g_fsinGamma = sinGamma; 172 173 Vector3 newVdir = viewdir; 174 Matrix4 proj;*/ 175 91 176 } 92 177 else if(light->getType() == Light::LT_SPOTLIGHT) 93 178 { 94 Vector3 dir = light->getDirection();179 /* Vector3 dir = light->getDirection(); 95 180 depthMapCamera->setDirection( dir ); 96 181 Vector3 pos = light->getParentNode()->getWorldPosition(); 97 182 depthMapCamera->setPosition(pos); 98 183 depthMapCamera->setProjectionType(PT_PERSPECTIVE); 99 depthMapCamera->setFOVy(light->getSpotlightOuterAngle()); 184 depthMapCamera->setFOVy(light->getSpotlightOuterAngle());*/ 100 185 } 101 186 else//point light 102 187 { 103 Vector3 pos = light->getParentNode()->getWorldPosition();188 /* Vector3 pos = light->getParentNode()->getWorldPosition(); 104 189 Vector3 dir = -pos; 105 190 depthMapCamera->setDirection( dir ); … … 111 196 112 197 //OGRE_EXCEPT(0, "NOT implemented for Pointlight", "OgreDepthShadowMapRenderingRun::refreshLight"); 113 198 */ 114 199 /*Vector3 pos = light->getParentNode()->getWorldPosition(); 115 200 Vector3 dir = -pos; … … 123 208 } 124 209 125 Matrix4 OgreDepthShadowMapRenderingRun::getLightViewMatrix( )126 { 127 return depthMapCamera ->getViewMatrix();128 } 129 130 Matrix4 OgreDepthShadowMapRenderingRun::getLightViewProjMatrix( )131 { 132 return depthMapCamera ->getProjectionMatrix() * depthMapCamera->getViewMatrix();133 } 134 210 Matrix4 OgreDepthShadowMapRenderingRun::getLightViewMatrix(int i) 211 { 212 return depthMapCameras[i]->getViewMatrix(); 213 } 214 215 Matrix4 OgreDepthShadowMapRenderingRun::getLightViewProjMatrix(int i) 216 { 217 return depthMapCameras[i]->getProjectionMatrix() * depthMapCameras[i]->getViewMatrix(); 218 } 219 -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePhotonMapRenderingRun.cpp
r949 r1055 103 103 Vector3 dir = light->getDirection(); 104 104 photonMapCamera->setDirection( dir ); 105 photonMapCamera->setPosition( sharedRuns->getRootPosition(ILLUMRUN_PHOTONMAP) - dir ); 106 photonMapCamera->setProjectionType(PT_ORTHOGRAPHIC); 105 Real r = sharedRuns->getRootBoundingSphere(ILLUMRUN_PHOTONMAP).getRadius(); 106 photonMapCamera->setPosition( sharedRuns->getRootPosition(ILLUMRUN_PHOTONMAP) - dir * r); 107 photonMapCamera->setProjectionType(PT_ORTHOGRAPHIC); 108 Matrix4 proj; 109 proj = Matrix4::IDENTITY; 110 proj.setScale(Vector3(1.0/r, 1.0/r, -1.0/r)); 111 proj.setTrans(Vector3(0,0,-1)); 112 photonMapCamera->setCustomProjectionMatrix(true,proj); 107 113 } 108 114 else 109 { 110 photonMapCamera->setFarClipDistance(100000); 111 photonMapCamera->setNearClipDistance(0.1); 115 { 112 116 Vector3 pos = light->getParentSceneNode()->getPosition(); 113 117 Vector3 dir = sharedRuns->getRootPosition(ILLUMRUN_PHOTONMAP) - pos; … … 125 129 photonMapCamera->setFOVy(2*alfa); 126 130 photonMapCamera->setDirection( dir ); 131 132 photonMapCamera->setNearClipDistance(std::max(0.01f, d - r)); 133 photonMapCamera->setFarClipDistance(r + d); 127 134 } 128 135 } -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreReducedCubeMapRenderingRun.cpp
r790 r1055 27 27 { 28 28 reducedCubemapTexture = createCubeRenderTexture(name, 29 sharedRuns->getRootPosition( ILLUMRUN_REDUCED_CUBEMAP),29 sharedRuns->getRootPosition(), 30 30 resolution, 31 31 PF_FLOAT16_RGBA); … … 42 42 // mat->getTechnique(0)->getPass(0)->setFragmentProgramParameters(fpParams); 43 43 44 renderFullscreenQuad("GameTools/CubeMap/Reduce", rt); 45 44 46 //rt->writeContentsToFile("cubbereduce" + StringConverter::toString(facenum) + ".dds"); 45 46 renderFullscreenQuad("GameTools/CubeMap/Reduce", rt);47 47 } 48 48
Note: See TracChangeset
for help on using the changeset viewer.