Changeset 2333 for GTP/trunk/Lib/Illum


Ignore:
Timestamp:
04/24/07 14:04:48 (17 years ago)
Author:
szirmay
Message:
 
Location:
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreIlluminationManager.h

    r2320 r2333  
    130130                @brief Size of the shadow maps. 
    131131        */ 
    132         unsigned int shadowMapSize; 
     132        unsigned int shadowMapSizePoint; 
     133        unsigned int shadowMapSizeSpot; 
     134        unsigned int shadowMapSizeDirectional; 
    133135        /** 
    134136                @brief Size of area lights for soft shadows. 
     
    138140                @brief Sets if light space perspective shadow mapping should be used. 
    139141        */ 
    140         bool useLISPSM; 
     142        bool useLISPSMPoint; 
     143        bool useLISPSMSpot; 
     144        bool useLISPSMDirectional; 
    141145        /** 
    142146                @brief Sets if the shadow maps should be blurred. 
     
    144148                Used in variance shadow mapping. 
    145149        */ 
    146         bool blurSM; 
     150        bool blurSMPoint; 
     151        bool blurSMSpot; 
     152        bool blurSMDirectional; 
    147153        /** 
    148154                @brief Sets if shadow maps should be focused. 
    149155        */ 
    150         bool focusingSM; 
     156        bool focusingSMPoint; 
     157        bool focusingSMSpot; 
     158        bool focusingSMDirectional; 
    151159        /** 
    152160                @brief The material name that should be used during rendering the shadow maps. 
     
    166174                 - directional lights : GTP/Basic/Depth or GTP/Basic/DepthCCW 
    167175        */ 
    168         String shadowMapMaterialName; 
     176        String shadowMapMaterialNamePoint; 
     177        String shadowMapMaterialNameSpot; 
     178        String shadowMapMaterialNameDirectional; 
    169179        /** 
    170180                @brief Size of the phase texture. 
     
    241251        std::vector<UpdateListener*> updateListeners; 
    242252 
     253        bool joinRuns; 
     254 
    243255public: 
     256 
     257        void joinSharedRuns(bool join){joinRuns = join;} 
    244258        /** 
    245259                @brief Registers an UpdateListener instance. @see UpdateListener 
     
    296310                @see shadowMapSize 
    297311        */ 
    298         void setShadowMapSize(unsigned int size){shadowMapSize = size;} 
     312        void setShadowMapSize(unsigned int size) 
     313        { 
     314                shadowMapSizeDirectional = size; 
     315                shadowMapSizePoint = size; 
     316                shadowMapSizeSpot = size; 
     317        } 
     318        void setShadowMapSize(Light::LightTypes type, unsigned int size) 
     319        { 
     320                switch(type) 
     321                { 
     322                        case Light::LT_DIRECTIONAL: 
     323                                shadowMapSizeDirectional = size;break; 
     324                        case Light::LT_POINT: 
     325                                shadowMapSizePoint = size;break; 
     326                        case Light::LT_SPOTLIGHT: 
     327                                shadowMapSizeSpot = size;break; 
     328                } 
     329        } 
    299330        /** 
    300331                @brief Returns the one and only OgreIlluminationManager instance. 
     
    454485                @see useLISPSM 
    455486        */ 
    456         bool getUseLISPSM(){return useLISPSM;} 
     487        bool getUseLISPSM(Light::LightTypes type) 
     488        { 
     489                switch(type) 
     490                { 
     491                        case Light::LT_DIRECTIONAL: 
     492                        return useLISPSMDirectional; 
     493                        case Light::LT_POINT: 
     494                        return useLISPSMPoint; 
     495                        case Light::LT_SPOTLIGHT: 
     496                        return useLISPSMSpot; 
     497                } 
     498        } 
    457499        /** 
    458500                @see focusingSM 
    459501        */ 
    460         bool getFocusingShadowMap(){return focusingSM;} 
     502        bool getFocusingShadowMap(Light::LightTypes type) 
     503        { 
     504                switch(type) 
     505                { 
     506                        case Light::LT_DIRECTIONAL: 
     507                        return focusingSMDirectional; 
     508                        case Light::LT_POINT: 
     509                        return focusingSMPoint; 
     510                        case Light::LT_SPOTLIGHT: 
     511                        return focusingSMSpot; 
     512                } 
     513        } 
    461514        /** 
    462515                @see blurSM 
    463516        */ 
    464         bool getBlurShadowMap(){return blurSM;} 
     517        bool getBlurShadowMap(Light::LightTypes type) 
     518        { 
     519                switch(type) 
     520                { 
     521                        case Light::LT_DIRECTIONAL: 
     522                        return blurSMDirectional; 
     523                        case Light::LT_POINT: 
     524                        return blurSMPoint; 
     525                        case Light::LT_SPOTLIGHT: 
     526                        return blurSMSpot; 
     527                } 
     528        } 
    465529        /** 
    466530                @see useLISPSM 
    467531        */ 
    468         void setUseLISPSM(bool use){useLISPSM = use;} 
     532        void setUseLISPSM(bool use) 
     533        { 
     534                useLISPSMDirectional = use; 
     535                useLISPSMPoint = use; 
     536                useLISPSMSpot = use; 
     537        } 
     538        void setUseLISPSM(Light::LightTypes type, bool use) 
     539        { 
     540                switch(type) 
     541                { 
     542                        case Light::LT_DIRECTIONAL: 
     543                                useLISPSMDirectional = use;break; 
     544                        case Light::LT_POINT: 
     545                                useLISPSMPoint = use;break; 
     546                        case Light::LT_SPOTLIGHT: 
     547                                useLISPSMSpot = use;break; 
     548                } 
     549        } 
    469550        /** 
    470551                @see focusingSM 
    471552        */ 
    472         void setFocusingSM(bool use){focusingSM = use;} 
     553        void setFocusingSM(bool use) 
     554        { 
     555                focusingSMDirectional = use; 
     556                focusingSMPoint = use; 
     557                focusingSMSpot = use; 
     558        } 
     559        void setFocusingSM(Light::LightTypes type, bool use) 
     560        { 
     561                switch(type) 
     562                { 
     563                        case Light::LT_DIRECTIONAL: 
     564                                focusingSMDirectional = use;break; 
     565                        case Light::LT_POINT: 
     566                                focusingSMPoint = use;break; 
     567                        case Light::LT_SPOTLIGHT: 
     568                                focusingSMSpot = use;break; 
     569                } 
     570        } 
    473571        /** 
    474572                @see blurSM 
    475573        */ 
    476         void setBlurShadowMap(bool use){blurSM = use;} 
     574        void setBlurShadowMap(bool use) 
     575        { 
     576                blurSMDirectional = use; 
     577                blurSMPoint = use; 
     578                blurSMSpot = use; 
     579        } 
     580        void setBlurShadowMap(Light::LightTypes type, bool use) 
     581        { 
     582                switch(type) 
     583                { 
     584                        case Light::LT_DIRECTIONAL: 
     585                                blurSMDirectional = use;break; 
     586                        case Light::LT_POINT: 
     587                                blurSMPoint = use;break; 
     588                        case Light::LT_SPOTLIGHT: 
     589                                blurSMSpot = use;break; 
     590                } 
     591        } 
    477592        /** 
    478593                @see shadowMapMaterialName 
    479594        */ 
    480         void setShadowMapMaterialName(String name){shadowMapMaterialName = name;} 
     595        void setShadowMapMaterialName(String name) 
     596        { 
     597                shadowMapMaterialNameDirectional = name; 
     598                shadowMapMaterialNamePoint = name; 
     599                shadowMapMaterialNameSpot = name; 
     600        } 
     601        void setShadowMapMaterialName(Light::LightTypes type, String name) 
     602        { 
     603                switch(type) 
     604                { 
     605                        case Light::LT_DIRECTIONAL: 
     606                                shadowMapMaterialNameDirectional = name;break; 
     607                        case Light::LT_POINT: 
     608                                shadowMapMaterialNamePoint = name;break; 
     609                        case Light::LT_SPOTLIGHT: 
     610                                shadowMapMaterialNameSpot = name;break; 
     611                } 
     612        } 
    481613        /** 
    482614                @brief Registers a PathMapClusters structure for a given subentity. 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderingRun.h

    r2320 r2333  
    2222                                                :RenderingRun(startFrame, updateInterval) 
    2323        { 
    24                 pixelSprites = 0; 
    25                 fullscreenGrid = 0; 
     24                 
    2625        } 
    2726         
     
    6968                @see renderPixelSprites 
    7069        */ 
    71         BillboardSet* pixelSprites; 
     70        static BillboardSet* pixelSprites; 
    7271        /** 
    7372                @brief Entity used in fullscreen grid rendering 
     
    7574                @see renderPixelGrid 
    7675        */ 
    77         Entity* fullscreenGrid; 
     76        static Entity* fullscreenGrid; 
    7877        /** 
    7978                @brief unique name of the SpriteSet used in pixel sprite rendering 
     
    8180                @see renderPixelSprites 
    8281        */ 
    83         String spriteSetName; 
     82        static String spriteSetName; 
    8483        /** 
    8584                @brief Returns a direction for a cubemap face id. 
     
    147146                @param target the RenderTarget the quad should be rendered on 
    148147        */ 
    149         void renderFullscreenQuad(String materialName, RenderTarget* target); 
     148        static void renderFullscreenQuad(String materialName, RenderTarget* target); 
    150149        /** 
    151150                @brief Renderes sprites to pixels of the screen on a given RendderTarget with a given material. 
     
    161160                @param height the desired resolution height of the sprites 
    162161        */ 
    163         void renderPixelSprites(String& materialName, RenderTarget* rt, int width, int height); 
     162        static void renderPixelSprites(String& materialName, RenderTarget* rt, int width, int height); 
    164163        /** 
    165164                @brief Renders a grid onto the screen. 
     
    169168                @param height the desired vertical resolution of the grid 
    170169        */ 
    171         void renderFullscreenGrid(String& materialName, RenderTarget* rt, int width, int height);        
     170        static void renderFullscreenGrid(String& materialName, RenderTarget* rt, int width, int height);         
    172171}; 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgrePMWeightComputeRenderingRun.h

    r2320 r2333  
    3535                @brief returns the name of the weight texture 
    3636        */ 
    37         String getPMWeightTetureName(){return weightTexture->getName();} 
     37        static String getPMWeightTextureName(){return weightTexture->getName();} 
    3838        //not used 
    3939        float* getWeights(){return weights;} 
    4040 
    4141        void freeAllResources(); 
     42        static void sumWeights(unsigned long frameNum); 
    4243         
    4344protected: 
     
    5758                @brief a pointer to the weight texture that was created by this run 
    5859        */ 
    59         Texture* weightTexture; 
     60        static Texture* weightTexture; 
    6061        /** 
    6162                @brief A pointer to a texture that stores weights for all the entry point. 
     
    6364                This texture will be used to determine the weights of the clusters. 
    6465        */ 
    65         Texture* allWeightsTexture; 
     66        static Texture* allWeightsTexture; 
    6667        /** 
    6768                @brief A pointer to the light source. 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/scripts/OgreIllumModule.7.10.vcproj

    r2285 r2333  
    9191                        <Tool 
    9292                                Name="VCLibrarianTool" 
    93                                 AdditionalDependencies="IllumModule.lib OgreMain.lib Plugin_OctreeSceneManager.lib Plugin_VisibilitySceneManager.lib" 
    94                                 AdditionalLibraryDirectories="..\..\IllumModule\bin\Release;&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;&quot;$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\$(ConfigurationName)&quot;;&quot;..\..\..\..\Vis\OnlineCullingCHC\OGRE\lib\$(ConfigurationName)&quot;"/> 
     93                                AdditionalDependencies="IllumModule.lib OgreMain.lib" 
     94                                AdditionalLibraryDirectories="..\..\IllumModule\bin\Release;&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;"/> 
    9595                        <Tool 
    9696                                Name="VCMIDLTool"/> 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreIlluminationManager.cpp

    r2320 r2333  
    7979{ 
    8080        visitor = new VisibleFinderVisitor(&visibleObjects); 
     81        joinRuns = true; 
    8182        maxRad = 400; 
    8283        focusingMapSize = 32; 
    83         shadowMapSize = 512; 
    8484        phaseTextureSize = 256; 
    85         useLISPSM = false; 
    86 //      useVSM = false; 
    87         blurSM = false; 
    88         focusingSM = true; 
    89         shadowMapMaterialName = "GTP/Basic/Distance_NormalizedCCW"; 
     85        shadowMapSizeDirectional = shadowMapSizePoint = shadowMapSizeSpot = 512; 
     86        useLISPSMDirectional = useLISPSMPoint = useLISPSMSpot = false; 
     87        blurSMDirectional = blurSMPoint = blurSMSpot = false; 
     88        focusingSMDirectional = focusingSMPoint = focusingSMSpot = true; 
     89        shadowMapMaterialNameDirectional = "GTP/Basic/Depth or GTP/Basic/DepthCCW"; 
     90        shadowMapMaterialNamePoint = "GTP/Basic/Distance_NormalizedCCW"; 
     91        shadowMapMaterialNameSpot = "GTP/Basic/Distance_NormalizedCCW"; 
    9092        areaLightRadius = 0.1; 
    9193 
     
    515517                fillVisibleList(rq);     
    516518 
    517                 int l = visibleObjects.size(); //debug 
    518                  
    519                 joinSharedRuns(); 
    520  
    521                 int ll = sharedRunRoots.size(); //debug 
     519                if(joinRuns) 
     520                { 
     521                        int l = visibleObjects.size(); //debug           
     522                        joinSharedRuns(); 
     523                        int ll = sharedRunRoots.size(); //debug 
     524                } 
    522525 
    523526                //update precomputings                           
     
    717720                { 
    718721                        SceneManager* sm = Root::getSingleton()._getCurrentSceneManager(); 
     722                        Light* light = sm->getLight(lightName); 
     723                        unsigned int res; 
     724                        String MaterialName; 
     725                        switch(light->getType()) 
     726                        { 
     727                        case Light::LT_DIRECTIONAL: 
     728                                res = shadowMapSizeDirectional; 
     729                                MaterialName = shadowMapMaterialNameDirectional; 
     730                                break; 
     731                        case Light::LT_POINT: 
     732                                res = shadowMapSizePoint; 
     733                                MaterialName = shadowMapMaterialNamePoint; 
     734                                break; 
     735                        case Light::LT_SPOTLIGHT: 
     736                                res = shadowMapSizeSpot; 
     737                                MaterialName = shadowMapMaterialNameSpot; 
     738                                break; 
     739                        } 
     740 
    719741                        OgreDepthShadowMapRenderingRun* run  = new OgreDepthShadowMapRenderingRun( 
    720742                                runs, 
    721743                                lightName + "DEPTH_SHADOW_MAP", 
    722                                 sm->getLight(lightName), 
    723                                 shadowMapSize, 
    724                                 shadowMapSize, 
    725                                 shadowMapMaterialName //TODO 
     744                                light, 
     745                                res, 
     746                                res, 
     747                                MaterialName 
    726748                                ); 
    727749                        runs->addRun(ILLUMRUN_DEPTH_SHADOWMAP, run); 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderingRun.cpp

    r2265 r2333  
    55Entity* OgreRenderingRun::fullScreenQuadEntity = NULL; 
    66SceneNode* OgreRenderingRun::fullScreenQuadNode = NULL; 
     7BillboardSet* OgreRenderingRun::pixelSprites = NULL; 
     8Entity* OgreRenderingRun::fullscreenGrid = NULL; 
     9String OgreRenderingRun::spriteSetName = ""; 
    710 
    811class MaterialSetVisitor : public QueuedRenderableVisitor 
     
    231234        SceneManager* sm = Root::getSingleton()._getCurrentSceneManager(); 
    232235         
    233         if(this->fullscreenGrid == NULL) 
     236        if(fullscreenGrid == NULL) 
    234237        { 
    235238                MeshPtr mesh = MeshManager::getSingleton().createManual("FullScreenGrid",ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDepthShadowReceiverRenderTechnique.cpp

    r2299 r2333  
    125125                                GpuProgramParametersSharedPtr fpParams = passes.at(i)->getFragmentProgramParameters(); 
    126126                                GpuProgramParametersSharedPtr vpParams = passes.at(i)->getVertexProgramParameters(); 
    127                          
    128                                 //fpParams->setNamedConstant("lightViewProj", depthRun->getLightViewProjMatrix());  
     127 
    129128                                if(setLightViewProjMatrix) 
    130129                                        vpParams->setNamedConstant(lightViewProjParamName, depthRun->getLightViewProjMatrix()); 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgrePathMapRenderTechnique.cpp

    r2299 r2333  
    6363        TextureUnitState* st = newpass->createTextureUnitState();                
    6464        st->setTextureFiltering(TFO_BILINEAR); 
    65         st->setTextureAddressingMode(TextureUnitState::TAM_BORDER); 
     65        st->setTextureAddressingMode(TextureUnitState::TAM_CLAMP); 
    6666        st->setTextureBorderColour(ColourValue::Green); 
    6767        st->setTextureName(clusters->pathMapTextureFilename); 
     
    7171        st = newpass->createTextureUnitState();          
    7272        st->setTextureFiltering(TFO_NONE); 
    73         st->setTextureAddressingMode(TextureUnitState::TAM_BORDER); 
     73        st->setTextureAddressingMode(TextureUnitState::TAM_CLAMP); 
    7474        st->setTextureBorderColour(ColourValue::Red); 
    7575        st->setTextureName(weightIndexTexture->getName()); 
     
    7777        st = newpass->createTextureUnitState();          
    7878        st->setTextureFiltering(TFO_NONE); 
    79         st->setTextureAddressingMode(TextureUnitState::TAM_BORDER); 
     79        st->setTextureAddressingMode(TextureUnitState::TAM_CLAMP); 
    8080        st->setTextureBorderColour(ColourValue::Blue); 
    8181 
     
    122122        LightList lights; 
    123123        SceneManager* sm = Root::getSingleton()._getCurrentSceneManager(); 
    124         sm->_populateLightList(Vector3(0,0,0), 1000, lights); //TODO 
    125 //TODO set weights 
    126         /* 
    127         unsigned int entryPointCount = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().size(); 
    128         PathMapClusters* clusters = OgreIlluminationManager::getSingleton().getPathMapClusters(parentOgreRenderable->getName()); 
    129         int weightTextureWidth = clusters->count / 4; 
    130         */ 
    131         for(int i = 0 ; i < 1; i++) 
    132         { 
    133                 String lightName = lights.at(0)->getName(); 
     124        sm->_populateLightList(OgreIlluminationManager::getSingleton().getMainCamera()->getPosition(), 1000, lights); 
     125 
     126        for(int i = 0 ; i < 5 && i < lights.size(); i++) 
     127        { 
     128                String lightName = lights.at(i)->getName(); 
    134129                OgreIlluminationManager::getSingleton().createPerLightRun(lightName, ILLUMRUN_PM_WEIGHTMAP); 
    135                 OgreIlluminationManager::getSingleton().updatePerLightRun(lightName, ILLUMRUN_PM_WEIGHTMAP, frameNum); 
    136                 OgrePMWeightComputeRenderingRun* PMWeightRun = (OgrePMWeightComputeRenderingRun*) 
    137                         OgreIlluminationManager::getSingleton().getPerLightRun(lightName, ILLUMRUN_PM_WEIGHTMAP)->asOgreRenderingRun(); 
    138  
    139                 TextureUnitState* st = pathMapPass->getTextureUnitState(2); 
    140                 st->setTextureName(PMWeightRun->getPMWeightTetureName()); 
    141  
    142                 /* 
    143                 TexturePtr tex = TextureManager::getSingleton().getByName(PMWeightRun->getPMWeightTetureName()); 
    144                 float *allClusterWeights = new float[entryPointCount]; 
    145                 PixelBox lockBox(entryPointCount, 1, 1, PF_FLOAT32_R, allClusterWeights); 
    146                 tex->getBuffer()->blitToMemory(lockBox); 
    147  
    148                 float *weightIndices = new float[clusters->count]; 
    149                 for(int j = 0; j< clusters->count; j++) 
    150                         weightIndices[j] = allClusterWeights[clusters->clusters[j]]; 
    151                  
    152                 PixelBox lockBox2(weightTextureWidth, 1, 1, PF_FLOAT32_RGBA, weightIndices); 
    153                 weightIndexTexture->getBuffer()->blitFromMemory(lockBox2); 
    154  
    155                 TextureUnitState* st = pathMapPass->getTextureUnitState(1); 
    156                 st->setTextureName(weightIndexTexture->getName());      */                       
     130                OgreIlluminationManager::getSingleton().updatePerLightRun(lightName, ILLUMRUN_PM_WEIGHTMAP, frameNum);           
    157131        } 
    158 } 
     132        OgrePMWeightComputeRenderingRun::sumWeights(frameNum); 
     133        TextureUnitState* st = pathMapPass->getTextureUnitState(2); 
     134        st->setTextureName(OgrePMWeightComputeRenderingRun::getPMWeightTextureName()); 
     135} 
     136 
     137 
    159138 
    160139namespace PathMapParsers 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp

    r2321 r2333  
    2626void OgreDepthShadowMapRenderingRun::createDepthMap() 
    2727{ 
     28        if(light->getType() == Light::LT_POINT) 
     29        { 
     30                depthMapTexture = createCubeRenderTexture(name, light->getPosition(), resolutionX,PF_FLOAT16_RGBA,0,ColourValue::White); 
     31                if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType())) 
     32                blurredDepthMapTexture = createCubeRenderTexture(blurredname, light->getPosition(), resolutionX,PF_FLOAT16_RGBA,0,ColourValue::White); 
     33        } 
     34        else 
     35        { 
    2836         
    2937                TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name,  
     
    4654                rt->setAutoUpdated(false); 
    4755                 
    48                 if(OgreIlluminationManager::getSingleton().getBlurShadowMap()) 
     56                if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType())) 
    4957                { 
    5058                        texPtr = Ogre::TextureManager::getSingleton().createManual(blurredname,  
     
    6472                        rt->setAutoUpdated(false); 
    6573                } 
     74        } 
    6675} 
    6776 
     
    7281        if(light->getType() == Light::LT_POINT) 
    7382        { 
    74                 updateDepthMap(); 
     83                //static int currentFace = 0; 
     84                //updateDepthCubeFace(currentFace); 
     85                //currentFace = (currentFace+1)%6; 
     86 
     87                for(int i = 0; i < 6 ; i++) 
     88                        updateDepthCubeFace(i); 
    7589        } 
    7690        else 
     
    8296void OgreDepthShadowMapRenderingRun::updateDepthCubeFace(int facenum) 
    8397{ 
     98        Vector3 lightpos = light->getDerivedPosition();                  
     99         
     100        RenderTarget* rt = depthMapTexture->getBuffer(facenum, 0).getPointer()->getRenderTarget();       
     101        Camera*  cam =  rt->getViewport(0)->getCamera(); 
     102        cam->setPosition(lightpos);      
     103        cam->setFarClipDistance(lightFarPlane); 
     104 
     105        setMaterialForVisibles(materialName, cam, false); 
     106        rt->update(); 
     107        restoreMaterials(); 
     108 
     109        //rt->writeContentsToFile("shadowmap_" + StringConverter::toString(facenum) + ".dds"); 
     110 
     111        if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType())) 
     112        { 
     113                rt = blurredDepthMapTexture->getBuffer(facenum, 0).getPointer()->getRenderTarget(); 
     114                Material*  mat = (Material*) MaterialManager::getSingleton().getByName("GameTools/BlurCubeFace").getPointer(); 
     115                mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(depthMapTexture->getName()); 
     116                mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("face", facenum); 
     117                renderFullscreenQuad("GameTools/BlurCubeFace", rt);              
     118                 
     119                //rt->writeContentsToFile("shadowmap_blurred_" + StringConverter::toString(facenum) + ".dds"); 
     120        } 
     121         
    84122} 
    85123 
     
    93131        restoreMaterials(); 
    94132         
    95         if(OgreIlluminationManager::getSingleton().getBlurShadowMap()) 
     133        if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType())) 
    96134        { 
    97135                rt = blurredDepthMapTexture->getBuffer().getPointer()->getRenderTarget(); 
     
    108146const String& OgreDepthShadowMapRenderingRun::getDepthMapTextureName() 
    109147{ 
    110                 if(OgreIlluminationManager::getSingleton().getBlurShadowMap()) 
     148                if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType())) 
    111149                        return blurredname; 
    112150 
     
    119157        if(light!= 0) 
    120158        { 
    121                 bool uselispsm = OgreIlluminationManager::getSingleton().getUseLISPSM(); 
    122                 bool usefocusing = OgreIlluminationManager::getSingleton().getFocusingShadowMap(); 
     159                bool uselispsm = OgreIlluminationManager::getSingleton().getUseLISPSM(light->getType()); 
     160                bool usefocusing = OgreIlluminationManager::getSingleton().getFocusingShadowMap(light->getType()); 
    123161                if(light->getType() == Light::LT_DIRECTIONAL) 
    124162                { 
     
    129167                        frun->setCameraMatrices(viewcam->getViewMatrix(), viewcam->getProjectionMatrix()); 
    130168 
    131                         Vector3 lightpos = light->getParentSceneNode()->getWorldPosition(); 
    132                         Vector3 lightdir = light->getDirection(); 
     169                        Vector3 lightpos = light->getDerivedPosition(); 
     170                        Vector3 lightdir = light->getDerivedDirection(); 
    133171                        lightdir.normalise();            
    134172                         
     
    234272                        frun->setCameraMatrices(viewcam->getViewMatrix(), viewcam->getProjectionMatrix()); 
    235273 
    236                         Vector3 lightpos = light->getParentSceneNode()->getWorldPosition (); 
    237                         Vector3 lightdir = light->getDirection(); 
     274                        Vector3 lightpos = light->getDerivedPosition(); 
     275                        Vector3 lightdir = light->getDerivedDirection(); 
    238276                        lightdir.normalise();            
    239277                        Radian lightangle = light->getSpotlightOuterAngle(); 
     
    359397                else//point light 
    360398                { 
    361         /*              Vector3 pos = light->getParentNode()->getWorldPosition(); 
    362                         Vector3 dir = -pos; 
    363                         depthMapCamera->setDirection( dir ); 
    364                         depthMapCamera->setPosition(pos); 
    365                         depthMapCamera->setProjectionType(PT_PERSPECTIVE); 
    366                         depthMapCamera->setFOVy(Radian(Degree(140))); 
    367                         depthMapCamera->setNearClipDistance(1); 
    368                         // depthMapCamera->setFarClipDistance(200); 
    369          
    370                         //OGRE_EXCEPT(0, "NOT implemented for Pointlight", "OgreDepthShadowMapRenderingRun::refreshLight"); 
    371                 */       
    372                         /*Vector3 pos = light->getParentNode()->getWorldPosition(); 
    373                         Vector3 dir = -pos; 
    374                         depthMapCamera->setDirection( dir ); 
    375                         depthMapCamera->setPosition(pos); 
    376                         depthMapCamera->setProjectionType(PT_ORTHOGRAPHIC); 
    377                         depthMapCamera->*/ 
    378                          
     399                        lightFarPlane = light->getAttenuationRange(); 
     400                        //no other adjustment needed                     
    379401                } 
    380402        } 
     
    383405Matrix4 OgreDepthShadowMapRenderingRun::getLightViewMatrix() 
    384406{ 
    385         return depthMapCamera->getViewMatrix(); 
     407        Camera* cam = depthMapCamera; 
     408        if(light->getType() == Light::LT_POINT) 
     409         cam = depthMapTexture->getBuffer(4, 0).getPointer()->getRenderTarget()->getViewport(0)->getCamera();    
     410         
     411        return cam->getViewMatrix(); 
    386412} 
    387413 
    388414Matrix4 OgreDepthShadowMapRenderingRun::getLightViewProjMatrix() 
    389415{ 
    390         return depthMapCamera->getProjectionMatrixWithRSDepth() * depthMapCamera->getViewMatrix(); 
     416        Camera* cam = depthMapCamera; 
     417        if(light->getType() == Light::LT_POINT) 
     418         cam = depthMapTexture->getBuffer(4, 0).getPointer()->getRenderTarget()->getViewport(0)->getCamera();    
     419         
     420        return cam->getProjectionMatrixWithRSDepth() * cam->getViewMatrix(); 
    391421} 
    392422 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreLightVolumeRenderingRun.cpp

    r2321 r2333  
    238238                else 
    239239                {                        
    240                         Vector3 pos = light->getParentSceneNode()->getPosition(); 
     240                        Vector3 pos = light->getDerivedPosition(); 
    241241                        Vector3 dir = sharedRuns->getRootPosition(ILLUMRUN_LIGHTVOLUME_MAP) - pos; 
    242242                        dir.normalise(); 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePMWeightComputeRenderingRun.cpp

    r2321 r2333  
    44#include "OgreDepthShadowMapRenderingRun.h" 
    55 
     6Texture* OgrePMWeightComputeRenderingRun::weightTexture = 0; 
     7Texture* OgrePMWeightComputeRenderingRun::allWeightsTexture = 0; 
     8 
    69OgrePMWeightComputeRenderingRun::OgrePMWeightComputeRenderingRun(String name, String LightName) 
    710                                                                                                                   : OgreRenderingRun(1, 1) 
     
    1922void OgrePMWeightComputeRenderingRun::createWeightMap() 
    2023{ 
    21          
    22         unsigned int entryPointCnt = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().size(); 
    23         int width = entryPointCnt / 4096; 
    24         int height = 4096; 
    25         TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name + "_ALL",  
    26                                                                                                                                                 "default", 
    27                                                                                                                                                 TEX_TYPE_2D, 
    28                                                                                                                                                 width, 
    29                                                                                                                                                 height, 
    30                                                                                                                                                 0, 
    31                                                                                                                                                 0, 
    32                                                                                                                                                 PF_FLOAT32_R, 
    33                                                                                                                                                 TU_RENDERTARGET); 
    34          allWeightsTexture = texPtr.getPointer(); 
    35          //add viewport to rendertarget 
    36          HardwarePixelBuffer* hpb = (allWeightsTexture->getBuffer()).getPointer(); 
    37          RenderTarget* rt = hpb->getRenderTarget(); 
    38          Camera* wc = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_ALL_CAMERA");  
    39          Viewport* v = rt->addViewport(wc); 
    40          v->setOverlaysEnabled(false); 
    41          rt->setAutoUpdated(false); 
    42  
    43         unsigned int clustercount = OgreIlluminationManager::getSingleton().getPathMapClusterLengthsSize(); 
    44         width = clustercount; 
    45         height = 1; 
    46         texPtr = Ogre::TextureManager::getSingleton().createManual(name,  
    47                                                                                                                                 "default", 
    48                                                                                                                                 TEX_TYPE_2D, 
    49                                                                                                                                 width, 
    50                                                                                                                                 height, 
    51                                                                                                                                 0, 
    52                                                                                                                                 0, 
    53                                                                                                                                 PF_FLOAT32_R, 
    54                                                                                                                                 TU_RENDERTARGET); 
    55          weightTexture = texPtr.getPointer(); 
    56          //add viewport to rendertarget 
    57          hpb = (weightTexture->getBuffer()).getPointer(); 
    58          rt = hpb->getRenderTarget(); 
    59          wc = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_CAMERA");  
    60          v = rt->addViewport(wc); 
    61          v->setOverlaysEnabled(false); 
    62          rt->setAutoUpdated(false); 
     24        if(allWeightsTexture == 0) 
     25        { 
     26                unsigned int entryPointCnt = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().size(); 
     27                int width = entryPointCnt / 4096; 
     28                int height = 4096; 
     29                TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name + "_ALL",  
     30                                                                                                                                                        "default", 
     31                                                                                                                                                        TEX_TYPE_2D, 
     32                                                                                                                                                        width, 
     33                                                                                                                                                        height, 
     34                                                                                                                                                        0, 
     35                                                                                                                                                        0, 
     36                                                                                                                                                        PF_FLOAT16_RGBA, 
     37                                                                                                                                                        TU_RENDERTARGET); 
     38                allWeightsTexture = texPtr.getPointer(); 
     39                //add viewport to rendertarget 
     40                HardwarePixelBuffer* hpb = (allWeightsTexture->getBuffer()).getPointer(); 
     41                RenderTarget* rt = hpb->getRenderTarget(); 
     42                Camera* wc = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_ALL_CAMERA");  
     43                Viewport* v = rt->addViewport(wc); 
     44                v->setBackgroundColour(ColourValue::Black); 
     45                v->setClearEveryFrame(false); 
     46                v->setOverlaysEnabled(false); 
     47                rt->setAutoUpdated(false); 
     48 
     49                unsigned int clustercount = OgreIlluminationManager::getSingleton().getPathMapClusterLengthsSize(); 
     50                width = clustercount; 
     51                height = 1; 
     52                texPtr = Ogre::TextureManager::getSingleton().createManual(name,  
     53                                                                                                                                        "default", 
     54                                                                                                                                        TEX_TYPE_2D, 
     55                                                                                                                                        width, 
     56                                                                                                                                        height, 
     57                                                                                                                                        0, 
     58                                                                                                                                        0, 
     59                                                                                                                                        PF_FLOAT16_RGBA, 
     60                                                                                                                                        TU_RENDERTARGET); 
     61                weightTexture = texPtr.getPointer(); 
     62                //add viewport to rendertarget 
     63                hpb = (weightTexture->getBuffer()).getPointer(); 
     64                rt = hpb->getRenderTarget(); 
     65                wc = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_CAMERA");  
     66                v = rt->addViewport(wc); 
     67                v->setOverlaysEnabled(false); 
     68                rt->setAutoUpdated(false);               
     69        } 
    6370} 
    6471 
     
    8390                GpuProgramParameters* Fparams = mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters().getPointer(); 
    8491                         
    85                         Vector3 lightPos = light->getPosition(); 
    86                         Vector3 lightDir = light->getDirection(); 
    87                 //      Radian lightAngle = light->getSpotlightOuterAngle(); 
     92                        Vector3 lightPos = light->getDerivedPosition(); 
     93                        Vector3 lightDir = light->getDerivedDirection(); 
     94                        Radian lightAngle = light->getSpotlightOuterAngle(); 
    8895                         
    8996                        Fparams->setNamedConstant("nRadionColumns", col); 
     
    9198                        Fparams->setNamedConstant("lightDir", lightDir); 
    9299                        Fparams->setNamedConstant("lightPower", light->getPowerScale()); 
     100                        Fparams->setNamedConstant("lightColor", light->getDiffuseColour()); 
    93101                        Fparams->setNamedConstant("lightViewProj", SMrun->getLightViewProjMatrix()); 
    94102                        Fparams->setNamedConstant("lightFarPlane", SMrun->getLightFarPlane()); 
     103                        Fparams->setNamedConstant("lightAttenuation", Vector4(light->getAttenuationRange(), 
     104                                                                                                                                        light->getAttenuationConstant(), 
     105                                                                                                                                        light->getAttenuationLinear(), 
     106                                                                                                                                        light->getAttenuationQuadric())); 
     107                        Fparams->setNamedConstant("lightAngleCos", Math::Cos(lightAngle.valueRadians()/2.0));                    
     108                        Fparams->setNamedConstant("spotLightFalloff", light->getSpotlightFalloff());                     
    95109                         
    96110                        mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName( 
     
    100114                                 
    101115                        RenderTarget* rt = allWeightsTexture->getBuffer().getPointer()->getRenderTarget(); 
    102                         renderFullscreenQuad(mat->getName(), rt); 
     116                        if(frameNum != rt->getLastFrameNumber()) 
     117                                rt->getViewport(0)->setClearEveryFrame(true); 
     118                        else 
     119                                rt->getViewport(0)->setClearEveryFrame(false); 
     120                         
     121                                renderFullscreenQuad(mat->getName(), rt); 
     122                         
    103123 
    104124                //      rt->writeContentsToFile("allweights.bmp"); 
    105125                //      rt->writeContentsToFile("allweights.dds"); 
    106                          
    107                 /*      float* allweights = new float[entryPointCnt / 4096 * 4096]; 
    108                         PixelBox lockBox(entryPointCnt / 4096, 4096, 1, PF_FLOAT32_R, allweights); 
    109                         allWeightsTexture->getBuffer()->blitToMemory(lockBox); 
    110  
    111                         ///////////////////DEBUG 
    112                         static BillboardSet* entryPointBBSet = 0; 
    113                         if(entryPointBBSet == 0) 
    114                         { 
    115                                 SceneManager* sm = Root::getSingleton()._getCurrentSceneManager(); 
    116                                 entryPointBBSet = sm->createBillboardSet("PATHMAP_ENTRYPOINTS", entryPointCnt); 
    117                                 entryPointBBSet->setBillboardType(BBT_POINT); 
    118                                 entryPointBBSet->setBillboardsInWorldSpace(true); 
    119                                 entryPointBBSet->setPointRenderingEnabled(true); 
    120                                 for(unsigned int i = 0; i < entryPointCnt; i++) 
    121                                 { 
    122                                         PathMapEntryPoint EP = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().at(i); 
    123                                         Vector3 billboardPosition = EP.position; 
    124                                          
    125                                         float uCoord = allweights[i]; 
    126                                         float  vCoord = 0; 
    127                                         //float uCoord = ((float) (i % col) + 0.5f) / (float) col; 
    128                                         //float vCoord = ((float)(i / col) + 0.5f) / 4096.0f; 
    129                                         entryPointBBSet->createBillboard(billboardPosition, ColourValue(uCoord, vCoord, 0, 0)); 
    130                                 } 
    131                                 entryPointBBSet->setMaterialName("GTP/PM/EPBillboards"); 
    132                                 MaterialPtr mater = MaterialManager::getSingleton().getByName("GTP/PM/EPBillboards"); 
    133                                 mater->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(allWeightsTexture->getName()); 
    134                                 sm->getRootSceneNode()->createChildSceneNode()->attachObject(entryPointBBSet); 
    135                         } 
    136  
    137                         delete[] allweights;*/ 
    138  
    139 ///////////////// 
     126 
    140127        } 
    141         else 
     128        else if(light->getType() == Light::LT_POINT) 
    142129        { 
    143                 ///not implemented 
     130                OgreIlluminationManager::getSingleton().createPerLightRun(light->getName(), ILLUMRUN_DEPTH_SHADOWMAP); 
     131                OgreIlluminationManager::getSingleton().updatePerLightRun(light->getName(), ILLUMRUN_DEPTH_SHADOWMAP, frameNum); 
     132                OgreDepthShadowMapRenderingRun* SMrun = (OgreDepthShadowMapRenderingRun*) OgreIlluminationManager::getSingleton() 
     133                        .getPerLightRun(light->getName(), ILLUMRUN_DEPTH_SHADOWMAP)->asOgreRenderingRun();  
     134                 
     135                MaterialPtr mat = MaterialManager::getSingleton().getByName("GTP/PathMap_ComputeWeights_Point"); 
     136                GpuProgramParameters* Fparams = mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters().getPointer(); 
     137                         
     138                        Vector3 lightPos = light->getDerivedPosition(); 
     139                         
     140                        Fparams->setNamedConstant("nRadionColumns", col); 
     141                        Fparams->setNamedConstant("lightPos", lightPos); 
     142                        Fparams->setNamedConstant("lightPower", light->getPowerScale()); 
     143                        Fparams->setNamedConstant("lightColor", light->getDiffuseColour()); 
     144                        Fparams->setNamedConstant("lightFarPlane", SMrun->getLightFarPlane()); 
     145                        Fparams->setNamedConstant("lightAttenuation", Vector4(light->getAttenuationRange(), 
     146                                                                                                                                        light->getAttenuationConstant(), 
     147                                                                                                                                        light->getAttenuationLinear(), 
     148                                                                                                                                        light->getAttenuationQuadric())); 
     149 
     150                        mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName( 
     151                                                PMEPrun->getEntryPointTextureName()); 
     152                        mat->getTechnique(0)->getPass(0)->getTextureUnitState(1)->setTextureName( 
     153                                                SMrun->getDepthMapTextureName()); 
     154                                 
     155                        RenderTarget* rt = allWeightsTexture->getBuffer().getPointer()->getRenderTarget(); 
     156                        if(frameNum != rt->getLastFrameNumber()) 
     157                                rt->getViewport(0)->setClearEveryFrame(true); 
     158                        else 
     159                                rt->getViewport(0)->setClearEveryFrame(false); 
     160                         
     161                                renderFullscreenQuad(mat->getName(), rt); 
     162                         
    144163        } 
    145164 
     165} 
     166 
     167void OgrePMWeightComputeRenderingRun::sumWeights(unsigned long frameNum) 
     168{ 
     169        RenderTarget* rt = weightTexture->getBuffer().getPointer()->getRenderTarget(); 
     170        if(frameNum == rt->getLastFrameNumber())return; 
     171         
     172        unsigned int entryPointCnt = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().size(); 
     173        int col = entryPointCnt / 4096;  
    146174        unsigned int clustercount = OgreIlluminationManager::getSingleton().getPathMapClusterLengthsSize(); 
    147  
     175        OgrePMEntryPointMapRenderingRun* PMEPrun = (OgrePMEntryPointMapRenderingRun*) 
     176        OgreIlluminationManager::getSingleton().getGlobalRun(ILLUMRUN_PM_ENTRYPOINTMAP)->asOgreRenderingRun(); 
     177         
    148178        MaterialPtr mat = MaterialManager::getSingleton().getByName("GTP/PathMap_SumWeights"); 
    149179        GpuProgramParameters* Fparams = mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters().getPointer(); 
     
    157187                                                allWeightsTexture->getName()); 
    158188         
    159         RenderTarget* rt = weightTexture->getBuffer().getPointer()->getRenderTarget(); 
    160189        renderFullscreenQuad(mat->getName(), rt); 
    161  
    162         //rt->writeContentsToFile("weights.bmp");        
    163         //rt->writeContentsToFile("weights.dds"); 
    164 /* 
    165         float* weights = new float[clustercount]; 
    166         PixelBox lockBox(clustercount, 1, 1, PF_FLOAT32_R, weights); 
    167         weightTexture->getBuffer()->blitToMemory(lockBox); 
    168  
    169         delete[] weights;*/ 
    170190} 
    171191 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePhotonMapRenderingRun.cpp

    r2321 r2333  
    100100                if(light->getType() == Light::LT_DIRECTIONAL) 
    101101                { 
    102                         Vector3 dir = light->getDirection(); 
     102                        Vector3 dir = light->getDerivedDirection(); 
    103103                        photonMapCamera->setDirection( dir ); 
    104104                        Real r = sharedRuns->getRootBoundingSphere(ILLUMRUN_PHOTONMAP).getRadius(); 
     
    113113                else 
    114114                {                        
    115                         Vector3 pos = light->getParentSceneNode()->getPosition(); 
     115                        Vector3 pos = light->getDerivedPosition(); 
    116116                        Vector3 dir = sharedRuns->getRootPosition(ILLUMRUN_PHOTONMAP) - pos; 
    117117                        Real r = sharedRuns->getRootBoundingSphere(ILLUMRUN_PHOTONMAP).getRadius(); 
Note: See TracChangeset for help on using the changeset viewer.