Changeset 2333 for GTP/trunk/Lib/Illum
- Timestamp:
- 04/24/07 14:04:48 (18 years ago)
- Location:
- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreIlluminationManager.h
r2320 r2333 130 130 @brief Size of the shadow maps. 131 131 */ 132 unsigned int shadowMapSize; 132 unsigned int shadowMapSizePoint; 133 unsigned int shadowMapSizeSpot; 134 unsigned int shadowMapSizeDirectional; 133 135 /** 134 136 @brief Size of area lights for soft shadows. … … 138 140 @brief Sets if light space perspective shadow mapping should be used. 139 141 */ 140 bool useLISPSM; 142 bool useLISPSMPoint; 143 bool useLISPSMSpot; 144 bool useLISPSMDirectional; 141 145 /** 142 146 @brief Sets if the shadow maps should be blurred. … … 144 148 Used in variance shadow mapping. 145 149 */ 146 bool blurSM; 150 bool blurSMPoint; 151 bool blurSMSpot; 152 bool blurSMDirectional; 147 153 /** 148 154 @brief Sets if shadow maps should be focused. 149 155 */ 150 bool focusingSM; 156 bool focusingSMPoint; 157 bool focusingSMSpot; 158 bool focusingSMDirectional; 151 159 /** 152 160 @brief The material name that should be used during rendering the shadow maps. … … 166 174 - directional lights : GTP/Basic/Depth or GTP/Basic/DepthCCW 167 175 */ 168 String shadowMapMaterialName; 176 String shadowMapMaterialNamePoint; 177 String shadowMapMaterialNameSpot; 178 String shadowMapMaterialNameDirectional; 169 179 /** 170 180 @brief Size of the phase texture. … … 241 251 std::vector<UpdateListener*> updateListeners; 242 252 253 bool joinRuns; 254 243 255 public: 256 257 void joinSharedRuns(bool join){joinRuns = join;} 244 258 /** 245 259 @brief Registers an UpdateListener instance. @see UpdateListener … … 296 310 @see shadowMapSize 297 311 */ 298 void setShadowMapSize(unsigned int size){shadowMapSize = size;} 312 void setShadowMapSize(unsigned int size) 313 { 314 shadowMapSizeDirectional = size; 315 shadowMapSizePoint = size; 316 shadowMapSizeSpot = size; 317 } 318 void setShadowMapSize(Light::LightTypes type, unsigned int size) 319 { 320 switch(type) 321 { 322 case Light::LT_DIRECTIONAL: 323 shadowMapSizeDirectional = size;break; 324 case Light::LT_POINT: 325 shadowMapSizePoint = size;break; 326 case Light::LT_SPOTLIGHT: 327 shadowMapSizeSpot = size;break; 328 } 329 } 299 330 /** 300 331 @brief Returns the one and only OgreIlluminationManager instance. … … 454 485 @see useLISPSM 455 486 */ 456 bool getUseLISPSM(){return useLISPSM;} 487 bool getUseLISPSM(Light::LightTypes type) 488 { 489 switch(type) 490 { 491 case Light::LT_DIRECTIONAL: 492 return useLISPSMDirectional; 493 case Light::LT_POINT: 494 return useLISPSMPoint; 495 case Light::LT_SPOTLIGHT: 496 return useLISPSMSpot; 497 } 498 } 457 499 /** 458 500 @see focusingSM 459 501 */ 460 bool getFocusingShadowMap(){return focusingSM;} 502 bool getFocusingShadowMap(Light::LightTypes type) 503 { 504 switch(type) 505 { 506 case Light::LT_DIRECTIONAL: 507 return focusingSMDirectional; 508 case Light::LT_POINT: 509 return focusingSMPoint; 510 case Light::LT_SPOTLIGHT: 511 return focusingSMSpot; 512 } 513 } 461 514 /** 462 515 @see blurSM 463 516 */ 464 bool getBlurShadowMap(){return blurSM;} 517 bool getBlurShadowMap(Light::LightTypes type) 518 { 519 switch(type) 520 { 521 case Light::LT_DIRECTIONAL: 522 return blurSMDirectional; 523 case Light::LT_POINT: 524 return blurSMPoint; 525 case Light::LT_SPOTLIGHT: 526 return blurSMSpot; 527 } 528 } 465 529 /** 466 530 @see useLISPSM 467 531 */ 468 void setUseLISPSM(bool use){useLISPSM = use;} 532 void setUseLISPSM(bool use) 533 { 534 useLISPSMDirectional = use; 535 useLISPSMPoint = use; 536 useLISPSMSpot = use; 537 } 538 void setUseLISPSM(Light::LightTypes type, bool use) 539 { 540 switch(type) 541 { 542 case Light::LT_DIRECTIONAL: 543 useLISPSMDirectional = use;break; 544 case Light::LT_POINT: 545 useLISPSMPoint = use;break; 546 case Light::LT_SPOTLIGHT: 547 useLISPSMSpot = use;break; 548 } 549 } 469 550 /** 470 551 @see focusingSM 471 552 */ 472 void setFocusingSM(bool use){focusingSM = use;} 553 void setFocusingSM(bool use) 554 { 555 focusingSMDirectional = use; 556 focusingSMPoint = use; 557 focusingSMSpot = use; 558 } 559 void setFocusingSM(Light::LightTypes type, bool use) 560 { 561 switch(type) 562 { 563 case Light::LT_DIRECTIONAL: 564 focusingSMDirectional = use;break; 565 case Light::LT_POINT: 566 focusingSMPoint = use;break; 567 case Light::LT_SPOTLIGHT: 568 focusingSMSpot = use;break; 569 } 570 } 473 571 /** 474 572 @see blurSM 475 573 */ 476 void setBlurShadowMap(bool use){blurSM = use;} 574 void setBlurShadowMap(bool use) 575 { 576 blurSMDirectional = use; 577 blurSMPoint = use; 578 blurSMSpot = use; 579 } 580 void setBlurShadowMap(Light::LightTypes type, bool use) 581 { 582 switch(type) 583 { 584 case Light::LT_DIRECTIONAL: 585 blurSMDirectional = use;break; 586 case Light::LT_POINT: 587 blurSMPoint = use;break; 588 case Light::LT_SPOTLIGHT: 589 blurSMSpot = use;break; 590 } 591 } 477 592 /** 478 593 @see shadowMapMaterialName 479 594 */ 480 void setShadowMapMaterialName(String name){shadowMapMaterialName = name;} 595 void setShadowMapMaterialName(String name) 596 { 597 shadowMapMaterialNameDirectional = name; 598 shadowMapMaterialNamePoint = name; 599 shadowMapMaterialNameSpot = name; 600 } 601 void setShadowMapMaterialName(Light::LightTypes type, String name) 602 { 603 switch(type) 604 { 605 case Light::LT_DIRECTIONAL: 606 shadowMapMaterialNameDirectional = name;break; 607 case Light::LT_POINT: 608 shadowMapMaterialNamePoint = name;break; 609 case Light::LT_SPOTLIGHT: 610 shadowMapMaterialNameSpot = name;break; 611 } 612 } 481 613 /** 482 614 @brief Registers a PathMapClusters structure for a given subentity. -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderingRun.h
r2320 r2333 22 22 :RenderingRun(startFrame, updateInterval) 23 23 { 24 pixelSprites = 0; 25 fullscreenGrid = 0; 24 26 25 } 27 26 … … 69 68 @see renderPixelSprites 70 69 */ 71 BillboardSet* pixelSprites;70 static BillboardSet* pixelSprites; 72 71 /** 73 72 @brief Entity used in fullscreen grid rendering … … 75 74 @see renderPixelGrid 76 75 */ 77 Entity* fullscreenGrid;76 static Entity* fullscreenGrid; 78 77 /** 79 78 @brief unique name of the SpriteSet used in pixel sprite rendering … … 81 80 @see renderPixelSprites 82 81 */ 83 String spriteSetName;82 static String spriteSetName; 84 83 /** 85 84 @brief Returns a direction for a cubemap face id. … … 147 146 @param target the RenderTarget the quad should be rendered on 148 147 */ 149 void renderFullscreenQuad(String materialName, RenderTarget* target);148 static void renderFullscreenQuad(String materialName, RenderTarget* target); 150 149 /** 151 150 @brief Renderes sprites to pixels of the screen on a given RendderTarget with a given material. … … 161 160 @param height the desired resolution height of the sprites 162 161 */ 163 void renderPixelSprites(String& materialName, RenderTarget* rt, int width, int height);162 static void renderPixelSprites(String& materialName, RenderTarget* rt, int width, int height); 164 163 /** 165 164 @brief Renders a grid onto the screen. … … 169 168 @param height the desired vertical resolution of the grid 170 169 */ 171 void renderFullscreenGrid(String& materialName, RenderTarget* rt, int width, int height);170 static void renderFullscreenGrid(String& materialName, RenderTarget* rt, int width, int height); 172 171 }; -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgrePMWeightComputeRenderingRun.h
r2320 r2333 35 35 @brief returns the name of the weight texture 36 36 */ 37 String getPMWeightTetureName(){return weightTexture->getName();}37 static String getPMWeightTextureName(){return weightTexture->getName();} 38 38 //not used 39 39 float* getWeights(){return weights;} 40 40 41 41 void freeAllResources(); 42 static void sumWeights(unsigned long frameNum); 42 43 43 44 protected: … … 57 58 @brief a pointer to the weight texture that was created by this run 58 59 */ 59 Texture* weightTexture;60 static Texture* weightTexture; 60 61 /** 61 62 @brief A pointer to a texture that stores weights for all the entry point. … … 63 64 This texture will be used to determine the weights of the clusters. 64 65 */ 65 Texture* allWeightsTexture;66 static Texture* allWeightsTexture; 66 67 /** 67 68 @brief A pointer to the light source. -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/scripts/OgreIllumModule.7.10.vcproj
r2285 r2333 91 91 <Tool 92 92 Name="VCLibrarianTool" 93 AdditionalDependencies="IllumModule.lib OgreMain.lib Plugin_OctreeSceneManager.lib Plugin_VisibilitySceneManager.lib"94 AdditionalLibraryDirectories="..\..\IllumModule\bin\Release;"$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)" ;"$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\$(ConfigurationName)";"..\..\..\..\Vis\OnlineCullingCHC\OGRE\lib\$(ConfigurationName)""/>93 AdditionalDependencies="IllumModule.lib OgreMain.lib" 94 AdditionalLibraryDirectories="..\..\IllumModule\bin\Release;"$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)""/> 95 95 <Tool 96 96 Name="VCMIDLTool"/> -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreIlluminationManager.cpp
r2320 r2333 79 79 { 80 80 visitor = new VisibleFinderVisitor(&visibleObjects); 81 joinRuns = true; 81 82 maxRad = 400; 82 83 focusingMapSize = 32; 83 shadowMapSize = 512;84 84 phaseTextureSize = 256; 85 useLISPSM = false; 86 // useVSM = false; 87 blurSM = false; 88 focusingSM = true; 89 shadowMapMaterialName = "GTP/Basic/Distance_NormalizedCCW"; 85 shadowMapSizeDirectional = shadowMapSizePoint = shadowMapSizeSpot = 512; 86 useLISPSMDirectional = useLISPSMPoint = useLISPSMSpot = false; 87 blurSMDirectional = blurSMPoint = blurSMSpot = false; 88 focusingSMDirectional = focusingSMPoint = focusingSMSpot = true; 89 shadowMapMaterialNameDirectional = "GTP/Basic/Depth or GTP/Basic/DepthCCW"; 90 shadowMapMaterialNamePoint = "GTP/Basic/Distance_NormalizedCCW"; 91 shadowMapMaterialNameSpot = "GTP/Basic/Distance_NormalizedCCW"; 90 92 areaLightRadius = 0.1; 91 93 … … 515 517 fillVisibleList(rq); 516 518 517 int l = visibleObjects.size(); //debug 518 519 joinSharedRuns(); 520 521 int ll = sharedRunRoots.size(); //debug 519 if(joinRuns) 520 { 521 int l = visibleObjects.size(); //debug 522 joinSharedRuns(); 523 int ll = sharedRunRoots.size(); //debug 524 } 522 525 523 526 //update precomputings … … 717 720 { 718 721 SceneManager* sm = Root::getSingleton()._getCurrentSceneManager(); 722 Light* light = sm->getLight(lightName); 723 unsigned int res; 724 String MaterialName; 725 switch(light->getType()) 726 { 727 case Light::LT_DIRECTIONAL: 728 res = shadowMapSizeDirectional; 729 MaterialName = shadowMapMaterialNameDirectional; 730 break; 731 case Light::LT_POINT: 732 res = shadowMapSizePoint; 733 MaterialName = shadowMapMaterialNamePoint; 734 break; 735 case Light::LT_SPOTLIGHT: 736 res = shadowMapSizeSpot; 737 MaterialName = shadowMapMaterialNameSpot; 738 break; 739 } 740 719 741 OgreDepthShadowMapRenderingRun* run = new OgreDepthShadowMapRenderingRun( 720 742 runs, 721 743 lightName + "DEPTH_SHADOW_MAP", 722 sm->getLight(lightName),723 shadowMapSize,724 shadowMapSize,725 shadowMapMaterialName //TODO744 light, 745 res, 746 res, 747 MaterialName 726 748 ); 727 749 runs->addRun(ILLUMRUN_DEPTH_SHADOWMAP, run); -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderingRun.cpp
r2265 r2333 5 5 Entity* OgreRenderingRun::fullScreenQuadEntity = NULL; 6 6 SceneNode* OgreRenderingRun::fullScreenQuadNode = NULL; 7 BillboardSet* OgreRenderingRun::pixelSprites = NULL; 8 Entity* OgreRenderingRun::fullscreenGrid = NULL; 9 String OgreRenderingRun::spriteSetName = ""; 7 10 8 11 class MaterialSetVisitor : public QueuedRenderableVisitor … … 231 234 SceneManager* sm = Root::getSingleton()._getCurrentSceneManager(); 232 235 233 if( this->fullscreenGrid == NULL)236 if(fullscreenGrid == NULL) 234 237 { 235 238 MeshPtr mesh = MeshManager::getSingleton().createManual("FullScreenGrid",ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDepthShadowReceiverRenderTechnique.cpp
r2299 r2333 125 125 GpuProgramParametersSharedPtr fpParams = passes.at(i)->getFragmentProgramParameters(); 126 126 GpuProgramParametersSharedPtr vpParams = passes.at(i)->getVertexProgramParameters(); 127 128 //fpParams->setNamedConstant("lightViewProj", depthRun->getLightViewProjMatrix()); 127 129 128 if(setLightViewProjMatrix) 130 129 vpParams->setNamedConstant(lightViewProjParamName, depthRun->getLightViewProjMatrix()); -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgrePathMapRenderTechnique.cpp
r2299 r2333 63 63 TextureUnitState* st = newpass->createTextureUnitState(); 64 64 st->setTextureFiltering(TFO_BILINEAR); 65 st->setTextureAddressingMode(TextureUnitState::TAM_ BORDER);65 st->setTextureAddressingMode(TextureUnitState::TAM_CLAMP); 66 66 st->setTextureBorderColour(ColourValue::Green); 67 67 st->setTextureName(clusters->pathMapTextureFilename); … … 71 71 st = newpass->createTextureUnitState(); 72 72 st->setTextureFiltering(TFO_NONE); 73 st->setTextureAddressingMode(TextureUnitState::TAM_ BORDER);73 st->setTextureAddressingMode(TextureUnitState::TAM_CLAMP); 74 74 st->setTextureBorderColour(ColourValue::Red); 75 75 st->setTextureName(weightIndexTexture->getName()); … … 77 77 st = newpass->createTextureUnitState(); 78 78 st->setTextureFiltering(TFO_NONE); 79 st->setTextureAddressingMode(TextureUnitState::TAM_ BORDER);79 st->setTextureAddressingMode(TextureUnitState::TAM_CLAMP); 80 80 st->setTextureBorderColour(ColourValue::Blue); 81 81 … … 122 122 LightList lights; 123 123 SceneManager* sm = Root::getSingleton()._getCurrentSceneManager(); 124 sm->_populateLightList(Vector3(0,0,0), 1000, lights); //TODO 125 //TODO set weights 126 /* 127 unsigned int entryPointCount = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().size(); 128 PathMapClusters* clusters = OgreIlluminationManager::getSingleton().getPathMapClusters(parentOgreRenderable->getName()); 129 int weightTextureWidth = clusters->count / 4; 130 */ 131 for(int i = 0 ; i < 1; i++) 132 { 133 String lightName = lights.at(0)->getName(); 124 sm->_populateLightList(OgreIlluminationManager::getSingleton().getMainCamera()->getPosition(), 1000, lights); 125 126 for(int i = 0 ; i < 5 && i < lights.size(); i++) 127 { 128 String lightName = lights.at(i)->getName(); 134 129 OgreIlluminationManager::getSingleton().createPerLightRun(lightName, ILLUMRUN_PM_WEIGHTMAP); 135 OgreIlluminationManager::getSingleton().updatePerLightRun(lightName, ILLUMRUN_PM_WEIGHTMAP, frameNum); 136 OgrePMWeightComputeRenderingRun* PMWeightRun = (OgrePMWeightComputeRenderingRun*) 137 OgreIlluminationManager::getSingleton().getPerLightRun(lightName, ILLUMRUN_PM_WEIGHTMAP)->asOgreRenderingRun(); 138 139 TextureUnitState* st = pathMapPass->getTextureUnitState(2); 140 st->setTextureName(PMWeightRun->getPMWeightTetureName()); 141 142 /* 143 TexturePtr tex = TextureManager::getSingleton().getByName(PMWeightRun->getPMWeightTetureName()); 144 float *allClusterWeights = new float[entryPointCount]; 145 PixelBox lockBox(entryPointCount, 1, 1, PF_FLOAT32_R, allClusterWeights); 146 tex->getBuffer()->blitToMemory(lockBox); 147 148 float *weightIndices = new float[clusters->count]; 149 for(int j = 0; j< clusters->count; j++) 150 weightIndices[j] = allClusterWeights[clusters->clusters[j]]; 151 152 PixelBox lockBox2(weightTextureWidth, 1, 1, PF_FLOAT32_RGBA, weightIndices); 153 weightIndexTexture->getBuffer()->blitFromMemory(lockBox2); 154 155 TextureUnitState* st = pathMapPass->getTextureUnitState(1); 156 st->setTextureName(weightIndexTexture->getName()); */ 130 OgreIlluminationManager::getSingleton().updatePerLightRun(lightName, ILLUMRUN_PM_WEIGHTMAP, frameNum); 157 131 } 158 } 132 OgrePMWeightComputeRenderingRun::sumWeights(frameNum); 133 TextureUnitState* st = pathMapPass->getTextureUnitState(2); 134 st->setTextureName(OgrePMWeightComputeRenderingRun::getPMWeightTextureName()); 135 } 136 137 159 138 160 139 namespace PathMapParsers -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp
r2321 r2333 26 26 void OgreDepthShadowMapRenderingRun::createDepthMap() 27 27 { 28 if(light->getType() == Light::LT_POINT) 29 { 30 depthMapTexture = createCubeRenderTexture(name, light->getPosition(), resolutionX,PF_FLOAT16_RGBA,0,ColourValue::White); 31 if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType())) 32 blurredDepthMapTexture = createCubeRenderTexture(blurredname, light->getPosition(), resolutionX,PF_FLOAT16_RGBA,0,ColourValue::White); 33 } 34 else 35 { 28 36 29 37 TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name, … … 46 54 rt->setAutoUpdated(false); 47 55 48 if(OgreIlluminationManager::getSingleton().getBlurShadowMap( ))56 if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType())) 49 57 { 50 58 texPtr = Ogre::TextureManager::getSingleton().createManual(blurredname, … … 64 72 rt->setAutoUpdated(false); 65 73 } 74 } 66 75 } 67 76 … … 72 81 if(light->getType() == Light::LT_POINT) 73 82 { 74 updateDepthMap(); 83 //static int currentFace = 0; 84 //updateDepthCubeFace(currentFace); 85 //currentFace = (currentFace+1)%6; 86 87 for(int i = 0; i < 6 ; i++) 88 updateDepthCubeFace(i); 75 89 } 76 90 else … … 82 96 void OgreDepthShadowMapRenderingRun::updateDepthCubeFace(int facenum) 83 97 { 98 Vector3 lightpos = light->getDerivedPosition(); 99 100 RenderTarget* rt = depthMapTexture->getBuffer(facenum, 0).getPointer()->getRenderTarget(); 101 Camera* cam = rt->getViewport(0)->getCamera(); 102 cam->setPosition(lightpos); 103 cam->setFarClipDistance(lightFarPlane); 104 105 setMaterialForVisibles(materialName, cam, false); 106 rt->update(); 107 restoreMaterials(); 108 109 //rt->writeContentsToFile("shadowmap_" + StringConverter::toString(facenum) + ".dds"); 110 111 if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType())) 112 { 113 rt = blurredDepthMapTexture->getBuffer(facenum, 0).getPointer()->getRenderTarget(); 114 Material* mat = (Material*) MaterialManager::getSingleton().getByName("GameTools/BlurCubeFace").getPointer(); 115 mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(depthMapTexture->getName()); 116 mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("face", facenum); 117 renderFullscreenQuad("GameTools/BlurCubeFace", rt); 118 119 //rt->writeContentsToFile("shadowmap_blurred_" + StringConverter::toString(facenum) + ".dds"); 120 } 121 84 122 } 85 123 … … 93 131 restoreMaterials(); 94 132 95 if(OgreIlluminationManager::getSingleton().getBlurShadowMap( ))133 if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType())) 96 134 { 97 135 rt = blurredDepthMapTexture->getBuffer().getPointer()->getRenderTarget(); … … 108 146 const String& OgreDepthShadowMapRenderingRun::getDepthMapTextureName() 109 147 { 110 if(OgreIlluminationManager::getSingleton().getBlurShadowMap( ))148 if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType())) 111 149 return blurredname; 112 150 … … 119 157 if(light!= 0) 120 158 { 121 bool uselispsm = OgreIlluminationManager::getSingleton().getUseLISPSM( );122 bool usefocusing = OgreIlluminationManager::getSingleton().getFocusingShadowMap( );159 bool uselispsm = OgreIlluminationManager::getSingleton().getUseLISPSM(light->getType()); 160 bool usefocusing = OgreIlluminationManager::getSingleton().getFocusingShadowMap(light->getType()); 123 161 if(light->getType() == Light::LT_DIRECTIONAL) 124 162 { … … 129 167 frun->setCameraMatrices(viewcam->getViewMatrix(), viewcam->getProjectionMatrix()); 130 168 131 Vector3 lightpos = light->get ParentSceneNode()->getWorldPosition();132 Vector3 lightdir = light->getD irection();169 Vector3 lightpos = light->getDerivedPosition(); 170 Vector3 lightdir = light->getDerivedDirection(); 133 171 lightdir.normalise(); 134 172 … … 234 272 frun->setCameraMatrices(viewcam->getViewMatrix(), viewcam->getProjectionMatrix()); 235 273 236 Vector3 lightpos = light->get ParentSceneNode()->getWorldPosition();237 Vector3 lightdir = light->getD irection();274 Vector3 lightpos = light->getDerivedPosition(); 275 Vector3 lightdir = light->getDerivedDirection(); 238 276 lightdir.normalise(); 239 277 Radian lightangle = light->getSpotlightOuterAngle(); … … 359 397 else//point light 360 398 { 361 /* Vector3 pos = light->getParentNode()->getWorldPosition(); 362 Vector3 dir = -pos; 363 depthMapCamera->setDirection( dir ); 364 depthMapCamera->setPosition(pos); 365 depthMapCamera->setProjectionType(PT_PERSPECTIVE); 366 depthMapCamera->setFOVy(Radian(Degree(140))); 367 depthMapCamera->setNearClipDistance(1); 368 // depthMapCamera->setFarClipDistance(200); 369 370 //OGRE_EXCEPT(0, "NOT implemented for Pointlight", "OgreDepthShadowMapRenderingRun::refreshLight"); 371 */ 372 /*Vector3 pos = light->getParentNode()->getWorldPosition(); 373 Vector3 dir = -pos; 374 depthMapCamera->setDirection( dir ); 375 depthMapCamera->setPosition(pos); 376 depthMapCamera->setProjectionType(PT_ORTHOGRAPHIC); 377 depthMapCamera->*/ 378 399 lightFarPlane = light->getAttenuationRange(); 400 //no other adjustment needed 379 401 } 380 402 } … … 383 405 Matrix4 OgreDepthShadowMapRenderingRun::getLightViewMatrix() 384 406 { 385 return depthMapCamera->getViewMatrix(); 407 Camera* cam = depthMapCamera; 408 if(light->getType() == Light::LT_POINT) 409 cam = depthMapTexture->getBuffer(4, 0).getPointer()->getRenderTarget()->getViewport(0)->getCamera(); 410 411 return cam->getViewMatrix(); 386 412 } 387 413 388 414 Matrix4 OgreDepthShadowMapRenderingRun::getLightViewProjMatrix() 389 415 { 390 return depthMapCamera->getProjectionMatrixWithRSDepth() * depthMapCamera->getViewMatrix(); 416 Camera* cam = depthMapCamera; 417 if(light->getType() == Light::LT_POINT) 418 cam = depthMapTexture->getBuffer(4, 0).getPointer()->getRenderTarget()->getViewport(0)->getCamera(); 419 420 return cam->getProjectionMatrixWithRSDepth() * cam->getViewMatrix(); 391 421 } 392 422 -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreLightVolumeRenderingRun.cpp
r2321 r2333 238 238 else 239 239 { 240 Vector3 pos = light->get ParentSceneNode()->getPosition();240 Vector3 pos = light->getDerivedPosition(); 241 241 Vector3 dir = sharedRuns->getRootPosition(ILLUMRUN_LIGHTVOLUME_MAP) - pos; 242 242 dir.normalise(); -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePMWeightComputeRenderingRun.cpp
r2321 r2333 4 4 #include "OgreDepthShadowMapRenderingRun.h" 5 5 6 Texture* OgrePMWeightComputeRenderingRun::weightTexture = 0; 7 Texture* OgrePMWeightComputeRenderingRun::allWeightsTexture = 0; 8 6 9 OgrePMWeightComputeRenderingRun::OgrePMWeightComputeRenderingRun(String name, String LightName) 7 10 : OgreRenderingRun(1, 1) … … 19 22 void OgrePMWeightComputeRenderingRun::createWeightMap() 20 23 { 21 22 unsigned int entryPointCnt = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().size(); 23 int width = entryPointCnt / 4096; 24 int height = 4096; 25 TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name + "_ALL", 26 "default", 27 TEX_TYPE_2D, 28 width, 29 height, 30 0, 31 0, 32 PF_FLOAT32_R, 33 TU_RENDERTARGET); 34 allWeightsTexture = texPtr.getPointer(); 35 //add viewport to rendertarget 36 HardwarePixelBuffer* hpb = (allWeightsTexture->getBuffer()).getPointer(); 37 RenderTarget* rt = hpb->getRenderTarget(); 38 Camera* wc = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_ALL_CAMERA"); 39 Viewport* v = rt->addViewport(wc); 40 v->setOverlaysEnabled(false); 41 rt->setAutoUpdated(false); 42 43 unsigned int clustercount = OgreIlluminationManager::getSingleton().getPathMapClusterLengthsSize(); 44 width = clustercount; 45 height = 1; 46 texPtr = Ogre::TextureManager::getSingleton().createManual(name, 47 "default", 48 TEX_TYPE_2D, 49 width, 50 height, 51 0, 52 0, 53 PF_FLOAT32_R, 54 TU_RENDERTARGET); 55 weightTexture = texPtr.getPointer(); 56 //add viewport to rendertarget 57 hpb = (weightTexture->getBuffer()).getPointer(); 58 rt = hpb->getRenderTarget(); 59 wc = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_CAMERA"); 60 v = rt->addViewport(wc); 61 v->setOverlaysEnabled(false); 62 rt->setAutoUpdated(false); 24 if(allWeightsTexture == 0) 25 { 26 unsigned int entryPointCnt = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().size(); 27 int width = entryPointCnt / 4096; 28 int height = 4096; 29 TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name + "_ALL", 30 "default", 31 TEX_TYPE_2D, 32 width, 33 height, 34 0, 35 0, 36 PF_FLOAT16_RGBA, 37 TU_RENDERTARGET); 38 allWeightsTexture = texPtr.getPointer(); 39 //add viewport to rendertarget 40 HardwarePixelBuffer* hpb = (allWeightsTexture->getBuffer()).getPointer(); 41 RenderTarget* rt = hpb->getRenderTarget(); 42 Camera* wc = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_ALL_CAMERA"); 43 Viewport* v = rt->addViewport(wc); 44 v->setBackgroundColour(ColourValue::Black); 45 v->setClearEveryFrame(false); 46 v->setOverlaysEnabled(false); 47 rt->setAutoUpdated(false); 48 49 unsigned int clustercount = OgreIlluminationManager::getSingleton().getPathMapClusterLengthsSize(); 50 width = clustercount; 51 height = 1; 52 texPtr = Ogre::TextureManager::getSingleton().createManual(name, 53 "default", 54 TEX_TYPE_2D, 55 width, 56 height, 57 0, 58 0, 59 PF_FLOAT16_RGBA, 60 TU_RENDERTARGET); 61 weightTexture = texPtr.getPointer(); 62 //add viewport to rendertarget 63 hpb = (weightTexture->getBuffer()).getPointer(); 64 rt = hpb->getRenderTarget(); 65 wc = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_CAMERA"); 66 v = rt->addViewport(wc); 67 v->setOverlaysEnabled(false); 68 rt->setAutoUpdated(false); 69 } 63 70 } 64 71 … … 83 90 GpuProgramParameters* Fparams = mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters().getPointer(); 84 91 85 Vector3 lightPos = light->get Position();86 Vector3 lightDir = light->getD irection();87 //Radian lightAngle = light->getSpotlightOuterAngle();92 Vector3 lightPos = light->getDerivedPosition(); 93 Vector3 lightDir = light->getDerivedDirection(); 94 Radian lightAngle = light->getSpotlightOuterAngle(); 88 95 89 96 Fparams->setNamedConstant("nRadionColumns", col); … … 91 98 Fparams->setNamedConstant("lightDir", lightDir); 92 99 Fparams->setNamedConstant("lightPower", light->getPowerScale()); 100 Fparams->setNamedConstant("lightColor", light->getDiffuseColour()); 93 101 Fparams->setNamedConstant("lightViewProj", SMrun->getLightViewProjMatrix()); 94 102 Fparams->setNamedConstant("lightFarPlane", SMrun->getLightFarPlane()); 103 Fparams->setNamedConstant("lightAttenuation", Vector4(light->getAttenuationRange(), 104 light->getAttenuationConstant(), 105 light->getAttenuationLinear(), 106 light->getAttenuationQuadric())); 107 Fparams->setNamedConstant("lightAngleCos", Math::Cos(lightAngle.valueRadians()/2.0)); 108 Fparams->setNamedConstant("spotLightFalloff", light->getSpotlightFalloff()); 95 109 96 110 mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName( … … 100 114 101 115 RenderTarget* rt = allWeightsTexture->getBuffer().getPointer()->getRenderTarget(); 102 renderFullscreenQuad(mat->getName(), rt); 116 if(frameNum != rt->getLastFrameNumber()) 117 rt->getViewport(0)->setClearEveryFrame(true); 118 else 119 rt->getViewport(0)->setClearEveryFrame(false); 120 121 renderFullscreenQuad(mat->getName(), rt); 122 103 123 104 124 // rt->writeContentsToFile("allweights.bmp"); 105 125 // rt->writeContentsToFile("allweights.dds"); 106 107 /* float* allweights = new float[entryPointCnt / 4096 * 4096]; 108 PixelBox lockBox(entryPointCnt / 4096, 4096, 1, PF_FLOAT32_R, allweights); 109 allWeightsTexture->getBuffer()->blitToMemory(lockBox); 110 111 ///////////////////DEBUG 112 static BillboardSet* entryPointBBSet = 0; 113 if(entryPointBBSet == 0) 114 { 115 SceneManager* sm = Root::getSingleton()._getCurrentSceneManager(); 116 entryPointBBSet = sm->createBillboardSet("PATHMAP_ENTRYPOINTS", entryPointCnt); 117 entryPointBBSet->setBillboardType(BBT_POINT); 118 entryPointBBSet->setBillboardsInWorldSpace(true); 119 entryPointBBSet->setPointRenderingEnabled(true); 120 for(unsigned int i = 0; i < entryPointCnt; i++) 121 { 122 PathMapEntryPoint EP = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().at(i); 123 Vector3 billboardPosition = EP.position; 124 125 float uCoord = allweights[i]; 126 float vCoord = 0; 127 //float uCoord = ((float) (i % col) + 0.5f) / (float) col; 128 //float vCoord = ((float)(i / col) + 0.5f) / 4096.0f; 129 entryPointBBSet->createBillboard(billboardPosition, ColourValue(uCoord, vCoord, 0, 0)); 130 } 131 entryPointBBSet->setMaterialName("GTP/PM/EPBillboards"); 132 MaterialPtr mater = MaterialManager::getSingleton().getByName("GTP/PM/EPBillboards"); 133 mater->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(allWeightsTexture->getName()); 134 sm->getRootSceneNode()->createChildSceneNode()->attachObject(entryPointBBSet); 135 } 136 137 delete[] allweights;*/ 138 139 ///////////////// 126 140 127 } 141 else 128 else if(light->getType() == Light::LT_POINT) 142 129 { 143 ///not implemented 130 OgreIlluminationManager::getSingleton().createPerLightRun(light->getName(), ILLUMRUN_DEPTH_SHADOWMAP); 131 OgreIlluminationManager::getSingleton().updatePerLightRun(light->getName(), ILLUMRUN_DEPTH_SHADOWMAP, frameNum); 132 OgreDepthShadowMapRenderingRun* SMrun = (OgreDepthShadowMapRenderingRun*) OgreIlluminationManager::getSingleton() 133 .getPerLightRun(light->getName(), ILLUMRUN_DEPTH_SHADOWMAP)->asOgreRenderingRun(); 134 135 MaterialPtr mat = MaterialManager::getSingleton().getByName("GTP/PathMap_ComputeWeights_Point"); 136 GpuProgramParameters* Fparams = mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters().getPointer(); 137 138 Vector3 lightPos = light->getDerivedPosition(); 139 140 Fparams->setNamedConstant("nRadionColumns", col); 141 Fparams->setNamedConstant("lightPos", lightPos); 142 Fparams->setNamedConstant("lightPower", light->getPowerScale()); 143 Fparams->setNamedConstant("lightColor", light->getDiffuseColour()); 144 Fparams->setNamedConstant("lightFarPlane", SMrun->getLightFarPlane()); 145 Fparams->setNamedConstant("lightAttenuation", Vector4(light->getAttenuationRange(), 146 light->getAttenuationConstant(), 147 light->getAttenuationLinear(), 148 light->getAttenuationQuadric())); 149 150 mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName( 151 PMEPrun->getEntryPointTextureName()); 152 mat->getTechnique(0)->getPass(0)->getTextureUnitState(1)->setTextureName( 153 SMrun->getDepthMapTextureName()); 154 155 RenderTarget* rt = allWeightsTexture->getBuffer().getPointer()->getRenderTarget(); 156 if(frameNum != rt->getLastFrameNumber()) 157 rt->getViewport(0)->setClearEveryFrame(true); 158 else 159 rt->getViewport(0)->setClearEveryFrame(false); 160 161 renderFullscreenQuad(mat->getName(), rt); 162 144 163 } 145 164 165 } 166 167 void OgrePMWeightComputeRenderingRun::sumWeights(unsigned long frameNum) 168 { 169 RenderTarget* rt = weightTexture->getBuffer().getPointer()->getRenderTarget(); 170 if(frameNum == rt->getLastFrameNumber())return; 171 172 unsigned int entryPointCnt = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().size(); 173 int col = entryPointCnt / 4096; 146 174 unsigned int clustercount = OgreIlluminationManager::getSingleton().getPathMapClusterLengthsSize(); 147 175 OgrePMEntryPointMapRenderingRun* PMEPrun = (OgrePMEntryPointMapRenderingRun*) 176 OgreIlluminationManager::getSingleton().getGlobalRun(ILLUMRUN_PM_ENTRYPOINTMAP)->asOgreRenderingRun(); 177 148 178 MaterialPtr mat = MaterialManager::getSingleton().getByName("GTP/PathMap_SumWeights"); 149 179 GpuProgramParameters* Fparams = mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters().getPointer(); … … 157 187 allWeightsTexture->getName()); 158 188 159 RenderTarget* rt = weightTexture->getBuffer().getPointer()->getRenderTarget();160 189 renderFullscreenQuad(mat->getName(), rt); 161 162 //rt->writeContentsToFile("weights.bmp");163 //rt->writeContentsToFile("weights.dds");164 /*165 float* weights = new float[clustercount];166 PixelBox lockBox(clustercount, 1, 1, PF_FLOAT32_R, weights);167 weightTexture->getBuffer()->blitToMemory(lockBox);168 169 delete[] weights;*/170 190 } 171 191 -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePhotonMapRenderingRun.cpp
r2321 r2333 100 100 if(light->getType() == Light::LT_DIRECTIONAL) 101 101 { 102 Vector3 dir = light->getD irection();102 Vector3 dir = light->getDerivedDirection(); 103 103 photonMapCamera->setDirection( dir ); 104 104 Real r = sharedRuns->getRootBoundingSphere(ILLUMRUN_PHOTONMAP).getRadius(); … … 113 113 else 114 114 { 115 Vector3 pos = light->get ParentSceneNode()->getPosition();115 Vector3 pos = light->getDerivedPosition(); 116 116 Vector3 dir = sharedRuns->getRootPosition(ILLUMRUN_PHOTONMAP) - pos; 117 117 Real r = sharedRuns->getRootBoundingSphere(ILLUMRUN_PHOTONMAP).getRadius();
Note: See TracChangeset
for help on using the changeset viewer.