World positions on rendering the tiles.

classic Classic list List threaded Threaded
4 messages Options
marlinrowley marlinrowley
Reply | Threaded
Open this post in threaded view
|

World positions on rendering the tiles.

We are running into a problem where we are passing in a world space vertex into our vertex/pixel shader (from the terrain),

WorldVertex = inverse(gl_ModelViewMatrix) * gl_ModelViewMatrix * aVertex;

 and doing some computation with that vertex.  However, we are seeing the computation be tiled along with the entire terrain.  This leads me to believe that the vertex isn't a "unique" vertex and is being repeated for each tile.  Am I missing something?

-M
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: World positions on rendering the tiles.

Marlin,
Not sure what you mean exactly; however, your computation of the world vertex is wrong. It should be:

WorldVertex  = osg_ViewMatrixInverse * gl_ModelViewMatrix * aVertex;

I.e., use the inverse of the view matrix, not the inverse of the modelview matrix. Also be aware you will lose precision doing this in the shader.
Glenn Waldron / Pelican Mapping
marlinrowley marlinrowley
Reply | Threaded
Open this post in threaded view
|

Re: World positions on rendering the tiles.

Where is osg_ViewMatrixInverse defined?  It's giving me an error when using it.
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: World positions on rendering the tiles.

You have to declare it:

uniform mat4 osg_ViewMatrixInverse;

And OSG automatically sets it in the frame loop.
Glenn Waldron / Pelican Mapping