- Timestamp:
- 07/07/06 17:01:43 (18 years ago)
- Location:
- GTP/trunk/Lib/Illum/IllumModule
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/SharedRuns.h
r1055 r1103 21 21 ILLUMRUN_DEPTH_SHADOWMAP, 22 22 ILLUMRUN_SCENE_CAMERA_DEPTH, 23 ILLUMRUN_HPP_IMPOSTOR 23 ILLUMRUN_HPP_IMPOSTOR, 24 ILLUMRUN_FOCUSING_MAP 24 25 }; 25 26 -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreIlluminationManager.h
r1062 r1103 67 67 */ 68 68 float maxRad; 69 unsigned int focusingMapSize; 69 70 std::map<RenderingRunType,float> maxRads; 70 71 /** … … 149 150 } 150 151 void setMaxJoinRadius(RenderingRunType type, float rad){maxRads[type] = rad;} 152 void setFocusingMapSize(unsigned int size){focusingMapSize = size;} 151 153 /** 152 154 @brief Returns the one and only OgreIlluminationManager instance. -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreDepthShadowMapRenderingRun.h
r1055 r1103 11 11 #include "DepthShadowMapRenderingRun.h" 12 12 #include "OgreSharedRuns.h" 13 #include "OgreFocusingMapRenderingRun.h" 13 14 14 15 … … 45 46 @brief Refreshes light camera matrices, called in each update. 46 47 */ 47 void refreshLight( );48 void refreshLight(unsigned long frameNum); 48 49 /** 49 50 @brief retuns the view matrix of the camera from which the depth shadow map was created -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/scripts/OgreIllumModule.vcproj
r1055 r1103 187 187 </File> 188 188 <File 189 RelativePath="..\src\RenderingRuns\OgreFocusingMapRenderingRun.cpp"> 190 </File> 191 <File 189 192 RelativePath="..\src\RenderingRuns\OgrePhotonMapRenderingRun.cpp"> 190 193 </File> … … 272 275 </File> 273 276 <File 277 RelativePath="..\include\RenderingRuns\OgreFocusingMapRenderingRun.h"> 278 </File> 279 <File 274 280 RelativePath="..\include\RenderingRuns\OgrePhotonMapRenderingRun.h"> 275 281 </File> -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreIlluminationManager.cpp
r1062 r1103 79 79 visitor = new VisibleFinderVisitor(&visibleObjects); 80 80 maxRad = 400; 81 focusingMapSize = 32; 81 82 82 83 for(int i = 0; i < RUN_TYPE_COUNT; i++) … … 571 572 572 573 } 574 case ILLUMRUN_FOCUSING_MAP: 575 if(runs->getRun(ILLUMRUN_FOCUSING_MAP) == 0) 576 { 577 SceneManager* sm = Root::getSingleton()._getCurrentSceneManager(); 578 Light* light = sm->getLight(lightName); 579 Vector3 position = light->getPosition(); 580 Vector3 direction = light->getDirection(); 581 Matrix4 transMatrix; 582 Camera cam("tempCamera", sm); 583 cam.setPosition(position); 584 cam.setDirection(direction); 585 transMatrix = cam.getViewMatrix(); 586 587 if(light->getType() == Light::LT_SPOTLIGHT) 588 { 589 Radian fov = light->getSpotlightOuterAngle(); 590 float far = light->getAttenuationRange(); 591 cam.setNearClipDistance(0.1); 592 cam.setFarClipDistance(far); 593 cam.setFOVy(fov); 594 Matrix4 proj = cam.getProjectionMatrix(); 595 transMatrix = transMatrix * proj; 596 } 597 sm->destroyCamera("tempCamera"); 598 599 OgreFocusingMapRenderingRun* run = new OgreFocusingMapRenderingRun( 600 lightName + "FOCUSING_MAP", 601 mainViewport, 602 transMatrix, 603 focusingMapSize 604 ); 605 runs->addRun(ILLUMRUN_FOCUSING_MAP, run); 606 607 } 573 608 break; 574 609 } -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDepthShadowRecieverRenderTechnique.cpp
r1055 r1103 103 103 fpParams->setNamedConstant("lightView", depthRun->getLightViewMatrix(0)); 104 104 fpParams->setNamedConstant("lightViewProj", depthRun->getLightViewProjMatrix(0)); 105 fpParams->setNamedConstant("lightView2", depthRun->getLightViewMatrix(1));106 fpParams->setNamedConstant("lightViewProj2", depthRun->getLightViewProjMatrix(1));105 // fpParams->setNamedConstant("lightView2", depthRun->getLightViewMatrix(1)); 106 // fpParams->setNamedConstant("lightViewProj2", depthRun->getLightViewProjMatrix(1)); 107 107 108 108 passes.at(i)->setActive(true); -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp
r1055 r1103 25 25 void OgreDepthShadowMapRenderingRun::createDepthMap() 26 26 { 27 for(int i = 0; i < 2; i++)27 for(int i = 0; i < 1; i++) 28 28 { 29 29 TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(names[i], … … 49 49 void OgreDepthShadowMapRenderingRun::updateFrame(unsigned long frameNum) 50 50 { 51 refreshLight( );51 refreshLight(frameNum); 52 52 53 53 if(light->getType() == Light::LT_POINT) … … 69 69 void OgreDepthShadowMapRenderingRun::updateDepthMap() 70 70 { 71 setMaterialForVisibles(materialName, depthMapCameras[0], true);71 setMaterialForVisibles(materialName, depthMapCameras[0], false); 72 72 RenderTarget* rt = depthMapTextures[0]->getBuffer().getPointer()->getRenderTarget(); 73 73 rt->update(); 74 //restoreMaterials();74 restoreMaterials(); 75 75 //rt->writeContentsToFile("shadowmap1.dds"); 76 77 //setMaterialForVisibles(materialName, depthMapCameras[1], true);78 RenderTarget* rt2 = depthMapTextures[1]->getBuffer().getPointer()->getRenderTarget();79 rt2->update();80 restoreMaterials();81 //rt2->writeContentsToFile("shadowmap2.dds");82 83 84 76 } 85 77 … … 89 81 } 90 82 91 void OgreDepthShadowMapRenderingRun::refreshLight( )83 void OgreDepthShadowMapRenderingRun::refreshLight(unsigned long frameNum) 92 84 { 93 85 … … 96 88 if(light->getType() == Light::LT_DIRECTIONAL) 97 89 { 98 //Vector3 dir = light->getDirection();99 Vector3 dir = Vector3(0,-1,-1);100 Vector3 pos;101 float size;102 103 90 Camera* viewcam = OgreIlluminationManager::getSingleton().getMainCamera(); 104 91 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(); 92 OgreIlluminationManager::getSingleton().updatePerLightRun(light->getName(), 93 ILLUMRUN_FOCUSING_MAP, 94 frameNum); 95 96 OgreFocusingMapRenderingRun* frun = (OgreFocusingMapRenderingRun*) 97 OgreIlluminationManager::getSingleton().getPerLightRun(light->getName(), ILLUMRUN_FOCUSING_MAP)->asOgreRenderingRun(); 116 98 117 //TODO: where to put light 118 size = 30; 119 pos = Vector3(0,0,0); 99 Vector3 min; 100 Vector3 max; 101 frun->getMinMax(min, max); 102 103 Vector3 lightpos = light->getPosition(); 104 Vector3 lightdir = light->getDirection(); 120 105 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); 106 Vector3 center = (min + max) / 2.0; 107 Vector3 scale = max - min; 108 scale.x = 2.0 / scale.x; 109 scale.y = 2.0 / scale.y; 110 scale.z = 2.0 / scale.z; 111 center.x *= scale.x; 112 center.y *= scale.y; 113 center.z *= scale.z; 131 114 132 115 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; 116 depthMapCameras[0]->setDirection( lightdir ); 117 depthMapCameras[0]->setPosition( lightpos ); 167 118 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;*/ 119 Matrix4 projection = Matrix4::IDENTITY; 120 projection.setTrans(center); 121 projection.setScale(scale); 122 depthMapCameras[0]->setCustomProjectionMatrix(true, projection); 123 /* 124 projection = Matrix4::IDENTITY; 125 projection.setScale(Vector3(1.0 / 100.0, 1.0 / 100.0, -1.0 / 100.0)); 126 depthMapCameras[0]->setCustomProjectionMatrix(true, projection); 127 depthMapCameras[0]->setPosition( Vector3(50,50,50) );*/ 175 128 176 129 }
Note: See TracChangeset
for help on using the changeset viewer.