Show
Ignore:
Timestamp:
03/19/08 13:09:20 (7 years ago)
Author:
robert
Message:

From Sebastian Messerschimdt, Added polygon offset controls

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgShadow/ShadowMap.cpp

    r7972 r7974  
    8282 
    8383ShadowMap::ShadowMap(): 
    84 _baseTextureUnit(0), 
     84    _baseTextureUnit(0), 
    8585    _shadowTextureUnit(1), 
    8686    _ambientBias(0.5f,0.5f), 
    87     _textureSize(1024,1024) 
     87    _textureSize(1024,1024), 
     88    _polyOffset(1.0,1.0) 
    8889{ 
    8990} 
     
    101102{ 
    102103    _shadowTextureUnit = unit; 
     104} 
     105 
     106void ShadowMap::setPolygonOffset(const osg::Vec2& polyOffset) 
     107{ 
     108    _polyOffset = polyOffset; 
    103109} 
    104110 
     
    210216#if 1 
    211217        // cull front faces so that only backfaces contribute to depth map 
     218         
    212219 
    213220        osg::ref_ptr<osg::CullFace> cull_face = new osg::CullFace; 
     
    218225        // negative polygonoffset - move the backface nearer to the eye point so that backfaces 
    219226        // shadow themselves 
    220         float factor = -1.0f; 
    221         float units = -1.0f; 
     227        float factor = -_polyOffset[0]; 
     228        float units =  -_polyOffset[1]; 
    222229 
    223230        osg::ref_ptr<osg::PolygonOffset> polygon_offset = new osg::PolygonOffset; 
     
    232239        // negative polygonoffset - move the backface nearer to the eye point 
    233240        // so that front faces do not shadow themselves. 
    234         float factor = 1.0f; 
    235         float units = 1.0f; 
     241        float factor = _polyOffset[0]; 
     242        float units =  _polyOffset[1]; 
    236243 
    237244        osg::ref_ptr<osg::PolygonOffset> polygon_offset = new osg::PolygonOffset; 
     
    328335    osgUtil::RenderStage* orig_rs = cv.getRenderStage(); 
    329336 
    330     // do traversal of shadow receiving scene which does need to be decorated by the shadow map 
     337    // do traversal of shadow recieving scene which does need to be decorated by the shadow map 
    331338    { 
    332339        cv.pushStateSet(_stateset.get()); 
     
    608615    stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF); 
    609616    stateset->setMode(GL_BLEND,osg::StateAttribute::ON); 
    610     //stateset->setAttribute(new osg::PolygonOffset(1.0f,1.0f),osg::StateAttribute::ON); 
    611617    stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); 
    612618