Show
Ignore:
Timestamp:
09/24/07 17:24:23 (7 years ago)
Author:
robert
Message:

From Adrian Egli, further work on PSSM implementation.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgshadow/osgshadow.cpp

    r7452 r7462  
    500500    arguments.getApplicationUsage()->addCommandLineOption("--mapres", "ParallelSplitShadowMap texture resolution.");//ADEGLI 
    501501    arguments.getApplicationUsage()->addCommandLineOption("--debug-color", "ParallelSplitShadowMap display debugging color (only the first 3 maps are color r=0,g=1,b=2.");//ADEGLI 
    502  
     502    arguments.getApplicationUsage()->addCommandLineOption("--minNearSplit", "ParallelSplitShadowMap shadow map near offset.");//ADEGLI 
     503    arguments.getApplicationUsage()->addCommandLineOption("--maxFarDist", "ParallelSplitShadowMap max far distance to shadow.");//ADEGLI 
     504    arguments.getApplicationUsage()->addCommandLineOption("--NVidea", "ParallelSplitShadowMap set default PolygonOffset for NVidea.");//ADEGLI 
     505    arguments.getApplicationUsage()->addCommandLineOption("--PolyOffset-Factor", "ParallelSplitShadowMap set PolygonOffset factor.");//ADEGLI 
     506    arguments.getApplicationUsage()->addCommandLineOption("--PolyOffset-Unit", "ParallelSplitShadowMap set PolygonOffset unit.");//ADEGLI 
     507    arguments.getApplicationUsage()->addCommandLineOption("--CullFaceFront", "ParallelSplitShadowMap add a cull face: front.");//ADEGLI 
     508 
     509     
    503510    arguments.getApplicationUsage()->addCommandLineOption("-1", "Use test model one."); 
    504511    arguments.getApplicationUsage()->addCommandLineOption("-2", "Use test model two."); 
     
    626633        osg::ref_ptr<osgShadow::ParallelSplitShadowMap> pssm = new osgShadow::ParallelSplitShadowMap(NULL,mapcount); 
    627634 
    628         unsigned int mapres = 1024; 
    629         while (arguments.read("--mapres", mapres)); 
    630         pssm->setTextureResolution(mapres); 
     635        int mapres = 1024; 
     636        while (arguments.read("--mapres", mapres))  
     637            pssm->setTextureResolution(mapres); 
    631638         
    632639        while (arguments.read("--debug-color")) { pssm->setDebugColorOn(); } 
    633640          
     641 
     642        int minNearSplit=0; 
     643        while (arguments.read("--minNearSplit", minNearSplit)) 
     644            if ( minNearSplit > 0 ) { 
     645                pssm->setMinNearDistanceForSplits(minNearSplit); 
     646                std::cout << "ParallelSplitShadowMap : setMinNearDistanceForSplits(" << minNearSplit <<")" << std::endl; 
     647            } 
     648 
     649        int maxfardist = 0; 
     650        while (arguments.read("--maxFarDist", maxfardist)) 
     651            if ( maxfardist > 0 ) { 
     652                pssm->setMaxFarDistance(maxfardist); 
     653                std::cout << "ParallelSplitShadowMap : setMaxFarDistance(" << maxfardist<<")" << std::endl; 
     654            } 
     655 
     656        double polyoffsetfactor = -0.02; 
     657        double polyoffsetunit = 1.0; 
     658        while (arguments.read("--PolyOffset-Factor", polyoffsetfactor)); 
     659        while (arguments.read("--PolyOffset-Unit", polyoffsetunit)); 
     660        pssm->setPolygonOffset(osg::Vec2(polyoffsetfactor,polyoffsetunit)); //ATI Radeon 
     661 
     662        if (arguments.read("--NVidea")){ 
     663            //pssm->setPolygonOffset(osg::Vec2(-0.02,1.0)); //ATI Radeon 
     664            pssm->setPolygonOffset(osg::Vec2(10.0f,20.0f)); //NVidea  
     665        } 
     666 
     667        if ( arguments.read("--CullFaceFront") ) { 
     668            pssm->forceFrontCullFace(); 
     669        } 
    634670 
    635671        shadowedScene->setShadowTechnique(pssm.get());