Changeset 2200
- Timestamp:
- 03/07/07 17:34:13 (18 years ago)
- Location:
- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreIlluminationManager.h
r2189 r2200 34 34 Vector3 position; 35 35 Vector3 normal; 36 float prob; 36 37 }; 37 38 /** -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgrePathMapRenderTechnique.h
r2189 r2200 57 57 Pass* pathMapPass; 58 58 PathMapClusters* clusters; 59 Texture* weightIndexTexture; 60 61 void createWeightIndexTexture(); 59 62 }; 60 63 -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgrePMEntryPointMapRenderingRun.h
r2189 r2200 29 29 */ 30 30 String getEntryPointTextureName(){return name;} 31 String getClusterLengthTextureName(){return clusterLengthTexture->getName();} 31 32 32 33 protected: … … 39 40 */ 40 41 Texture* entryPointTexture; 42 Texture* clusterLengthTexture; 41 43 42 44 //inherited -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgrePMWeightComputeRenderingRun.h
r2189 r2200 28 28 @brief returns the name of the camera depth texture 29 29 */ 30 String getPMWeightTetureName(){return name;}30 String getPMWeightTetureName(){return weightTexture->getName();} 31 31 float* getWeights(){return weights;} 32 32 … … 45 45 */ 46 46 Texture* weightTexture; 47 Texture* allWeightsTexture; 47 48 48 49 Light* light; … … 54 55 55 56 inline void createWeightMap(); 56 57 bool needUpdate(unsigned long frameNum )58 {59 return true;60 }61 62 57 }; -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreIlluminationManager.cpp
r2189 r2200 224 224 sharedruns->updateBounds(); 225 225 } 226 String newMaterialName = mat->getName() + rend->getName() + "_clone";226 String newMaterialName = mat->getName() + "_clone_" + rend->getName(); 227 227 Material* newMat = mat->clone(newMaterialName).getPointer(); 228 mat = newMat;229 228 rend->setMaterialName(newMaterialName); 229 mat = sube->getMaterial().getPointer(); 230 230 break; 231 231 } -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreCausticCasterRenderTechnique.cpp
r2027 r2200 30 30 this->blurCauCubeMap = blurCauCubeMap; 31 31 32 String newMaterialName = causticMapMaterialName + parentRenderable->getName() + "_clone";32 String newMaterialName = causticMapMaterialName + "_clone_" + parentRenderable->getName(); 33 33 Material* mat = (Material*) MaterialManager::getSingleton().getByName(causticMapMaterialName).getPointer(); 34 34 Material* newMat = mat->clone(newMaterialName).getPointer(); -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgrePathMapRenderTechnique.cpp
r2189 r2200 50 50 Vector4 pathMapParameters(prmnt[0],prmnt[1],halfPixel[0],halfPixel[1]); 51 51 Fparams->setNamedConstant("prmAtlasTilesHalfPixel",pathMapParameters); 52 52 unsigned int clustercount = OgreIlluminationManager::getSingleton().getPathMapClusterLengthsSize(); 53 Fparams->setNamedConstant("allClusterCount", (float) clustercount); 54 PathMapClusters* clusters = OgreIlluminationManager::getSingleton().getPathMapClusters(parentOgreRenderable->getName()); 55 Fparams->setNamedConstant("clusterCount", (float) clusters->count); 56 53 57 TextureUnitState* st = newpass->createTextureUnitState(); 54 58 st->setTextureFiltering(TFO_BILINEAR); 55 59 st->setTextureAddressingMode(TextureUnitState::TAM_BORDER); 60 st->setTextureBorderColour(ColourValue::Green); 61 st->setTextureName(clusters->pathMapTextureFilename); 62 63 createWeightIndexTexture(); 64 65 st = newpass->createTextureUnitState(); 66 st->setTextureFiltering(TFO_NONE); 67 st->setTextureAddressingMode(TextureUnitState::TAM_BORDER); 68 st->setTextureBorderColour(ColourValue::Red); 69 st->setTextureName(weightIndexTexture->getName()); 70 71 st = newpass->createTextureUnitState(); 72 st->setTextureFiltering(TFO_NONE); 73 st->setTextureAddressingMode(TextureUnitState::TAM_BORDER); 56 74 st->setTextureBorderColour(ColourValue::Blue); 57 st->setTextureName(clusters->pathMapTextureFilename);58 75 59 76 //newpass->setSceneBlending(SBT_MODULATE); … … 70 87 } 71 88 89 void OgrePathMapRenderTechnique::createWeightIndexTexture() 90 { 91 PathMapClusters* clusters = OgreIlluminationManager::getSingleton().getPathMapClusters(parentOgreRenderable->getName()); 92 int width = clusters->count / 4; 93 TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(this->parentOgreRenderable->getName() + "_PMWeightIndexTexture", 94 "default", 95 TEX_TYPE_1D, 96 width, 97 1, 98 0, 99 0, 100 PF_FLOAT32_RGBA, 101 TU_DYNAMIC_WRITE_ONLY); 102 weightIndexTexture = texPtr.getPointer(); 103 104 float *weightIndices = new float[clusters->count]; 105 PixelBox lockBox(width, 1, 1, PF_FLOAT32_RGBA, weightIndices); 106 for(int j = 0; j< clusters->count; j++) 107 weightIndices[j] = clusters->clusters[j]; 108 weightIndexTexture->getBuffer()->blitFromMemory(lockBox); 109 delete[] weightIndices; 110 } 111 72 112 void OgrePathMapRenderTechnique::update(unsigned long frameNum) 73 113 { … … 76 116 sm->_populateLightList(Vector3(0,0,0), 1000, lights); //TODO 77 117 //TODO set weights 78 PathMapClusters* clusters = OgreIlluminationManager::getSingleton().getPathMapClusters(parentOgreRenderable->getName());79 float *actualWeights = new float[clusters->count];//TODO = 0118 119 80 120 for(int i = 0 ; i < 1; i++) 81 121 { … … 86 126 OgreIlluminationManager::getSingleton().getPerLightRun(lightName, ILLUMRUN_PM_WEIGHTMAP)->asOgreRenderingRun(); 87 127 88 float* weights = PMWeightRun->getWeights(); 89 90 for(int j = 0; j< clusters->count; j++) 91 actualWeights[j] = weights[clusters->clusters[j]]; 92 128 TextureUnitState* st =pathMapPass->getTextureUnitState(2); 129 st->setTextureName(PMWeightRun->getPMWeightTetureName()); 93 130 } 94 95 GpuProgramParameters* Fparams = pathMapPass->getFragmentProgramParameters().getPointer();96 Fparams->setNamedConstant("weights", actualWeights, clusters->count);97 131 } 98 132 -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePMEntryPointMapRenderingRun.cpp
r2189 r2200 43 43 tm[i].dir[1] = EP->normal.y; 44 44 tm[i].dir[2] = EP->normal.z; 45 tm[i].dir[3] = 1.0;45 tm[i].dir[3] = EP->prob; 46 46 } 47 47 48 48 PixelBox lockBox(width, height, 1, PF_FLOAT32_RGBA, tm); 49 49 entryPointTexture->getBuffer()->blitFromMemory(lockBox); 50 51 delete[] tm; 52 53 int clusterCount = OgreIlluminationManager::getSingleton().getPathMapClusterLengthsSize(); 54 width = clusterCount; 55 height = 2; 56 texPtr = Ogre::TextureManager::getSingleton().createManual(name + "_CL", 57 "default", 58 TEX_TYPE_2D, 59 width, 60 height, 61 0, 62 0, 63 PF_FLOAT32_R, 64 TU_RENDERTARGET); 65 clusterLengthTexture = texPtr.getPointer(); 66 67 float* data = new float[clusterCount * 2]; 68 unsigned int entryPointCount = 0; 69 for(int i = 0; i < clusterCount; i++) 70 { 71 unsigned int clusterSize = OgreIlluminationManager::getSingleton().getPathMapClusterLength(i); 72 data[i] = clusterSize;//clustercount 73 data[clusterCount + i] = entryPointCount; 74 entryPointCount += clusterSize; 75 } 76 77 PixelBox lockBox2(width, height, 1, PF_FLOAT32_R, data); 78 clusterLengthTexture->getBuffer()->blitFromMemory(lockBox2); 79 80 delete[] data; 50 81 } 51 82 -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePMWeightComputeRenderingRun.cpp
r2189 r2200 22 22 int width = entryPointCnt / 4096; 23 23 int height = 4096; 24 TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name ,24 TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name + "_ALL", 25 25 "default", 26 26 TEX_TYPE_2D, … … 29 29 0, 30 30 0, 31 PF_FLOAT32_R ,31 PF_FLOAT32_RGBA, 32 32 TU_RENDERTARGET); 33 allWeightsTexture = texPtr.getPointer(); 34 //add viewport to rendertarget 35 HardwarePixelBuffer* hpb = (allWeightsTexture->getBuffer()).getPointer(); 36 RenderTarget* rt = hpb->getRenderTarget(); 37 Camera* wc = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_ALL_CAMERA"); 38 Viewport* v = rt->addViewport(wc); 39 v->setOverlaysEnabled(false); 40 rt->setAutoUpdated(false); 41 42 unsigned int clustercount = OgreIlluminationManager::getSingleton().getPathMapClusterLengthsSize(); 43 width = clustercount; 44 height = 1; 45 texPtr = Ogre::TextureManager::getSingleton().createManual(name, 46 "default", 47 TEX_TYPE_2D, 48 width, 49 height, 50 0, 51 0, 52 PF_FLOAT32_RGBA, 53 TU_RENDERTARGET); 33 54 weightTexture = texPtr.getPointer(); 34 55 //add viewport to rendertarget 35 HardwarePixelBuffer*hpb = (weightTexture->getBuffer()).getPointer();36 RenderTarget*rt = hpb->getRenderTarget();37 Camera*wc = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_CAMERA");38 Viewport*v = rt->addViewport(wc);56 hpb = (weightTexture->getBuffer()).getPointer(); 57 rt = hpb->getRenderTarget(); 58 wc = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_CAMERA"); 59 v = rt->addViewport(wc); 39 60 v->setOverlaysEnabled(false); 40 61 rt->setAutoUpdated(false); … … 45 66 void OgrePMWeightComputeRenderingRun::updateFrame(unsigned long frameNum) 46 67 { 47 switch(light->getType()) 68 OgreIlluminationManager::getSingleton().updateGlobalRun(ILLUMRUN_PM_ENTRYPOINTMAP, frameNum); 69 OgrePMEntryPointMapRenderingRun* PMEPrun = (OgrePMEntryPointMapRenderingRun*) 70 OgreIlluminationManager::getSingleton().getGlobalRun(ILLUMRUN_PM_ENTRYPOINTMAP)->asOgreRenderingRun(); 71 unsigned int entryPointCnt = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().size(); 72 int col = entryPointCnt / 4096; 73 74 if(light->getType() == Light::LT_SPOTLIGHT) 48 75 { 49 case Light::LT_SPOTLIGHT:76 MaterialPtr mat = MaterialManager::getSingleton().getByName("GTP/PathMap_ComputeWeights"); 50 77 51 MaterialPtr mat = MaterialManager::getSingleton().getByName("GTP/PathMap_ComputeWeights"); 52 53 GpuProgramParameters* Fparams = mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters().getPointer(); 78 GpuProgramParameters* Fparams = mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters().getPointer(); 54 79 55 80 Vector3 lightPos = light->getPosition(); 56 81 Vector3 lightDir = light->getDirection(); 57 82 // Radian lightAngle = light->getSpotlightOuterAngle(); 58 unsigned int entryPointCnt = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().size(); 59 int col = entryPointCnt / 4096; 60 83 61 84 //Fparams->setNamedConstant("lightTransform", lightMatrix); 62 85 Fparams->setNamedConstant("nRadionColumns", col); 63 86 Fparams->setNamedConstant("lightPos", lightPos); 64 87 Fparams->setNamedConstant("lightDir", lightDir); 65 66 OgrePMEntryPointMapRenderingRun* PMEPrun = (OgrePMEntryPointMapRenderingRun*) 67 OgreIlluminationManager::getSingleton().getGlobalRun(ILLUMRUN_PM_ENTRYPOINTMAP)->asOgreRenderingRun(); 88 68 89 mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName( 69 90 PMEPrun->getEntryPointTextureName()); 70 91 71 RenderTarget* rt = weightTexture->getBuffer().getPointer()->getRenderTarget();92 RenderTarget* rt = allWeightsTexture->getBuffer().getPointer()->getRenderTarget(); 72 93 renderFullscreenQuad(mat->getName(), rt); 73 94 74 //rt->writeContentsToFile("focusingmap.dds"); 75 76 77 break; 95 rt->writeContentsToFile("allweights.bmp"); 96 rt->writeContentsToFile("allweights.dds"); 97 } 98 else 99 { 100 ///not implemented 78 101 } 79 102 80 103 unsigned int clustercount = OgreIlluminationManager::getSingleton().getPathMapClusterLengthsSize(); 81 if(weights == 0) 82 weights = new float[clustercount]; 104 105 MaterialPtr mat = MaterialManager::getSingleton().getByName("GTP/PathMap_SumWeights"); 106 GpuProgramParameters* Fparams = mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters().getPointer(); 107 Fparams->setNamedConstant("nRadionColumns", col); 108 Fparams->setNamedConstant("clusterCount", (float) clustercount); 109 mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName( 110 PMEPrun->getEntryPointTextureName()); 111 mat->getTechnique(0)->getPass(0)->getTextureUnitState(1)->setTextureName( 112 PMEPrun->getClusterLengthTextureName()); 113 mat->getTechnique(0)->getPass(0)->getTextureUnitState(2)->setTextureName( 114 allWeightsTexture->getName()); 83 115 84 unsigned int entryPointCnt = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().size(); 85 int width = entryPointCnt / 4096; 86 int height = 4096; 87 unsigned int buffersize = width * height; 88 float* allEntryWeights = new float[buffersize]; 89 PixelBox lockBox(width, height, 1, PF_FLOAT32_R, allEntryWeights); 90 weightTexture->getBuffer()->blitToMemory(lockBox); 116 RenderTarget* rt = weightTexture->getBuffer().getPointer()->getRenderTarget(); 117 renderFullscreenQuad(mat->getName(), rt); 91 118 92 int iRadion = 0; 93 for(int iCluster=0; iCluster < clustercount; iCluster++) 94 { 95 weights[iCluster] = 0.0; 96 for(int clusterSummer=0; 97 clusterSummer < OgreIlluminationManager::getSingleton().getPathMapClusterLength(iCluster); 98 clusterSummer++, iRadion++) 99 { 100 weights[iCluster] += allEntryWeights[iRadion]; 101 } 102 if(weights[iCluster] <= 0) 103 weights[iCluster] /= OgreIlluminationManager::getSingleton().getPathMapClusterLength(iCluster); //(double)clusterLenghts[iCluster]; 104 else 105 weights[iCluster] = 0.0f; 106 } 119 rt->writeContentsToFile("weights.bmp"); 120 rt->writeContentsToFile("weights.dds"); 107 121 } 108 122
Note: See TracChangeset
for help on using the changeset viewer.