Here is a more informed email of what I'm trying to accomplish: We have some old code that inherits from the ShadowMapTechnique to do most of it's work which is based on the fixed-function pipeline. It uses the shadow map's camera for projection of textures (among other things) and we are redesigning it so that the base class is independent of the shadow map class. I thought I had everything working when I gutted out this function in the ViewData override function called addShadowReceivingTexGen():
_texgen->setMode(osg::TexGen::EYE_LINEAR); // compute the matrix which takes a vertex from view coords into tex coords _texgen->setPlanesFromMatrix( mClampCallback->getLastProjection() * osg::Matrix::translate(1.0, 1.0, 1.0) * osg::Matrix::scale(0.5f, 0.5f, 0.5f)); osg::RefMatrix * refMatrix = new osg::RefMatrix (_camera->getInverseViewMatrix() * *_cv->getModelViewMatrix()); _cv->getRenderStage()->getPositionalStateContainer()-> addPositionedTextureAttribute (*_shadowTextureUnitPtr, refMatrix, _texgen.get()); This is evidently stored in OpenGL's built-in variables because it's used in the vertex shader like this: { gl_TexCoord[1].s = dot(ecPosition, gl_EyePlaneS[1]); gl_TexCoord[1].t = dot(ecPosition, gl_EyePlaneT[1]); gl_TexCoord[1].p = dot(ecPosition, gl_EyePlaneR[1]); gl_TexCoord[1].q = dot(ecPosition, gl_EyePlaneQ[1]); } My new solution for the addShadowReceivingTexGen() is a simple updateTextureCoordinates() function: mTexGenMatrix = mCamera->getViewMatrix() *mCamera->getProjectionMatrix() * osg::Matrixd::translate(osg::Vec3d(1.0, 1.0, 1.0)) * osg::Matrixd::scale(0.5, 0.5, 0.5); And in the new vertex shader, I do this: TexCoords[0] = TexGenMatrix0 * gl_Vertex; Which goes from modelspace all the way to clip space. This works on simple objects created at the origin in modelspace, but it does NOT work with an entire world with large terrain. I'd like to continue NOT using the gl_EyePlaneSTRQ and just doing a regular transformation. However, going back to the old code for any clues is leading me nowhere. I traced the 'addPositionedTextureAttribute' to this: virtual void addPositionedTextureAttribute(unsigned int textureUnit, osg::RefMatrix* matrix,const osg::StateAttribute* attr) { _texAttrListMap[textureUnit].push_back(AttrMatrixPair(attr,matrix)); } .. but I'm not sure what it's doing here. The attr is the texgen object but that's used to store a matrix. So what does the vertex shader 'see' from this function? I apologize for the long and drawn out email but I've been thinking on this for a few hours now and am really new to OpenGL and not sure what some of this code is trying to do. Thanks, -M ---------------------------------------- Marlin Rowley Software Engineer, Staff [cid:image002.jpg@01D39374.DEC5A2E0] Missiles and Fire Control 972-603-1931 (office) 214-926-0622 (mobile) marlin.r.row...@lmco.com<mailto:marlin.r.row...@lmco.com> From: osg-users [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Rowley, Marlin R (US) Sent: Wednesday, May 2, 2018 12:05 PM To: OpenSceneGraph Users <osg-users@lists.openscenegraph.org> Subject: EXTERNAL: [osg-users] Getting the main camera. Is there a way to get a pointer to the main rendering camera without passing the Viewer around through classes and functions? Thanks, -M ---------------------------------------- Marlin Rowley Software Engineer, Staff [cid:image002.jpg@01D39374.DEC5A2E0] Missiles and Fire Control 972-603-1931 (office) 214-926-0622 (mobile) marlin.r.row...@lmco.com<mailto:marlin.r.row...@lmco.com>
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org