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/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 
Note: See TracChangeset for help on using the changeset viewer.