Ignore:
Timestamp:
03/07/07 17:34:13 (17 years ago)
Author:
szirmay
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePMWeightComputeRenderingRun.cpp

    r2189 r2200  
    2222        int width = entryPointCnt / 4096; 
    2323        int height = 4096; 
    24         TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name,  
     24        TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name + "_ALL",  
    2525                                                                                                                                                "default", 
    2626                                                                                                                                                TEX_TYPE_2D, 
     
    2929                                                                                                                                                0, 
    3030                                                                                                                                                0, 
    31                                                                                                                                                 PF_FLOAT32_R, 
     31                                                                                                                                                PF_FLOAT32_RGBA, 
    3232                                                                                                                                                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); 
    3354         weightTexture = texPtr.getPointer(); 
    3455         //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); 
    3960         v->setOverlaysEnabled(false); 
    4061         rt->setAutoUpdated(false); 
     
    4566void OgrePMWeightComputeRenderingRun::updateFrame(unsigned long frameNum) 
    4667{ 
    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) 
    4875        { 
    49                 case Light::LT_SPOTLIGHT: 
     76                MaterialPtr mat = MaterialManager::getSingleton().getByName("GTP/PathMap_ComputeWeights"); 
    5077 
    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(); 
    5479                         
    5580                        Vector3 lightPos = light->getPosition(); 
    5681                        Vector3 lightDir = light->getDirection(); 
    5782                //      Radian lightAngle = light->getSpotlightOuterAngle(); 
    58                         unsigned int entryPointCnt = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().size(); 
    59                         int col = entryPointCnt / 4096;  
    60  
     83                         
    6184                        //Fparams->setNamedConstant("lightTransform", lightMatrix); 
    6285                        Fparams->setNamedConstant("nRadionColumns", col); 
    6386                        Fparams->setNamedConstant("lightPos", lightPos); 
    6487                        Fparams->setNamedConstant("lightDir", lightDir); 
    65  
    66                         OgrePMEntryPointMapRenderingRun* PMEPrun = (OgrePMEntryPointMapRenderingRun*) 
    67                                         OgreIlluminationManager::getSingleton().getGlobalRun(ILLUMRUN_PM_ENTRYPOINTMAP)->asOgreRenderingRun(); 
     88                         
    6889                        mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName( 
    6990                                                PMEPrun->getEntryPointTextureName()); 
    7091                                 
    71                         RenderTarget* rt = weightTexture->getBuffer().getPointer()->getRenderTarget(); 
     92                        RenderTarget* rt = allWeightsTexture->getBuffer().getPointer()->getRenderTarget(); 
    7293                        renderFullscreenQuad(mat->getName(), rt); 
    7394 
    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 
    78101        } 
    79102 
    80103        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()); 
    83115         
    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); 
    91118 
    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");  
    107121} 
    108122 
Note: See TracChangeset for help on using the changeset viewer.