Changeset 1130


Ignore:
Timestamp:
07/13/06 08:16:36 (18 years ago)
Author:
szirmay
Message:
 
Location:
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule
Files:
5 edited

Legend:

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

    r1103 r1130  
    6868        float maxRad; 
    6969        unsigned int focusingMapSize; 
     70        unsigned int shadowMapSize; 
    7071        std::map<RenderingRunType,float> maxRads; 
    7172        /** 
     
    151152        void setMaxJoinRadius(RenderingRunType type, float rad){maxRads[type] = rad;} 
    152153        void setFocusingMapSize(unsigned int size){focusingMapSize = size;} 
     154        void setShadowMapSize(unsigned int size){shadowMapSize = size;} 
    153155        /** 
    154156                @brief Returns the one and only OgreIlluminationManager instance. 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/RenderingRuns/OgreDepthShadowMapRenderingRun.h

    r1120 r1130  
    4242                @brief returns the depth shadow map texture created by this run 
    4343        */ 
    44         String getDepthMapTextureName(){return name;} 
     44        String getDepthMapTextureName(){return blurredname;} 
    4545        /** 
    4646                @brief Refreshes light camera matrices, called in each update. 
     
    7777        */ 
    7878        String name; 
     79        String blurredname; 
    7980        /** 
    8081                @brief a pointer to the depth shadow texture that was created by this run 
    8182        */ 
    8283        Texture* depthMapTexture; 
     84        Texture* blurredDepthMapTexture; 
    8385         
    8486        //inherited 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreIlluminationManager.cpp

    r1125 r1130  
    8080        maxRad = 400; 
    8181        focusingMapSize = 32; 
     82        shadowMapSize = 512; 
    8283         
    8384        for(int i = 0; i < RUN_TYPE_COUNT; i++) 
     
    578579                                lightName + "DEPTH_SHADOW_MAP", 
    579580                                sm->getLight(lightName), 
    580                                 128, //TODO 
    581                                 128, //TODO 
     581                                shadowMapSize, 
     582                                shadowMapSize, 
    582583                                "GameTools/ShadowMapDepth" //TODO 
    583584                                ); 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDepthShadowRecieverRenderTechnique.cpp

    r1120 r1130  
    4646                Vparams->setNamedAutoConstant("worldViewProj", 
    4747                                                                        GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX);         
     48                Vparams->setNamedAutoConstant("world", 
     49                                                                        GpuProgramParameters::ACT_WORLD_MATRIX); 
    4850                GpuProgramParameters* Fparams = newpass->getFragmentProgramParameters().getPointer(); 
    4951                 
    5052                TextureUnitState* st = newpass->createTextureUnitState();                
    51                 st->setTextureFiltering(TFO_BILINEAR);           
    52                 st = newpass->createTextureUnitState();          
    53                 st->setTextureFiltering(TFO_BILINEAR);           
     53                st->setTextureFiltering(TFO_ANISOTROPIC);                                                
    5454 
    55                 //newpass->setSceneBlending(SBT_MODULATE); 
    56                 newpass->setSceneBlending(SBF_ONE, SBF_ZERO); 
     55                newpass->setSceneBlending(SBT_MODULATE); 
     56                //newpass->setSceneBlending(SBF_ONE, SBF_ZERO); 
    5757                newpass->setDepthBias(1); 
    5858                techn->movePass(lastpass, index);                        
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp

    r1125 r1130  
    1717        this->sharedRuns = sharedRuns; 
    1818        this->name = name;       
     19        this->blurredname = name + "blurred"; 
    1920         
    2021        this->materialName = materialName; 
     
    3435                                                                                                                                                        0, 
    3536                                                                                                                                                        PF_FLOAT16_RGBA, 
    36                                                                                                                                                         TU_RENDERTARGET); 
     37                                                                                                                                                        TU_RENDERTARGET);                
    3738                depthMapTexture = texPtr.getPointer(); 
    3839                depthMapCamera = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_CAMERA"); 
     
    4243                Viewport* v = rt->addViewport(depthMapCamera); 
    4344                v->setOverlaysEnabled(false); 
    44                 rt->setAutoUpdated(false);       
     45                rt->setAutoUpdated(false); 
     46 
     47                texPtr = Ogre::TextureManager::getSingleton().createManual(blurredname,  
     48                                                                                                                                                        "default", 
     49                                                                                                                                                        TEX_TYPE_2D, 
     50                                                                                                                                                        resolutionX, 
     51                                                                                                                                                        resolutionY, 
     52                                                                                                                                                        6, 
     53                                                                                                                                                        0, 
     54                                                                                                                                                        PF_FLOAT16_RGBA, 
     55                                                                                                                                                        TU_RENDERTARGET); 
     56                blurredDepthMapTexture = texPtr.getPointer(); 
     57                hpb = (blurredDepthMapTexture->getBuffer()).getPointer(); 
     58                rt = hpb->getRenderTarget(); 
     59                v = rt->addViewport(depthMapCamera); 
     60                v->setOverlaysEnabled(false); 
     61                rt->setAutoUpdated(false); 
    4562} 
    4663 
     
    5673        { 
    5774                updateDepthMap(); 
    58         } 
    59          
    60          
     75        }        
    6176} 
    6277 
     
    7388        rt->update(); 
    7489        restoreMaterials(); 
    75         rt->writeContentsToFile("shadowmap1.dds"); 
     90 
     91        rt = blurredDepthMapTexture->getBuffer().getPointer()->getRenderTarget(); 
     92        Material*  mat = (Material*) MaterialManager::getSingleton().getByName("GameTools/Blur").getPointer(); 
     93        mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(depthMapTexture->getName()); 
     94        renderFullscreenQuad("GameTools/Blur", rt); 
     95         
     96         
     97        //rt->writeContentsToFile("shadowmap1.dds"); 
     98 
     99        //depthMapTexture->(); 
    76100} 
    77101 
     
    118142                                //left = lightdir.crossProduct(up); 
    119143                                left.normalise();                                
    120  
    121144                                Matrix4 viewMatrix( left.x,      left.y,      left.z,            0, 
    122145                                                                        up.x,            up.y,            up.z,                  0, 
     
    142165 
    143166                                Vector3 pos = campos - up * (n - nearclip); 
    144                                  
    145167                                Matrix4 newViewMatrix(  left.x,      left.y,      left.z,                -left.dotProduct(pos), 
    146168                                                                                up.x,            up.y,            up.z,                  -up.dotProduct(pos), 
     
    148170                                                                                0,           0,           0,             1); 
    149171 
    150  
    151                                 Matrix4 newProjection = Matrix4::IDENTITY; 
    152                                  
    153                                 newProjection[1][1] = (f + n) / (f - n); 
    154                                 newProjection[1][3] = - 2* f * n / (f - n); 
    155                                 newProjection[3][1] = 1; 
    156                                 newProjection[3][3] = 0; 
    157                                 //newProjection = newProjection.transpose(); 
    158                                 Matrix4 standardProjMatrix = Matrix4::IDENTITY; 
    159                                 standardProjMatrix.setScale(Vector3(1,1,-1)); 
    160                                 newProjection = newProjection * standardProjMatrix; 
    161                                 depthMapCamera->setCustomProjectionMatrix(true, newProjection); 
    162                                 depthMapCamera->setCustomViewMatrix(true, viewMatrix); 
     172                                Matrix4 lispMat = Matrix4::IDENTITY; 
     173                                 
     174                                lispMat[1][1] = f / (f - n); 
     175                                lispMat[1][3] = f * n / (f - n); 
     176                                lispMat[3][1] = 1; 
     177                                lispMat[3][3] = 0; 
     178                                 
     179                                depthMapCamera->setCustomProjectionMatrix(true, Matrix4::IDENTITY); 
     180                                depthMapCamera->setCustomViewMatrix(true, lispMat * newViewMatrix); 
    163181                        } 
    164182                        else 
    165183                        { 
    166                                 Matrix4 standardProjMatrix = Matrix4::IDENTITY; 
    167                                 standardProjMatrix.setScale(Vector3(0,0,-1)); 
    168                                 depthMapCamera->setCustomProjectionMatrix(true, standardProjMatrix); 
     184                                depthMapCamera->setCustomProjectionMatrix(true, Matrix4::IDENTITY); 
    169185                                depthMapCamera->setCustomViewMatrix(false); 
    170                                 depthMapCamera->setProjectionType(PT_ORTHOGRAPHIC);                      
    171186                                depthMapCamera->setPosition(lightpos); 
    172                                 depthMapCamera->setDirection(lightdir); 
     187                                depthMapCamera->setDirection(lightdir);                          
    173188                        } 
    174189 
    175190 
    176                         Matrix4 lightMatrix = depthMapCamera->getProjectionMatrix() * depthMapCamera->getViewMatrix(); 
     191                        Matrix4 lightMatrix = depthMapCamera->getViewMatrix(); 
    177192                        frun->setLightMatrix(lightMatrix); 
    178193                         
     
    191206                                                                                -(max.y + min.y) / scale.y, 
    192207                                                                                -(max.z + min.z) / scale.z)); 
    193                         projection = projection * depthMapCamera->getProjectionMatrix(); 
    194                         depthMapCamera->setCustomProjectionMatrix(true, projection); 
    195                          
    196                          
    197                          
     208                        depthMapCamera->setCustomProjectionMatrix(true, projection);                     
    198209                } 
    199210                else if(light->getType() == Light::LT_SPOTLIGHT) 
Note: See TracChangeset for help on using the changeset viewer.