- Timestamp:
- 03/07/07 17:34:13 (18 years ago)
- Location:
- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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.