How to texture a map on a curved surface?

I am trying to create a 3d game using OpenGL. I have a very simple world, and now I'm working on a character. I want to apply a texture to the head, which will be oval. How to make a comparison? I know how to match a flat surface. I am wondering if normals can be used to help, but I have never done this before, and when I search Google, I’m out of luck.

I plan to do this all programmatically and not use Blender or Maya, if that matters.

+6
android language-agnostic iphone opengl-es
source share
1 answer

I suppose you have everything in order with geometry?

For automatic matching in the general case, your hunch is a good idea - start from each vertex and follow its normal outward until you click on a well-defined external primitive, and then copy the location of the texture inward.

In this case, I think, probably, the key is how you create your geometry. If you are doing something like creating 8 rings of 16 points, effectively repeating around one circle in the outer loop and another in the inner loop, you can iterate over u and v at the same time to get a match. You get a few wrong polygon sizes, and mapping becomes uncomfortable at the poles, but the area around where the face will work quite well.

If you want to have a more equal polygon size and reliable display in all areas, then start with a cube with more tessellated ones (for example, grids of 8x8 squares per surface instead of one) and match the texture coordinates in any meaningful way. Think in terms of a cube network. Then we deform the cube into a sphere, setting the vector from the center to each point and moving the point so that it is the radius of the sphere from the center. Finally, we deform the sphere into an oval, changing different axes in different ways.

+1
source share

All Articles