Lighting problem on projected maps

classic Classic list List threaded Threaded
1 message Options
Xtof Xtof
Reply | Threaded
Open this post in threaded view
|

Lighting problem on projected maps

This post was updated on .
Hi,

I can make working part of "osgearth_lights.cpp" in my own code when using a geographic map.
But when trying to do the same on a projected map, some features don't seem to work.

1. void Light::setSpotExponent(float spot_exponent) doesn't work on a projected map!

   // A red spot light. A spot light has a real position in space
   // and points in a specific direciton. The Cutoff and Exponent
   // properties control the cone angle and sharpness, respectively
   {
      GeoPoint p(geosrs, -121, 34, 5000000., ALTMODE_ABSOLUTE);
      p.toWorld(world);

      osg::Light* spot = new osg::Light(lightNum++);
      spot->setPosition(worldToVec4(world));
      spot->setAmbient(osg::Vec4(0, 0.2, 0, 1));
      spot->setDiffuse(osg::Vec4(1, 1, 1, 1));
      spot->setSpotCutoff(20.0f);
      spot->setSpotExponent(100.0f); -> Doesn't work on a projected map!

      // point straight down at the map:
      world.normalize();
      spot->setDirection(-world);

      osg::LightSource* spotLS = new osg::LightSource();
      spotLS->setLight(spot);

      lights->addChild(spotLS);
   }

2. void Light::setDirection(const Vec3& direction) does't work if direction is expressed in a projected coordinate system!

Are there things I'm doing wrong?

Thanks,
Christophe