Don't bother multiplying a matrix by its inverse and applying that to the light direction.

Hopefully this will improve numerical stability and reduce shadow flicker a little.
pull/541/head
AnyOldName3 6 years ago
parent 4438ab4493
commit d82c85913a

@ -474,7 +474,7 @@ void MWShadowTechnique::LightData::setLightData(osg::RefMatrix* lm, const osg::L
lightDir.set(-lightPos.x(), -lightPos.y(), -lightPos.z());
lightDir.normalize();
OSG_INFO<<" Directional light, lightPos="<<lightPos<<", lightDir="<<lightDir<<std::endl;
if (lightMatrix.valid())
if (lightMatrix.valid() && *lightMatrix != osg::Matrixf(modelViewMatrix))
{
OSG_INFO<<" Light matrix "<<*lightMatrix<<std::endl;
osg::Matrix lightToLocalMatrix(*lightMatrix * osg::Matrix::inverse(modelViewMatrix) );

Loading…
Cancel
Save