- Timestamp:
- 06/26/06 09:52:08 (19 years ago)
- Location:
- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
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.