From Paul Martz, "To summarize the fix: OpenGL eye coords are negative outside Cartesian quadrant 1. As a result, the center of projection is eye coord (0,0), which (when used as st tex coords) looks up the lower left corner of the texture. However, in projective texturing, you usually want eye coord (0,0) to look up the center of the texture. Accomplishing this mapping requires not just a lookat and perspective transform, but also a translate and scale."

This commit is contained in:
Robert Osfield
2011-04-19 13:32:25 +00:00
parent c13b7d26b7
commit 3c4180d982

View File

@@ -121,7 +121,9 @@ osg::Node* createSpotLightNode(const osg::Vec3& position, const osg::Vec3& direc
osg::TexGen* texgen = texgenNode->getTexGen();
texgen->setMode(osg::TexGen::EYE_LINEAR);
texgen->setPlanesFromMatrix(osg::Matrixd::lookAt(position, position+direction, up)*
osg::Matrixd::perspective(angle,1.0,0.1,100));
osg::Matrixd::perspective(angle,1.0,0.1,100)*
osg::Matrixd::translate(1.0,1.0,1.0)*
osg::Matrixd::scale(0.5,0.5,0.5));
group->addChild(texgenNode);