Changeset 2200


Ignore:
Timestamp:
03/07/07 17:34:13 (17 years ago)
Author:
szirmay
Message:
 
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  
    3434    Vector3 position; 
    3535        Vector3 normal; 
     36        float prob; 
    3637}; 
    3738/** 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderTechniques/OgrePathMapRenderTechnique.h

    r2189 r2200  
    5757        Pass* pathMapPass; 
    5858        PathMapClusters* clusters;       
     59        Texture* weightIndexTexture; 
     60 
     61        void createWeightIndexTexture(); 
    5962}; 
    6063 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgrePMEntryPointMapRenderingRun.h

    r2189 r2200  
    2929        */ 
    3030        String getEntryPointTextureName(){return name;} 
     31        String getClusterLengthTextureName(){return clusterLengthTexture->getName();} 
    3132         
    3233protected: 
     
    3940        */ 
    4041        Texture* entryPointTexture; 
     42        Texture* clusterLengthTexture; 
    4143         
    4244        //inherited 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgrePMWeightComputeRenderingRun.h

    r2189 r2200  
    2828                @brief returns the name of the camera depth texture 
    2929        */ 
    30         String getPMWeightTetureName(){return name;} 
     30        String getPMWeightTetureName(){return weightTexture->getName();} 
    3131        float* getWeights(){return weights;} 
    3232         
     
    4545        */ 
    4646        Texture* weightTexture; 
     47        Texture* allWeightsTexture; 
    4748         
    4849        Light* light; 
     
    5455         
    5556        inline void createWeightMap(); 
    56  
    57         bool needUpdate(unsigned long frameNum ) 
    58         { 
    59                 return true; 
    60         } 
    61  
    6257}; 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreIlluminationManager.cpp

    r2189 r2200  
    224224                                                sharedruns->updateBounds(); 
    225225                                        } 
    226                                         String newMaterialName = mat->getName() + rend->getName() + "_clone"; 
     226                                        String newMaterialName = mat->getName() + "_clone_" + rend->getName(); 
    227227                                        Material* newMat = mat->clone(newMaterialName).getPointer(); 
    228                                         mat = newMat; 
    229228                                        rend->setMaterialName(newMaterialName); 
     229                                        mat = sube->getMaterial().getPointer(); 
    230230                                        break; 
    231231                                } 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreCausticCasterRenderTechnique.cpp

    r2027 r2200  
    3030        this->blurCauCubeMap = blurCauCubeMap; 
    3131         
    32         String newMaterialName = causticMapMaterialName + parentRenderable->getName() + "_clone"; 
     32        String newMaterialName = causticMapMaterialName + "_clone_" + parentRenderable->getName(); 
    3333        Material* mat = (Material*) MaterialManager::getSingleton().getByName(causticMapMaterialName).getPointer(); 
    3434        Material* newMat = mat->clone(newMaterialName).getPointer(); 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgrePathMapRenderTechnique.cpp

    r2189 r2200  
    5050        Vector4 pathMapParameters(prmnt[0],prmnt[1],halfPixel[0],halfPixel[1]); 
    5151        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         
    5357        TextureUnitState* st = newpass->createTextureUnitState();                
    5458        st->setTextureFiltering(TFO_BILINEAR); 
    5559        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); 
    5674        st->setTextureBorderColour(ColourValue::Blue); 
    57         st->setTextureName(clusters->pathMapTextureFilename); 
    5875         
    5976        //newpass->setSceneBlending(SBT_MODULATE); 
     
    7087} 
    7188 
     89void 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 
    72112void OgrePathMapRenderTechnique::update(unsigned long frameNum) 
    73113{        
     
    76116        sm->_populateLightList(Vector3(0,0,0), 1000, lights); //TODO 
    77117//TODO set weights 
    78         PathMapClusters* clusters = OgreIlluminationManager::getSingleton().getPathMapClusters(parentOgreRenderable->getName()); 
    79         float *actualWeights = new float[clusters->count];//TODO = 0 
     118         
     119         
    80120        for(int i = 0 ; i < 1; i++) 
    81121        { 
     
    86126                        OgreIlluminationManager::getSingleton().getPerLightRun(lightName, ILLUMRUN_PM_WEIGHTMAP)->asOgreRenderingRun(); 
    87127 
    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());                                
    93130        } 
    94  
    95         GpuProgramParameters* Fparams = pathMapPass->getFragmentProgramParameters().getPointer(); 
    96         Fparams->setNamedConstant("weights", actualWeights, clusters->count); 
    97131} 
    98132 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePMEntryPointMapRenderingRun.cpp

    r2189 r2200  
    4343                tm[i].dir[1] = EP->normal.y; 
    4444                tm[i].dir[2] = EP->normal.z; 
    45                 tm[i].dir[3] = 1.0; 
     45                tm[i].dir[3] = EP->prob; 
    4646        }        
    4747 
    4848        PixelBox lockBox(width, height, 1, PF_FLOAT32_RGBA, tm); 
    4949        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; 
    5081} 
    5182 
  • 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.