Changeset 1120


Ignore:
Timestamp:
07/11/06 15:48:46 (18 years ago)
Author:
szirmay
Message:
 
Location:
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule
Files:
3 edited

Legend:

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

    r1103 r1120  
    4242                @brief returns the depth shadow map texture created by this run 
    4343        */ 
    44         String getDepthMapTextureName(int i){return names[i];} 
     44        String getDepthMapTextureName(){return name;} 
    4545        /** 
    4646                @brief Refreshes light camera matrices, called in each update. 
     
    5050                @brief retuns the view matrix of the camera from which the depth shadow map was created 
    5151        */ 
    52         Matrix4 getLightViewMatrix(int i); 
     52        Matrix4 getLightViewMatrix(); 
    5353        /** 
    5454                @brief retuns the concatenation of the view and projection matrices of the camera from which the depth shadow map was created 
    5555        */ 
    56         Matrix4 getLightViewProjMatrix(int i); 
     56        Matrix4 getLightViewProjMatrix(); 
    5757 
    5858protected:       
     
    6464                @brief pointer to the camera of the lightsource 
    6565        */ 
    66         Camera* depthMapCameras[2]; 
     66        Camera* depthMapCamera; 
    6767        /** 
    6868                @brief the name of the material to be used when rendering the depth shadow map 
     
    7676                @brief the name of the depth shadow map texture that was created by this run 
    7777        */ 
    78         String names[2]; 
     78        String name; 
    7979        /** 
    8080                @brief a pointer to the depth shadow texture that was created by this run 
    8181        */ 
    82         Texture* depthMapTextures[2]; 
     82        Texture* depthMapTexture; 
    8383         
    8484        //inherited 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDepthShadowRecieverRenderTechnique.cpp

    r1103 r1120  
    4545                GpuProgramParameters* Vparams = newpass->getVertexProgramParameters().getPointer(); 
    4646                Vparams->setNamedAutoConstant("worldViewProj", 
    47                                                                         GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX); 
    48                 Vparams->setNamedAutoConstant("world", 
    49                                                                         GpuProgramParameters::ACT_WORLD_MATRIX); 
     47                                                                        GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX);         
    5048                GpuProgramParameters* Fparams = newpass->getFragmentProgramParameters().getPointer(); 
    5149                 
     
    5553                st->setTextureFiltering(TFO_BILINEAR);           
    5654 
    57                 newpass->setSceneBlending(SBT_MODULATE); 
    58                 newpass->setDepthBias(7); 
     55                //newpass->setSceneBlending(SBT_MODULATE); 
     56                newpass->setSceneBlending(SBF_ONE, SBF_ZERO); 
     57                newpass->setDepthBias(1); 
    5958                techn->movePass(lastpass, index);                        
    6059        } 
     
    9594                                         
    9695                        passes.at(i)->getTextureUnitState(0)->setTextureName( 
    97                                 depthRun->getDepthMapTextureName(0)); 
    98                         passes.at(i)->getTextureUnitState(1)->setTextureName( 
    99                                 depthRun->getDepthMapTextureName(1)); 
    100  
     96                                depthRun->getDepthMapTextureName()); 
     97                 
    10198                        //TODO: set matrices 
    10299                        GpuProgramParametersSharedPtr fpParams = passes.at(i)->getFragmentProgramParameters(); 
    103                         fpParams->setNamedConstant("lightView", depthRun->getLightViewMatrix(0));  
    104                         fpParams->setNamedConstant("lightViewProj", depthRun->getLightViewProjMatrix(0));  
    105                 //      fpParams->setNamedConstant("lightView2", depthRun->getLightViewMatrix(1));  
    106                 //      fpParams->setNamedConstant("lightViewProj2", depthRun->getLightViewProjMatrix(1));  
     100                        GpuProgramParametersSharedPtr vpParams = passes.at(i)->getVertexProgramParameters(); 
     101                 
     102                        //fpParams->setNamedConstant("lightViewProj", depthRun->getLightViewProjMatrix());  
     103                        vpParams->setNamedConstant("lightViewProj", depthRun->getLightViewProjMatrix()); 
    107104                         
    108105                        passes.at(i)->setActive(true); 
  • GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp

    r1103 r1120  
    1616        this->light = light; 
    1717        this->sharedRuns = sharedRuns; 
    18         names[0] = name + "1" 
    19         names[1] = name + "2";   
     18        this->name = name;       
     19         
    2020        this->materialName = materialName; 
    2121 
     
    2525void OgreDepthShadowMapRenderingRun::createDepthMap() 
    2626{ 
    27         for(int i = 0; i < 1; i++) 
    28         { 
    29                 TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(names[i],  
     27         
     28                TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name,  
    3029                                                                                                                                                        "default", 
    3130                                                                                                                                                        TEX_TYPE_2D, 
     
    3635                                                                                                                                                        PF_FLOAT16_RGBA, 
    3736                                                                                                                                                        TU_RENDERTARGET); 
    38                 depthMapTextures[i] = texPtr.getPointer(); 
    39                 depthMapCameras[i] = Root::getSingleton()._getCurrentSceneManager()->createCamera(names[i] + "_CAMERA"); 
     37                depthMapTexture = texPtr.getPointer(); 
     38                depthMapCamera = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_CAMERA"); 
    4039                //add viewport to rendertarget 
    41                 HardwarePixelBuffer* hpb = (depthMapTextures[i]->getBuffer()).getPointer(); 
     40                HardwarePixelBuffer* hpb = (depthMapTexture->getBuffer()).getPointer(); 
    4241                RenderTarget* rt = hpb->getRenderTarget(); 
    43                 Viewport* v = rt->addViewport(depthMapCameras[i]); 
     42                Viewport* v = rt->addViewport(depthMapCamera); 
    4443                v->setOverlaysEnabled(false); 
    45                 rt->setAutoUpdated(false); 
    46         } 
     44                rt->setAutoUpdated(false);       
    4745} 
    4846 
     
    6967void OgreDepthShadowMapRenderingRun::updateDepthMap() 
    7068{ 
    71         setMaterialForVisibles(materialName, depthMapCameras[0], false);         
    72         RenderTarget* rt = depthMapTextures[0]->getBuffer().getPointer()->getRenderTarget();     
     69        setMaterialForVisibles(materialName, depthMapCamera, false);     
     70        RenderTarget* rt = depthMapTexture->getBuffer().getPointer()->getRenderTarget();         
     71        Viewport* vp = rt->getViewport(0); 
     72         
    7373        rt->update(); 
    7474        restoreMaterials(); 
     
    103103                        Vector3 lightpos = light->getPosition(); 
    104104                        Vector3 lightdir = light->getDirection(); 
     105                        lightdir.normalise(); 
     106 
     107                        depthMapCamera->setProjectionType(PT_ORTHOGRAPHIC);      
     108                        /*depthMapCameras[0]->setAspectRatio(1.0); 
     109                        depthMapCameras[0]->setFOVy(Radian(Degree(20))); 
     110                        depthMapCameras[0]->setNearClipDistance(0.1); 
     111                        depthMapCameras[0]->setFarClipDistance(200);*/ 
     112 
    105113                         
    106                         Vector3 center = (min + max) / 2.0; 
    107                         Vector3 scale = max - min; 
    108                         scale.x = 2.0 / scale.x; 
    109                         scale.y = 2.0 / scale.y; 
    110                         scale.z = 2.0 / scale.z; 
    111                         center.x *= scale.x; 
    112                         center.y *= scale.y; 
    113                         center.z *= scale.z; 
    114  
    115  
    116                         depthMapCameras[0]->setDirection( lightdir ); 
    117                         depthMapCameras[0]->setPosition( lightpos ); 
    118  
    119                         Matrix4 projection = Matrix4::IDENTITY; 
    120                         projection.setTrans(center); 
    121                         projection.setScale(scale); 
    122                         depthMapCameras[0]->setCustomProjectionMatrix(true, projection);         
    123 /* 
     114                        Vector3 scale = (max - min); 
     115                        scale *= 1.5; 
     116                        //scale = Vector3(150,150,150); 
     117                        Matrix4 projection = depthMapCamera->getProjectionMatrix(); 
     118                        projection = Matrix4::IDENTITY; 
     119                        projection.setScale(Vector3(2.0 / scale.x, 2.0 / scale.y, -2.0 / scale.z));                      
     120                        projection.setTrans(Vector3(-(max.x + min.x) / scale.x, 
     121                                                                                -(max.y + min.y) / scale.y, 
     122                                                                                -(max.z + min.z) / scale.z)); 
     123                        depthMapCamera->setCustomProjectionMatrix(true, projection); 
     124                         
     125                        depthMapCamera->setPosition(lightpos); 
     126                        depthMapCamera->setDirection(lightdir); 
     127                         
     128        /* 
    124129                        projection = Matrix4::IDENTITY; 
    125130                        projection.setScale(Vector3(1.0 / 100.0, 1.0 / 100.0, -1.0 / 100.0)); 
     
    161166} 
    162167 
    163 Matrix4 OgreDepthShadowMapRenderingRun::getLightViewMatrix(int i) 
     168Matrix4 OgreDepthShadowMapRenderingRun::getLightViewMatrix() 
    164169{ 
    165         return depthMapCameras[i]->getViewMatrix(); 
     170        return depthMapCamera->getViewMatrix(); 
    166171} 
    167172 
    168 Matrix4 OgreDepthShadowMapRenderingRun::getLightViewProjMatrix(int i) 
     173Matrix4 OgreDepthShadowMapRenderingRun::getLightViewProjMatrix() 
    169174{ 
    170         return depthMapCameras[i]->getProjectionMatrix() * depthMapCameras[i]->getViewMatrix(); 
     175        return depthMapCamera->getProjectionMatrixWithRSDepth() * depthMapCamera->getViewMatrix(); 
    171176} 
    172177 
Note: See TracChangeset for help on using the changeset viewer.