Paul Martz wrote: > On 12/10/2010 5:21 AM, Chris Denham wrote: > > > I've been trying to apply a 2d texture to an object where I want the UVs to > > correspond to screen position. A bit like using EYE_LINEAR texgen, but with > > the texture projected 'orthographically' through the screen. > > What I want would in effect be like applying the texture so it always spans > > the window, but without applying the perspective of the camera. I guess, a > > bit like using the texture as a stencil. > > > > I've tried using EYE_LINEAR, and that very nearly does what I want, but I > > want to remove the effect of perspective on the way the texcoords are > > calculated. > > > > In other words, I think I want calculated texture UV's to be something like: > > texcoord.x = (worldPosition * (projectionMatrix * modelViewMatrix)).x > > texcoord.y = (worldPosition * (projectionMatrix * modelViewMatrix)).y > > > > What's the best way to implement this without using stencil buffer or > > shaders? > > Is there a way to do it by adjusting the texture matrix object to remove > > the perspective projection? > > Or would it be better to recalculate texCoords on geometries prior to each > > frame? > > > > Hope this makes some kind of sense. > > > > With those restrictions, it seems like the texture matrix is your only path > to a > solution, though I couldn't type it here off the top of my head. It would > take > some dev time to get it right. > > What you want to do would be trivial with a shader. Is there a reason why > you've > ruled out use of shaders for this problem? > > -- > -Paul Martz Skew Matrix Software > http://www.skew-matrix.com/ >
Thanks Paul, I may use a shader if it comes down to it, but I was trying (if possible) to get a solution that works on Joe Public's bargin basement laptop that probably has poor (if any) shader support. I have experimented with texmat object to get the projection right, but I can't seem to get the matrix right (probably cos of my flakey maths). Maybe I'll post a cut down example an someone can see if they spot the problem. I've had some success with recalculating the texcoords on geometries and assigning them with UVs based on screen coords. It's very nearly what I want but I'm getting some odd distortions due to uv interpolation (I think). Possibly a result of the texture mapping perspective correction, though I tried switching that off with GL_PERSPECTIVE_CORRECTION_HINT = GL_FASTEST to no avail :( Ho hum.... maybe as you say, a shader is the answer, well, if I can make it fail tidy on old craptops. Cheers Chris. ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=34722#34722 _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

