Show
Ignore:
Timestamp:
09/27/07 14:47:34 (7 years ago)
Author:
robert
Message:

From Adrian Egli, "update the PSSM, i did some bug fixes and added new features to move the camera virtual against the view direction by applaying a simple distance factor (a), which is calculated camera eye - camera center distance. and we can move the "light camera" against the light direction (b).

(a) some objects behind the camera can cast shadow
(b) object aboive the camera can cast shadow

then i fixed the shadow map orientation, now screen x coordinate alinged which improve the quality"

Files:
1 modified

Legend:

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

    r7462 r7497  
    502502    arguments.getApplicationUsage()->addCommandLineOption("--minNearSplit", "ParallelSplitShadowMap shadow map near offset.");//ADEGLI 
    503503    arguments.getApplicationUsage()->addCommandLineOption("--maxFarDist", "ParallelSplitShadowMap max far distance to shadow.");//ADEGLI 
     504    arguments.getApplicationUsage()->addCommandLineOption("--moveVCamFactor", "ParallelSplitShadowMap move the virtual frustum behind the real camera, (also back ground object can cast shadow).");//ADEGLI 
    504505    arguments.getApplicationUsage()->addCommandLineOption("--NVidea", "ParallelSplitShadowMap set default PolygonOffset for NVidea.");//ADEGLI 
    505506    arguments.getApplicationUsage()->addCommandLineOption("--PolyOffset-Factor", "ParallelSplitShadowMap set PolygonOffset factor.");//ADEGLI 
     
    577578    viewer.addEventHandler( new osgViewer::StatsHandler() ); 
    578579 
    579     osg::ref_ptr<osg::Node> model = osgDB::readNodeFiles(arguments); 
    580     if (model.valid()) 
    581     { 
    582         model->setNodeMask(CastsShadowTraversalMask | ReceivesShadowTraversalMask); 
    583     } 
    584     else 
    585     { 
    586         model = createTestModel(arguments); 
    587     } 
    588  
    589     // get the bounds of the model.     
    590     osg::ComputeBoundsVisitor cbbv; 
    591     model->accept(cbbv); 
    592     osg::BoundingBox bb = cbbv.getBoundingBox(); 
    593  
    594     osg::Vec4 lightpos; 
    595      
    596     if (postionalLight) 
    597     { 
    598         lightpos.set(bb.center().x(), bb.center().y(), bb.zMax() + bb.radius()  ,1.0f); 
    599     } 
    600     else 
    601     { 
    602         lightpos.set(0.5f,0.25f,0.8f,0.0f); 
    603     } 
    604580 
    605581 
     
    654630            } 
    655631 
     632        int moveVCamFactor = 0; 
     633        while (arguments.read("--moveVCamFactor", moveVCamFactor)) 
     634            if ( maxfardist > 0 ) { 
     635                pssm->setMoveVCamBehindRCamFactor(moveVCamFactor); 
     636                std::cout << "ParallelSplitShadowMap : setMoveVCamBehindRCamFactor(" << moveVCamFactor<<")" << std::endl; 
     637            } 
     638             
     639 
    656640        double polyoffsetfactor = -0.02; 
    657641        double polyoffsetunit = 1.0; 
     
    681665        shadowedScene->setShadowTechnique(sm.get()); 
    682666    } 
     667     
     668    osg::ref_ptr<osg::Node> model = osgDB::readNodeFiles(arguments); 
     669    if (model.valid()) 
     670    { 
     671        model->setNodeMask(CastsShadowTraversalMask | ReceivesShadowTraversalMask); 
     672    } 
     673    else 
     674    { 
     675        model = createTestModel(arguments); 
     676    } 
     677 
     678    // get the bounds of the model.     
     679    osg::ComputeBoundsVisitor cbbv; 
     680    model->accept(cbbv); 
     681    osg::BoundingBox bb = cbbv.getBoundingBox(); 
     682 
     683    osg::Vec4 lightpos; 
     684     
     685    if (postionalLight) 
     686    { 
     687        lightpos.set(bb.center().x(), bb.center().y(), bb.zMax() + bb.radius()  ,1.0f); 
     688    } 
     689    else 
     690    { 
     691        lightpos.set(0.5f,0.25f,0.8f,0.0f); 
     692    } 
     693 
    683694 
    684695    if ( arguments.read("--base")) 
     
    713724        ls->getLight()->setDiffuse(osg::Vec4(0.8,0.8,0.8,1.0)); 
    714725    } 
    715      
     726 
    716727    shadowedScene->addChild(model.get()); 
    717728    shadowedScene->addChild(ls.get());