Glenn,

Thanks again for the help. While pursuing your suggestion I introduced a bug in 
my shaders which led to me seeing that the default point cloud rendering was 
somehow having the overlay texture successfully applied. This made me think 
that the data was in the gl uniforms somewhere and after a few hours I found 
them in the gl_EyePlaneS/T variables allowing me to compute my texture cords 
with:

vec2 tc;
vec4 v = gl_ModelViewMatrix * gl_Vertex;
tc.x = dot(v, gl_EyePlaneS[1]);
tc.y = dot(v, gl_EyePlaneT[1]);

This assumes that my overlay was set to use texture unit 1. I figured I would 
respond with the answer since I found other instances of users asking about 
this system and often times those questions seemed to reach you. The result of 
my search is very confusing (even though it works) since my overlay is set to 
be object dependant and at no point did I find any code associated with an 
object dependant overlay doing anything with the eye plane settings that would 
be applied to the general render.

- Loren

From: [email protected] 
[mailto:[email protected]] On Behalf Of Glenn Waldron
Sent: Wednesday, May 09, 2012 2:57 PM
To: OpenSceneGraph Users
Subject: Re: [osg-users] osgSim::OverlayNode and Point Clouds

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]<mailto:[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]>
 
[mailto:[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]<mailto:[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"(tm) 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]<mailto:[email protected]>
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


_______________________________________________
osg-users mailing list
[email protected]<mailto:[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