From Jean-Sebestien Guay and Robert Osfield, mixture of two sets of change - one from JS that adds more controls for specifying positional and spot lights, and from RO adding support for the new ViewDepedentShadowMap
This commit is contained in:
@@ -43,6 +43,7 @@
|
|||||||
#include <osgShadow/ParallelSplitShadowMap>
|
#include <osgShadow/ParallelSplitShadowMap>
|
||||||
#include <osgShadow/LightSpacePerspectiveShadowMap>
|
#include <osgShadow/LightSpacePerspectiveShadowMap>
|
||||||
#include <osgShadow/StandardShadowMap>
|
#include <osgShadow/StandardShadowMap>
|
||||||
|
#include <osgShadow/ViewDependentShadowMap>
|
||||||
|
|
||||||
#include <osgDB/ReadFile>
|
#include <osgDB/ReadFile>
|
||||||
#include <osgDB/WriteFile>
|
#include <osgDB/WriteFile>
|
||||||
@@ -650,12 +651,17 @@ int main(int argc, char** argv)
|
|||||||
while (arguments.read("--fov",fov)) {}
|
while (arguments.read("--fov",fov)) {}
|
||||||
|
|
||||||
osg::Vec4 lightpos(0.0,0.0,1,0.0);
|
osg::Vec4 lightpos(0.0,0.0,1,0.0);
|
||||||
|
bool spotlight = false;
|
||||||
while (arguments.read("--positionalLight")) { lightpos.set(0.5,0.5,1.5,1.0); }
|
while (arguments.read("--positionalLight")) { lightpos.set(0.5,0.5,1.5,1.0); }
|
||||||
while (arguments.read("--directionalLight")) { lightpos.set(0.0,0.0,1,0.0); }
|
while (arguments.read("--directionalLight")) { lightpos.set(0.0,0.0,1,0.0); }
|
||||||
|
while (arguments.read("--spotLight")) { lightpos.set(0.5,0.5,1.5,1.0); spotlight = true; }
|
||||||
|
|
||||||
while ( arguments.read("--light-pos", lightpos.x(), lightpos.y(), lightpos.z(), lightpos.w())) {}
|
bool keepLightPos = false;
|
||||||
while ( arguments.read("--light-pos", lightpos.x(), lightpos.y(), lightpos.z())) { lightpos.w()=1.0; }
|
osg::Vec3 spotLookat(0.0,0.0,0.0);
|
||||||
while ( arguments.read("--light-dir", lightpos.x(), lightpos.y(), lightpos.z())) { lightpos.w()=0.0; }
|
while ( arguments.read("--light-pos", lightpos.x(), lightpos.y(), lightpos.z(), lightpos.w())) { keepLightPos = true; }
|
||||||
|
while ( arguments.read("--light-pos", lightpos.x(), lightpos.y(), lightpos.z())) { lightpos.w()=1.0; keepLightPos = true; }
|
||||||
|
while ( arguments.read("--light-dir", lightpos.x(), lightpos.y(), lightpos.z())) { lightpos.w()=0.0; keepLightPos = true; }
|
||||||
|
while ( arguments.read("--spot-lookat", spotLookat.x(), spotLookat.y(), spotLookat.z())) { }
|
||||||
|
|
||||||
|
|
||||||
while (arguments.read("--castsShadowMask", CastsShadowTraversalMask ));
|
while (arguments.read("--castsShadowMask", CastsShadowTraversalMask ));
|
||||||
@@ -805,6 +811,11 @@ int main(int argc, char** argv)
|
|||||||
else // if( arguments.read( "--DrawBounds" ) ) // default
|
else // if( arguments.read( "--DrawBounds" ) ) // default
|
||||||
msm = new osgShadow::MinimalDrawBoundsShadowMap;
|
msm = new osgShadow::MinimalDrawBoundsShadowMap;
|
||||||
}
|
}
|
||||||
|
else if( arguments.read("--vdsm") )
|
||||||
|
{
|
||||||
|
osg::ref_ptr<osgShadow::ViewDependentShadowMap> vdsm = new osgShadow::ViewDependentShadowMap;
|
||||||
|
shadowedScene->setShadowTechnique(vdsm.get());
|
||||||
|
}
|
||||||
else /* if (arguments.read("--sm")) */
|
else /* if (arguments.read("--sm")) */
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osgShadow::ShadowMap> sm = new osgShadow::ShadowMap;
|
osg::ref_ptr<osgShadow::ShadowMap> sm = new osgShadow::ShadowMap;
|
||||||
@@ -860,7 +871,7 @@ int main(int argc, char** argv)
|
|||||||
model->accept(cbbv);
|
model->accept(cbbv);
|
||||||
osg::BoundingBox bb = cbbv.getBoundingBox();
|
osg::BoundingBox bb = cbbv.getBoundingBox();
|
||||||
|
|
||||||
if (lightpos.w()==1.0)
|
if (lightpos.w()==1.0 && !keepLightPos)
|
||||||
{
|
{
|
||||||
lightpos.x() = bb.xMin()+(bb.xMax()-bb.xMin())*lightpos.x();
|
lightpos.x() = bb.xMin()+(bb.xMax()-bb.xMin())*lightpos.x();
|
||||||
lightpos.y() = bb.yMin()+(bb.yMax()-bb.yMin())*lightpos.y();
|
lightpos.y() = bb.yMin()+(bb.yMax()-bb.yMin())*lightpos.y();
|
||||||
@@ -889,12 +900,9 @@ int main(int argc, char** argv)
|
|||||||
osg::ref_ptr<osg::LightSource> ls = new osg::LightSource;
|
osg::ref_ptr<osg::LightSource> ls = new osg::LightSource;
|
||||||
ls->getLight()->setPosition(lightpos);
|
ls->getLight()->setPosition(lightpos);
|
||||||
|
|
||||||
bool spotlight = false;
|
if (spotlight)
|
||||||
if (arguments.read("--spotLight"))
|
|
||||||
{
|
{
|
||||||
spotlight = true;
|
osg::Vec3 center = spotLookat;
|
||||||
|
|
||||||
osg::Vec3 center = bb.center();
|
|
||||||
osg::Vec3 lightdir = center - osg::Vec3(lightpos.x(), lightpos.y(), lightpos.z());
|
osg::Vec3 lightdir = center - osg::Vec3(lightpos.x(), lightpos.y(), lightpos.z());
|
||||||
lightdir.normalize();
|
lightdir.normalize();
|
||||||
ls->getLight()->setDirection(lightdir);
|
ls->getLight()->setDirection(lightdir);
|
||||||
|
|||||||
Reference in New Issue
Block a user