- Timestamp:
- 07/13/06 08:16:36 (18 years ago)
- Location:
- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreIlluminationManager.h
r1103 r1130 68 68 float maxRad; 69 69 unsigned int focusingMapSize; 70 unsigned int shadowMapSize; 70 71 std::map<RenderingRunType,float> maxRads; 71 72 /** … … 151 152 void setMaxJoinRadius(RenderingRunType type, float rad){maxRads[type] = rad;} 152 153 void setFocusingMapSize(unsigned int size){focusingMapSize = size;} 154 void setShadowMapSize(unsigned int size){shadowMapSize = size;} 153 155 /** 154 156 @brief Returns the one and only OgreIlluminationManager instance. -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreDepthShadowMapRenderingRun.h
r1120 r1130 42 42 @brief returns the depth shadow map texture created by this run 43 43 */ 44 String getDepthMapTextureName(){return name;}44 String getDepthMapTextureName(){return blurredname;} 45 45 /** 46 46 @brief Refreshes light camera matrices, called in each update. … … 77 77 */ 78 78 String name; 79 String blurredname; 79 80 /** 80 81 @brief a pointer to the depth shadow texture that was created by this run 81 82 */ 82 83 Texture* depthMapTexture; 84 Texture* blurredDepthMapTexture; 83 85 84 86 //inherited -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreIlluminationManager.cpp
r1125 r1130 80 80 maxRad = 400; 81 81 focusingMapSize = 32; 82 shadowMapSize = 512; 82 83 83 84 for(int i = 0; i < RUN_TYPE_COUNT; i++) … … 578 579 lightName + "DEPTH_SHADOW_MAP", 579 580 sm->getLight(lightName), 580 128, //TODO581 128, //TODO581 shadowMapSize, 582 shadowMapSize, 582 583 "GameTools/ShadowMapDepth" //TODO 583 584 ); -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDepthShadowRecieverRenderTechnique.cpp
r1120 r1130 46 46 Vparams->setNamedAutoConstant("worldViewProj", 47 47 GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX); 48 Vparams->setNamedAutoConstant("world", 49 GpuProgramParameters::ACT_WORLD_MATRIX); 48 50 GpuProgramParameters* Fparams = newpass->getFragmentProgramParameters().getPointer(); 49 51 50 52 TextureUnitState* st = newpass->createTextureUnitState(); 51 st->setTextureFiltering(TFO_BILINEAR); 52 st = newpass->createTextureUnitState(); 53 st->setTextureFiltering(TFO_BILINEAR); 53 st->setTextureFiltering(TFO_ANISOTROPIC); 54 54 55 //newpass->setSceneBlending(SBT_MODULATE);56 newpass->setSceneBlending(SBF_ONE, SBF_ZERO);55 newpass->setSceneBlending(SBT_MODULATE); 56 //newpass->setSceneBlending(SBF_ONE, SBF_ZERO); 57 57 newpass->setDepthBias(1); 58 58 techn->movePass(lastpass, index); -
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.