Changeset 7690 for OpenSceneGraph/trunk/src/osgShadow/ShadowMap.cpp
- Timestamp:
- 12/15/07 16:17:51 (5 years ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/src/osgShadow/ShadowMap.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgShadow/ShadowMap.cpp
r7648 r7690 82 82 _baseTextureUnit(0), 83 83 _shadowTextureUnit(1), 84 _ambientBias(0. 3f,1.2f),84 _ambientBias(0.5f,0.5f), 85 85 _textureSize(1024,1024) 86 86 { … … 134 134 _uniformList.push_back(shadowTextureSampler); 135 135 136 osg::Uniform* ambientBias= new osg::Uniform("osgShadow_ambientBias",_ambientBias);137 _uniformList.push_back( ambientBias);136 _ambientBiasUniform = new osg::Uniform("osgShadow_ambientBias",_ambientBias); 137 _uniformList.push_back(_ambientBiasUniform.get()); 138 138 139 139 } … … 202 202 osg::StateSet* stateset = _camera->getOrCreateStateSet(); 203 203 204 float factor = 0.0f; 205 float units = 1.0f; 204 205 #if 1 206 // cull front faces so that only backfaces contribute to depth map 207 208 osg::ref_ptr<osg::CullFace> cull_face = new osg::CullFace; 209 cull_face->setMode(osg::CullFace::FRONT); 210 stateset->setAttribute(cull_face.get(), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); 211 stateset->setMode(GL_CULL_FACE, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); 212 213 // negative polygonoffset - move the backface nearer to the eye point so that backfaces 214 // shadow themselves 215 float factor = -1.0f; 216 float units = -1.0f; 206 217 207 218 osg::ref_ptr<osg::PolygonOffset> polygon_offset = new osg::PolygonOffset; … … 210 221 stateset->setAttribute(polygon_offset.get(), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); 211 222 stateset->setMode(GL_POLYGON_OFFSET_FILL, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); 212 213 osg::ref_ptr<osg::CullFace> cull_face = new osg::CullFace; 214 cull_face->setMode(osg::CullFace::FRONT); 215 stateset->setAttribute(cull_face.get(), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); 216 stateset->setMode(GL_CULL_FACE, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); 217 223 #else 224 // disabling cull faces so that only front and backfaces contribute to depth map 225 stateset->setMode(GL_CULL_FACE, osg::StateAttribute::OFF | osg::StateAttribute::OVERRIDE); 226 227 // negative polygonoffset - move the backface nearer to the eye point 228 // so that front faces do not shadow themselves. 229 float factor = 1.0f; 230 float units = 1.0f; 231 232 osg::ref_ptr<osg::PolygonOffset> polygon_offset = new osg::PolygonOffset; 233 polygon_offset->setFactor(factor); 234 polygon_offset->setUnits(units); 235 stateset->setAttribute(polygon_offset.get(), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); 236 stateset->setMode(GL_POLYGON_OFFSET_FILL, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); 237 #endif 218 238 } 219 239 … … 353 373 } 354 374 } 355 375 356 376 osg::Matrix eyeToWorld; 357 377 eyeToWorld.invert(*cv.getModelViewMatrix()); … … 364 384 if (selectLight) 365 385 { 386 387 // set to ambient on light to black so that the ambient bias uniform can take it's affect 388 const_cast<osg::Light*>(selectLight)->setAmbient(osg::Vec4(0.0f,0.0f,0.0f,1.0f)); 366 389 367 390 //std::cout<<"----- VxOSG::ShadowMap selectLight spot cutoff "<<selectLight->getSpotCutoff()<<std::endl;
