Jump to content
  • Advertisement
Sign in to follow this  
Gedden

Ortohgraphic Texture Projection?

This topic is 3471 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What I want to do is project a texture in 2D space on to a 3D terrain (like a gird over multiple objects with various textures). I want to keep the dimensions of this projection (I dont want it to grow or shrink by distance). I think what im looking for is some kind of tutorial on orthographic texture projection. This does not seem that advanced to me, but I cant seem to find any good references for how to accomplish this. I have seen many "general overviews" on texture projection, and a bunch for light-map & shadow map based stuff (which I dont think is exactly what im looking for). I would prefer to do this via traditional GL, but if a good orthographic projection is hard to achieve this way, then is doing this cg (or some other shader) the common way to accomplish this?

Share this post


Link to post
Share on other sites
Advertisement
Just set up the texture matrix with glOrtho. You might also want to apply a rotation

glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glOrtho(...);
glRotate(....);

or maybe use gluLookAt to rotate

glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glOrtho(...);
gluLookAt(....);

Share this post


Link to post
Share on other sites
I feel all the samples I have seen kinda gloss over the concept im having problems with. If I were to switch to glMatrixMode(GL_TEXTURE), at exactly what point do I tell GL texture X is the texture I want to project?



<render my existing geometry>

glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glOrtho(...);
gluLookAt(....);

// now how do I setup the projected texture I want?
glBindTexture(GL_TEXTURE_2D, texture_id); // ?
// Render on existing geometry??

Share this post


Link to post
Share on other sites
There are many ways to do it. Here are some examples

//Example 1
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glOrtho(...);
gluLookAt(....);
glBindTexture(GL_TEXTURE_2D, texture_id);

//Example 2
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glOrtho(...);
glBindTexture(GL_TEXTURE_2D, texture_id);
gluLookAt(....);

//Example 3
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glBindTexture(GL_TEXTURE_2D, texture_id);
glOrtho(...);
gluLookAt(....);

//Example 4
glMatrixMode(GL_TEXTURE);
glBindTexture(GL_TEXTURE_2D, texture_id);
glLoadIdentity();
glOrtho(...);
gluLookAt(....);

//Example 5
glBindTexture(GL_TEXTURE_2D, texture_id);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glOrtho(...);
gluLookAt(....);


so that makes it 5 possibilities.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!