- Timestamp:
- 07/13/06 08:16:36 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp
r1125 r1130 17 17 this->sharedRuns = sharedRuns; 18 18 this->name = name; 19 this->blurredname = name + "blurred"; 19 20 20 21 this->materialName = materialName; … … 34 35 0, 35 36 PF_FLOAT16_RGBA, 36 TU_RENDERTARGET); 37 TU_RENDERTARGET); 37 38 depthMapTexture = texPtr.getPointer(); 38 39 depthMapCamera = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_CAMERA"); … … 42 43 Viewport* v = rt->addViewport(depthMapCamera); 43 44 v->setOverlaysEnabled(false); 44 rt->setAutoUpdated(false); 45 rt->setAutoUpdated(false); 46 47 texPtr = Ogre::TextureManager::getSingleton().createManual(blurredname, 48 "default", 49 TEX_TYPE_2D, 50 resolutionX, 51 resolutionY, 52 6, 53 0, 54 PF_FLOAT16_RGBA, 55 TU_RENDERTARGET); 56 blurredDepthMapTexture = texPtr.getPointer(); 57 hpb = (blurredDepthMapTexture->getBuffer()).getPointer(); 58 rt = hpb->getRenderTarget(); 59 v = rt->addViewport(depthMapCamera); 60 v->setOverlaysEnabled(false); 61 rt->setAutoUpdated(false); 45 62 } 46 63 … … 56 73 { 57 74 updateDepthMap(); 58 } 59 60 75 } 61 76 } 62 77 … … 73 88 rt->update(); 74 89 restoreMaterials(); 75 rt->writeContentsToFile("shadowmap1.dds"); 90 91 rt = blurredDepthMapTexture->getBuffer().getPointer()->getRenderTarget(); 92 Material* mat = (Material*) MaterialManager::getSingleton().getByName("GameTools/Blur").getPointer(); 93 mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(depthMapTexture->getName()); 94 renderFullscreenQuad("GameTools/Blur", rt); 95 96 97 //rt->writeContentsToFile("shadowmap1.dds"); 98 99 //depthMapTexture->(); 76 100 } 77 101 … … 118 142 //left = lightdir.crossProduct(up); 119 143 left.normalise(); 120 121 144 Matrix4 viewMatrix( left.x, left.y, left.z, 0, 122 145 up.x, up.y, up.z, 0, … … 142 165 143 166 Vector3 pos = campos - up * (n - nearclip); 144 145 167 Matrix4 newViewMatrix( left.x, left.y, left.z, -left.dotProduct(pos), 146 168 up.x, up.y, up.z, -up.dotProduct(pos), … … 148 170 0, 0, 0, 1); 149 171 150 151 Matrix4 newProjection = Matrix4::IDENTITY; 152 153 newProjection[1][1] = (f + n) / (f - n); 154 newProjection[1][3] = - 2* f * n / (f - n); 155 newProjection[3][1] = 1; 156 newProjection[3][3] = 0; 157 //newProjection = newProjection.transpose(); 158 Matrix4 standardProjMatrix = Matrix4::IDENTITY; 159 standardProjMatrix.setScale(Vector3(1,1,-1)); 160 newProjection = newProjection * standardProjMatrix; 161 depthMapCamera->setCustomProjectionMatrix(true, newProjection); 162 depthMapCamera->setCustomViewMatrix(true, viewMatrix); 172 Matrix4 lispMat = Matrix4::IDENTITY; 173 174 lispMat[1][1] = f / (f - n); 175 lispMat[1][3] = f * n / (f - n); 176 lispMat[3][1] = 1; 177 lispMat[3][3] = 0; 178 179 depthMapCamera->setCustomProjectionMatrix(true, Matrix4::IDENTITY); 180 depthMapCamera->setCustomViewMatrix(true, lispMat * newViewMatrix); 163 181 } 164 182 else 165 183 { 166 Matrix4 standardProjMatrix = Matrix4::IDENTITY; 167 standardProjMatrix.setScale(Vector3(0,0,-1)); 168 depthMapCamera->setCustomProjectionMatrix(true, standardProjMatrix); 184 depthMapCamera->setCustomProjectionMatrix(true, Matrix4::IDENTITY); 169 185 depthMapCamera->setCustomViewMatrix(false); 170 depthMapCamera->setProjectionType(PT_ORTHOGRAPHIC);171 186 depthMapCamera->setPosition(lightpos); 172 depthMapCamera->setDirection(lightdir); 187 depthMapCamera->setDirection(lightdir); 173 188 } 174 189 175 190 176 Matrix4 lightMatrix = depthMapCamera->get ProjectionMatrix() * depthMapCamera->getViewMatrix();191 Matrix4 lightMatrix = depthMapCamera->getViewMatrix(); 177 192 frun->setLightMatrix(lightMatrix); 178 193 … … 191 206 -(max.y + min.y) / scale.y, 192 207 -(max.z + min.z) / scale.z)); 193 projection = projection * depthMapCamera->getProjectionMatrix(); 194 depthMapCamera->setCustomProjectionMatrix(true, projection); 195 196 197 208 depthMapCamera->setCustomProjectionMatrix(true, projection); 198 209 } 199 210 else if(light->getType() == Light::LT_SPOTLIGHT)
Note: See TracChangeset
for help on using the changeset viewer.