Changeset 1120 for GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src
- Timestamp:
- 07/11/06 15:48:46 (18 years ago)
- Location:
- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDepthShadowRecieverRenderTechnique.cpp
r1103 r1120 45 45 GpuProgramParameters* Vparams = newpass->getVertexProgramParameters().getPointer(); 46 46 Vparams->setNamedAutoConstant("worldViewProj", 47 GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX); 48 Vparams->setNamedAutoConstant("world", 49 GpuProgramParameters::ACT_WORLD_MATRIX); 47 GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX); 50 48 GpuProgramParameters* Fparams = newpass->getFragmentProgramParameters().getPointer(); 51 49 … … 55 53 st->setTextureFiltering(TFO_BILINEAR); 56 54 57 newpass->setSceneBlending(SBT_MODULATE); 58 newpass->setDepthBias(7); 55 //newpass->setSceneBlending(SBT_MODULATE); 56 newpass->setSceneBlending(SBF_ONE, SBF_ZERO); 57 newpass->setDepthBias(1); 59 58 techn->movePass(lastpass, index); 60 59 } … … 95 94 96 95 passes.at(i)->getTextureUnitState(0)->setTextureName( 97 depthRun->getDepthMapTextureName(0)); 98 passes.at(i)->getTextureUnitState(1)->setTextureName( 99 depthRun->getDepthMapTextureName(1)); 100 96 depthRun->getDepthMapTextureName()); 97 101 98 //TODO: set matrices 102 99 GpuProgramParametersSharedPtr fpParams = passes.at(i)->getFragmentProgramParameters(); 103 fpParams->setNamedConstant("lightView", depthRun->getLightViewMatrix(0));104 fpParams->setNamedConstant("lightViewProj", depthRun->getLightViewProjMatrix(0));105 // fpParams->setNamedConstant("lightView2", depthRun->getLightViewMatrix(1));106 // fpParams->setNamedConstant("lightViewProj2", depthRun->getLightViewProjMatrix(1));100 GpuProgramParametersSharedPtr vpParams = passes.at(i)->getVertexProgramParameters(); 101 102 //fpParams->setNamedConstant("lightViewProj", depthRun->getLightViewProjMatrix()); 103 vpParams->setNamedConstant("lightViewProj", depthRun->getLightViewProjMatrix()); 107 104 108 105 passes.at(i)->setActive(true); -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp
r1103 r1120 16 16 this->light = light; 17 17 this->sharedRuns = sharedRuns; 18 names[0] = name + "1";19 names[1] = name + "2";18 this->name = name; 19 20 20 this->materialName = materialName; 21 21 … … 25 25 void OgreDepthShadowMapRenderingRun::createDepthMap() 26 26 { 27 for(int i = 0; i < 1; i++) 28 { 29 TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(names[i], 27 28 TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name, 30 29 "default", 31 30 TEX_TYPE_2D, … … 36 35 PF_FLOAT16_RGBA, 37 36 TU_RENDERTARGET); 38 depthMapTexture s[i]= texPtr.getPointer();39 depthMapCamera s[i] = Root::getSingleton()._getCurrentSceneManager()->createCamera(names[i]+ "_CAMERA");37 depthMapTexture = texPtr.getPointer(); 38 depthMapCamera = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_CAMERA"); 40 39 //add viewport to rendertarget 41 HardwarePixelBuffer* hpb = (depthMapTexture s[i]->getBuffer()).getPointer();40 HardwarePixelBuffer* hpb = (depthMapTexture->getBuffer()).getPointer(); 42 41 RenderTarget* rt = hpb->getRenderTarget(); 43 Viewport* v = rt->addViewport(depthMapCamera s[i]);42 Viewport* v = rt->addViewport(depthMapCamera); 44 43 v->setOverlaysEnabled(false); 45 rt->setAutoUpdated(false); 46 } 44 rt->setAutoUpdated(false); 47 45 } 48 46 … … 69 67 void OgreDepthShadowMapRenderingRun::updateDepthMap() 70 68 { 71 setMaterialForVisibles(materialName, depthMapCameras[0], false); 72 RenderTarget* rt = depthMapTextures[0]->getBuffer().getPointer()->getRenderTarget(); 69 setMaterialForVisibles(materialName, depthMapCamera, false); 70 RenderTarget* rt = depthMapTexture->getBuffer().getPointer()->getRenderTarget(); 71 Viewport* vp = rt->getViewport(0); 72 73 73 rt->update(); 74 74 restoreMaterials(); … … 103 103 Vector3 lightpos = light->getPosition(); 104 104 Vector3 lightdir = light->getDirection(); 105 lightdir.normalise(); 106 107 depthMapCamera->setProjectionType(PT_ORTHOGRAPHIC); 108 /*depthMapCameras[0]->setAspectRatio(1.0); 109 depthMapCameras[0]->setFOVy(Radian(Degree(20))); 110 depthMapCameras[0]->setNearClipDistance(0.1); 111 depthMapCameras[0]->setFarClipDistance(200);*/ 112 105 113 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; 114 115 116 depthMapCameras[0]->setDirection( lightdir ); 117 depthMapCameras[0]->setPosition( lightpos ); 118 119 Matrix4 projection = Matrix4::IDENTITY; 120 projection.setTrans(center); 121 projection.setScale(scale); 122 depthMapCameras[0]->setCustomProjectionMatrix(true, projection); 123 /* 114 Vector3 scale = (max - min); 115 scale *= 1.5; 116 //scale = Vector3(150,150,150); 117 Matrix4 projection = depthMapCamera->getProjectionMatrix(); 118 projection = Matrix4::IDENTITY; 119 projection.setScale(Vector3(2.0 / scale.x, 2.0 / scale.y, -2.0 / scale.z)); 120 projection.setTrans(Vector3(-(max.x + min.x) / scale.x, 121 -(max.y + min.y) / scale.y, 122 -(max.z + min.z) / scale.z)); 123 depthMapCamera->setCustomProjectionMatrix(true, projection); 124 125 depthMapCamera->setPosition(lightpos); 126 depthMapCamera->setDirection(lightdir); 127 128 /* 124 129 projection = Matrix4::IDENTITY; 125 130 projection.setScale(Vector3(1.0 / 100.0, 1.0 / 100.0, -1.0 / 100.0)); … … 161 166 } 162 167 163 Matrix4 OgreDepthShadowMapRenderingRun::getLightViewMatrix( int i)168 Matrix4 OgreDepthShadowMapRenderingRun::getLightViewMatrix() 164 169 { 165 return depthMapCamera s[i]->getViewMatrix();170 return depthMapCamera->getViewMatrix(); 166 171 } 167 172 168 Matrix4 OgreDepthShadowMapRenderingRun::getLightViewProjMatrix( int i)173 Matrix4 OgreDepthShadowMapRenderingRun::getLightViewProjMatrix() 169 174 { 170 return depthMapCamera s[i]->getProjectionMatrix() * depthMapCameras[i]->getViewMatrix();175 return depthMapCamera->getProjectionMatrixWithRSDepth() * depthMapCamera->getViewMatrix(); 171 176 } 172 177
Note: See TracChangeset
for help on using the changeset viewer.