OverlayNode.cpp has some shader code in it you might look at.

In osgEarth we pass in a texgen matrix in a uniform, then in the vertex
shader say:

gl_TexCoord[1] = texGenMatrix * osg_ViewMatrixInverse * gl_ModelViewMatrix
* gl_Vertex;

Then in the frag shader:

vec2 tc = gl_TexCoord[1].xy / gl_TexCoord[1].q;
vec4 texel = texture2D( texture_1, tc );

Or, I I believe you could also call:

vec4 texel = texture2Dproj( projTex, gl_TexCoord[1] );

..but I've never tried it.
HTH.

Glenn Waldron / @glennwaldron


On Wed, May 9, 2012 at 3:12 PM, Loren Hoffman <[email protected]>wrote:

> Glenn,****
>
> ** **
>
> Thanks for the response. I got the texture showing up in a test scenario
> but am having a problem computing the texture coordinates. I looked through
> the overlaynode’s header file and didn’t see anything which I could use to
> compute the texture coordinates but did find that the implementation file
> has some code for creating a matrix which can (I think) convert the
> gl_Vertex into a valid coordinate but then I couldn’t find anything
> specifying where it would be bound to. I randomly tried the first few
> gl_TextureMatrices but either they don’t contain the matrix or I am using
> it wrong. Currently I am attempting:****
>
> ** **
>
> vec4 col = texture2D(overlay, (gl_TextureMatrix[1] * gl_Vertex).xy);****
>
> ** **
>
> where using index 1 is just one of the tests. Any help would again be
> appreciated. ****
>
> ** **
>
> Thanks,****
>
> - Loren****
>
> ** **
>
> *From:* [email protected] [mailto:
> [email protected]] *On Behalf Of *Glenn Waldron
> *Sent:* Wednesday, May 09, 2012 1:17 PM
> *To:* OpenSceneGraph Users
> *Subject:* Re: [osg-users] osgSim::OverlayNode and Point Clouds****
>
> ** **
>
> Loren, ****
>
> ** **
>
> If your point cloud has a custom shader, make sure that shader is
> rendering the projected texture used by OverlayNode.****
>
>
> Glenn Waldron / @glennwaldron
>
> ****
>
> On Wed, May 9, 2012 at 2:05 PM, Loren Hoffman <[email protected]>
> wrote:****
>
> Hello All,****
>
>  ****
>
> I have a setup where I need to project an overlay node’s sub graph onto a
> point cloud. We already have it setup to overlay onto geometry created with
> VPB and I was hoping it would “just work”™ for the clouds. Unfortunately it
> seems to have no effect at all on cloud despite it having been inserted
> into the graph in the same manner that the vpb geometry was. The point
> cloud is being rendered with a custom shader setup but I didn’t come across
> anything saying that that would be an issue. Is there anything I need to do
> to the point cloud’s graph to make it so it will accept the overlay or is
> this a limitation of the overlay system? Thanks in advance,****
>
>  ****
>
> - Loren****
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org*
> ***
>
> ** **
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to