Added s/getTextureSize() method for setting the shadow map texture size.

This commit is contained in:
Robert Osfield 2011-09-02 10:16:16 +00:00
parent f476406ae1
commit 52c2bc3ff5
2 changed files with 13 additions and 4 deletions

View File

@ -159,6 +159,12 @@ class OSGSHADOW_EXPORT ViewDependentShadowMap : public ShadowTechnique
/** Get the texture unit that the first shadow map will be placed on.*/
unsigned int getBaseShadowTextureUnit() const { return _baseShadowTextureUnit; }
/** Set the size of the shadow map textures.*/
void setTextureSize(const osg::Vec2s& textureSize) { _textureSize = textureSize; }
/** Get the size of the shadow map textures.*/
const osg::Vec2s& getTextureSize() const { return _textureSize; }
enum ShadowMapProjectionHint
{
ORTHOGRAPHIC_SHADOW_MAP,
@ -203,6 +209,7 @@ protected:
ViewDependentDataMap _viewDependentDataMap;
unsigned int _baseShadowTextureUnit;
osg::Vec2s _textureSize;
osg::ref_ptr<osg::StateSet> _shadowRecievingPlaceholderStateSet;

View File

@ -293,9 +293,9 @@ ViewDependentShadowMap::ShadowData::ShadowData(ViewDependentShadowMap::ViewDepen
// set up the texture
_texture = new osg::Texture2D;
unsigned int textureSize = debug ? 512 : 2048;
osg::Vec2s textureSize = debug ? osg::Vec2s(512,512) : vdd->getViewDependentShadowMap()->getTextureSize();
_texture->setTextureSize(textureSize.x(), textureSize.y());
_texture->setTextureSize(textureSize, textureSize);
if (debug)
{
_texture->setInternalFormat(GL_RGB);
@ -327,7 +327,7 @@ ViewDependentShadowMap::ShadowData::ShadowData(ViewDependentShadowMap::ViewDepen
_camera->setComputeNearFarMode(osg::Camera::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES);
// set viewport
_camera->setViewport(0,0,textureSize,textureSize);
_camera->setViewport(0,0,textureSize.x(),textureSize.y());
if (debug)
@ -522,7 +522,8 @@ void ViewDependentShadowMap::ViewDependentData::releaseGLObjects(osg::State* sta
//
ViewDependentShadowMap::ViewDependentShadowMap():
ShadowTechnique(),
_baseShadowTextureUnit(1),
_baseShadowTextureUnit(1),
_textureSize(2048,2048),
_shadowMapProjectionHint(PERSPECTIVE_SHADOW_MAP),
_minimumShadowMapNearFarRatio(0.01),
_debugDraw(false)
@ -533,6 +534,7 @@ ViewDependentShadowMap::ViewDependentShadowMap():
ViewDependentShadowMap::ViewDependentShadowMap(const ViewDependentShadowMap& vdsm, const osg::CopyOp& copyop):
ShadowTechnique(vdsm,copyop),
_baseShadowTextureUnit(vdsm._baseShadowTextureUnit),
_textureSize(vdsm._textureSize),
_shadowMapProjectionHint(vdsm._shadowMapProjectionHint),
_minimumShadowMapNearFarRatio(vdsm._minimumShadowMapNearFarRatio),
_debugDraw(vdsm._debugDraw)