3D Texture Map

I’m sure we’ve all seen the 2D texture map of a flag blowing in the wind.

I need to write some code that will allow me to do this ‘mesh warping?’ in 3D.

Is this possible with OpenGL and/or can you point me to an example?


The question “can this be done with OpenGL” can usually be answered with “yes”.

But i don´t know, what you want to do. Do you actually want to do that flag-blowing-in-the-wind-thing ? In this case, check out nehe.gamedev.net (lesson 11).
Otherwise, i don´t know what you mean.


I think the OP wants a 3D texture mapped on some animated waving teapot.

Well actually I want to move the verticies of the 3D texture, pass a plane through the cube and render the surface of that plane as it passes through the 3D texture.

I’m not sure I understand what you mean. A texture does not have vertices …
Is this anything near what you have in mind?

Put a plane into your fragment program using [0,0,0]->[1,1,0] coordinates.

In your fragment program, perturb the texture coordinate in any way you want before you fetch out of the 3D texture.

Problem solved.

As far as I know I define a 2D texture with glTexImage2D,
glTextParameterf and then with glBegin(GL_TRIANGLE_STRIP)
glBegin, glNormal3f, glVertex3f and compile these into a newlist etc. etc.

So that is what I mean about the texture having vertices…

So my question is how to do that in 3D? I’ve heard about 3D texture maps but haven’t actually had chance to program it.

In 2D I need to move the points that I defined with glVertex to make an object move (Like the flag wave). Perhaps there is a better way to do this that I am unaware of.

A 2D texture can be applied in 3D. The vertices are 3D etc but the texture coordinates and interpolated image remain 2D. Yes 3D texture exists and can be used but that is really to sample a slice through a 3D image for example if you had a 3D marble texture and wanted to sample based on surface location in that volume.

I’m moving this thread to the beginners section.