How do I get a 'model reference' space position of the earth?

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

How do I get a 'model reference' space position of the earth?

Hello,

I'm trying to get 'reference' position of the actual model of the globe instead of using the model space position as it's wreaking havoc with my projection textures (i.e. they are tiling like the terrain is).  I want to project a texture using my own uniform matrix but transforming the model space vertex changes with the tiles.  Ideally, I want a reference vertex position that never changes and can be accessed by the shaders.
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: How do I get a 'model reference' space position of the earth?

You can multiple your position by the modelview matrix to get out of model space and into view space. If you need to get into world space, premultiply by the inverse view matrix.

e.g., in GLSL:

vec4 worldVertex = osg_ViewMatrixInverse * gl_ModelViewMatrix * modelVertex.

Of course, you may run into precision issues going this on the GPU.
Glenn Waldron / Pelican Mapping
marlinrowley marlinrowley
Reply | Threaded
Open this post in threaded view
|

Re: How do I get a 'model reference' space position of the earth?

Thanks for this but it still tiles my projection when I zoom into the globe.

Any other thoughts?
marlinrowley marlinrowley
Reply | Threaded
Open this post in threaded view
|

Re: How do I get a 'model reference' space position of the earth?

In reply to this post by marlinrowley
To add..

I put just a regular texture on the globe using gl_MultiTexCoord0 as the texture coordinates, and this texture also tiles when zooming in and repeats.  I want a static unchanging texture as if it was on a sphere and I zoom in.

Does that help?