View Full Version : 3D Texture Map
09-22-2004, 12:59 PM
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.
09-22-2004, 01:30 PM
I think the OP wants a 3D texture mapped on some animated waving teapot.
09-22-2004, 02:02 PM
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.
09-22-2004, 02:55 PM
I'm not sure I understand what you mean. A texture does not have vertices ...
Is this anything near what you have in mind?
09-22-2004, 05:21 PM
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.
09-23-2004, 08:30 AM
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.
09-23-2004, 09:14 AM
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.
09-23-2004, 01:18 PM
Yes what your saying about a 3D marble texture and passing a slice through it is exactly what I'm trying to do however the block of marble is malibal. Do you know of any code snippets that make use of a 3D texture in this way?
09-23-2004, 02:28 PM
Yes, this is relatively simple.
There are two possible graphics behaviours with a "malleable" marble surface. One is that your 3D texture moves with the block and so the surface remains the same. An alternative is that the surface slides through the marble block, its local surface appearance changing with the contents of the 3D texture.
Both are possible.
To move the surface and retain the original 3D texture appearance you would retain the original 3D texture coordinates for that surface.
To slide through you simply update the 3D texture coordinates as the vertex coordinates change. This is pretty simple to do but OpenGL has functions which can automatically do this making it hardware accelerated and automatic, this mechanism is called texgen. Simply set up and enable texgen for s t and r coordinates with plane equations around your flag to match the desired axis orientation and position of your 3D texture volume.
Once you've done this each 3D vertex will produce a texture coordinate based on its position in the volume.
09-23-2004, 02:51 PM
P.S. read this useful thread, it should give you a good idea of how to set up the texgen etc.
http://www.opengl.org/discussion_boards/cgi_directory/ultimatebb.cgi?ubb=get_to pic;f=3;t=006597 (http://www.opengl.org/discussion_boards/cgi_directory/ultimatebb.cgi?ubb=get_topic;f=3;t=006597)
and some of the broken links from that thread:
09-24-2004, 09:01 AM
Thank Dorbie... :)
I'll check out these threads... In the advanced discussion group.
I just wanted to be sure we were on the same page in regards to the clipping plane.
I'm my application it would be equivalent to cutting a tree down and being able to see the rings of the tree.
Is this accomplished with clipping plane?
09-26-2004, 10:21 AM
When you are using 2D textures you define the points on the texture using right hand rule..
What do you do for 3D textures?
Would it be easier to use triangles or quads?
Are there backface issues think about?
Are there vertext norms to define?
I just found an example in the red book texture3d.c Do you recommend I use it?
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.