PDA

View Full Version : Texture Mapping on Surface

Rong Yao
08-13-2003, 05:47 AM
Is there anyway to map a texture on a surface instead of a 2D-plane?

zix99
08-13-2003, 07:07 AM
I don't understand your question very well, i think you mean instead of 1 texture on 1 quad, have 1 texture on a whole terrain. In this case you would just change the UV for each quad.

for example if you have one texture and a terrain 128x256 you would use an equation, (1/128)*x for U;(1/256)*y for V, do determine the coordinates for each quad where X and Y are points on the terrain.

I hope this could Help http://www.opengl.org/discussion_boards/ubb/smile.gif
ZIX

Orzech
08-13-2003, 07:13 AM
Sure there is! It just depends on how is your surface described. You can check out "Evaluators & NURBS" in The Red Book. OpenGL (and glu) gives some features allowing to draw curves and 3d surfaces. From what I know, you can then apply a texture to this surface.
Other solution is to divide your surface into number of triangles (or quads) and to map a texture on each primitive as if it was a 2D plane. It's really a way to do that! More or less it is how terrain is presented in some of games.

Rong Yao
08-13-2003, 08:56 AM
Thank you zix99, thank you Orzech.

I have never tried the first solution. I will try it.

As to solution II, will it slow down the application and use a lot of video memory?

Originally posted by Orzech:
Sure there is! It just depends on how is your surface described. You can check out "Evaluators & NURBS" in The Red Book. OpenGL (and glu) gives some features allowing to draw curves and 3d surfaces. From what I know, you can then apply a texture to this surface.
Other solution is to divide your surface into number of triangles (or quads) and to map a texture on each primitive as if it was a 2D plane. It's really a way to do that! More or less it is how terrain is presented in some of games.

[This message has been edited by Rong Yao (edited 08-13-2003).]

Orzech
08-14-2003, 03:07 AM
Originally posted by Rong Yao:
As to solution II, will it slow down the application and use a lot of video memory?

You mean dividing your surface into primitves, right? No - it's one of the fastest ways of doing it. It all depends, of course, on a number of vertices and a method. You can do it easily without using video memory to save data. Storing all vertices in an array (for example GLfloat Vertex[100][3]) use mainborad memory and not the graphics cards one.