Further work on basic ViewDependentShadowMaps, adding implementation of RTT camera and texgen setup.

This commit is contained in:
Robert Osfield
2011-08-08 17:00:55 +00:00
parent 31cb490c75
commit 4238629ebf
3 changed files with 493 additions and 87 deletions

View File

@@ -144,7 +144,8 @@ class OSG_EXPORT Polytope
itr->flip();
}
}
inline bool empty() const { return _planeList.empty(); }
inline PlaneList& getPlaneList() { return _planeList; }

View File

@@ -76,15 +76,52 @@ class OSGSHADOW_EXPORT ViewDependentShadowMap : public ShadowTechnique
ViewDependentData* getViewDependentData(osgUtil::CullVisitor* cv);
struct OSGSHADOW_EXPORT Frustum
{
Frustum(osgUtil::CullVisitor* cv);
typedef std::pair< osg::ref_ptr<osg::RefMatrix>, osg::ref_ptr<const osg::Light> > PositionedLight;
osg::Matrixd projectionMatrix;
osg::Matrixd modelViewMatrix;
typedef std::vector<osg::Vec3d> Vertices;
Vertices corners;
typedef std::vector<unsigned int> Indices;
typedef std::vector<Indices> Faces;
Faces faces;
typedef std::vector<Indices> Edges;
Edges edges;
osg::Vec3d centerNearPlane;
osg::Vec3d centerFarPlane;
osg::Vec3d center;
osg::Vec3d frustumCenterLine;
};
struct OSGSHADOW_EXPORT PositionedLight
{
PositionedLight(osg::RefMatrix* lm, const osg::Light* l, const osg::Matrixd& modelViewMatrix);
osg::ref_ptr<osg::RefMatrix> lightMatrix;
osg::ref_ptr<const osg::Light> light;
osg::Vec4d lightPos;
osg::Vec3d lightPos3;
osg::Vec3d lightDir;
bool directionalLight;
typedef std::vector<unsigned int> ActiveTextureUnits;
ActiveTextureUnits textureUnits;
};
typedef std::list< PositionedLight > PositionedLightList;
virtual bool selectActiveLights(osgUtil::CullVisitor* cv, PositionedLightList& pll) const;
virtual osg::Polytope computeLightViewFrustumPolytope(osgUtil::CullVisitor* cv, PositionedLight& positionedLight);
virtual osg::Polytope computeLightViewFrustumPolytope(Frustum& frustum, PositionedLight& positionedLight);
virtual bool computeShadowCameraSettings(PositionedLight& positionedLight, osg::Polytope& polytope, osg::Camera* camera);
virtual bool computeShadowCameraSettings(Frustum& frustum, PositionedLight& positionedLight, osg::Camera* camera);
virtual bool assignTexGenSettings(osgUtil::CullVisitor* cv, osg::Camera* camera, unsigned int textureUnit, osg::TexGen* texgen);