how to map an image onto an irregular 3d object?

Hello,

I was asked to map an image to a heart model whose shape is irregular. Could anyone please give me some idea how to do this?
Is this possible?
Thanks a lot
Alison

I posted this quesion in OpenGL Coding:advanced. and below is a reply.

ZbuffeR
OpenGL Guru

Registered: 12/01/03
Posts: 2371
Loc: Grenoble - France
The keyword you search for is “unwrapping”.
A good technique is “Least Squares Conformal Mapping”, abreviated as LSCM.
The Blender 3D package has good tools to help artists unwrap sucessfully any sort of meshes, even the most complex ones.
http://wiki.blender.org/index.php/Manual/Unwrapping_a_Mesh

If you prefer simpler concepts, depending on the complexity of the mesh, a simple spherical or cubic mapping can be enough.

By the way, this is not really an opengl subject, more a “Math & Algorithms” one.

Edited by ZbuffeR (07/15/08 03:40 PM)

Hi ZbuffeR,
I do prefer simpler concepts. I found it hard to read ‘unwrapping’, ‘Least Squares Conformal Mapping’, etc.
I am a beginner in OpenGL, i did some 2D texture mapping before.
How would you suggest to do it with a simple spherical or cubic mapping?
Thanks.

“UV atlas” is another term, that relates to unwrapping.
Basically, this is a feature that most 3D modelers have - automatic computation of UVs, so that a 3D object’s surface is nicely packed into a texture.
Here are some UV unwraps:


It’s computationally expensive, and really never needed in realtime. So, this is static data, that the artist creates. Plus it really needs an artist’s intervention to split areas optimally for improved texture-quality on same texture-size (the skull example above shows this nicely).
Here’s a bit of reading: http://www.menithings.com/main.php?action=how&how_id=7&manual=1
Btw it’s also used in light-mapping (static light in Quake, HalfLife2, all games till 2004). There, you first create a nice UV layout of an object/scene’s vertices, and via raytracing compute the light intensity/color at each texel. (so, you get the texels automatically computed)

On the other hand, when an artist creates a model, he/she first sculpts it, then makes the UV atlas, and finally draws on the surface of the 3D model, using software like Z-Brush. (it’s like spraying paint on a real sculpture). So, here the artist draws the texels himself/herself, a bit indirectly.

Hi Ilian Dinev,

Thank you for the detailed explaination. Do you also think i should use unwrapping or some spherical or cubic mapping would work?
Thanks

It depends on your heart mesh complexity. If you have a heart with many details veins, arteries, maybe you would see some mapping artifacts on it (stretched texture…).

I think you should do this task inside a 3D modeler and then export your model with its texture coordinates in an appopriate format.

Spherical and cubic mapping are really unsuitable for anything that doesn’t have that regular shape respectively :). But I suppose they are easy to compute in realtime, and for this reason they were suggested to you.

Just try them in a 3D modeler, to see how nasty results you can get. Sure, it can be acceptable, but cannot reach the detail and truth-in-representation of UV-unwrapping. In a modeler, they take just 1 click to make.
To make an UV atlas, you just click “make UV atlas” in your modeler. There’s some chance you get a nicely packed texture on the first attempt (nicely packed as the skull example above). If it doesn’t look right, you select some contiguous region of the mesh, and make it as a separate segment (this will duplicate vertices at the edges of the segment). To create that separate segment, usually in modelers you just select some triangles, cut it (the Ctrl+X way), and paste it. Right after that, you again click “make UV atlas”, and see whether the texture is nicer. As you can see from the skull, this process might need to be repeated 50 times… it’s tedious for inexperienced artists.

But it’s very easy to do if you don’t strive for perfection and smaller texture-sizes :slight_smile:

dletozeun, Ilina,
thanks for the reply. Where can i get a 3D modeler?
In my case, each time i can load a different heart model in my program, will the same UV atlas work for all different heart models?

You did not follow the discussion ? get Blender.
http://www.blender.org/download/get-blender/

And no, it will not work for different meshes.

Sorry, i followed the link harf way then i found it is too complicated to me.
If it will not work for different heart models, then it may not work for me.
But i will check with others, we may have the same default heart model for all.
Anyway i will try blender first.
Thanks