UVW mapping

Started by
9 comments, last by V-man 13 years ago
I cannot find what how to do UVM mapping. Please, explain me or give me a link.
Advertisement
OpenGL doesn't define UVM mapping.

There are many pages that seem to talk about UVM mapping but they are about a software package = 3D Studio Max and Cinema4D.
Like this one
http://waylon-art.com/uvw_tutorial/uvwtut_01.html

and this one
http://forums.cgsociety.org/archive/index.php/t-412221.html
http://lounge.ego-farms.com/showthread.php?t=970

perhaps you should ask on the artists forum.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Yes, I know. But I need to implement UVW mapping with GLSL.
uh.....you said you 'need to' instead of 'want to' so I'm assuming this is homework? Do you know what uv-maps /uv mapping is. What are you asking how to texture a cube? How to spherical map something?

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

UVW seems to be about automatically assigning texture coordinates. I'm sure the algorithm is quite involved and it would be done in your application code rather than a shader. You should have a function that takes the model's indices and vertices and calculates the best texcoords for it. Look at the Blender source code if you want but you will have copyright issues if you just steal other people's code (http://www.blender.org)
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
I must recalculate texture coordinates due to the third coordinate, do not I?
Could you explain in more detail or give a link with the explanation? How is this technique named?


[color=#333333]I want to know how the third texture coordinate influence to my model and there is such a situation:Here is model in DAE format:
http://www.speedyshare.com/files/28222811/clown.rar
If you have not Collada importer, look at this snippet:
<mesh>
<source id="geom-Line01-positions">
<float_array id="geom-Line01-positions-array" count="3969">-4.574107 9.329709 0.08463868 -0.4054546 8.766739 1.292424 1.775585 8.825006 0.075146 2.263489 6.411057 0.1705481 ...</float_array>
<technique_common>
<accessor source="#geom-Line01-normals-array" count="2944" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="geom-Line01-normals">
<float_array id="geom-Line01-normals-array" count="8832">0.03413525 0.9753383 0.2180594 0.06667629 0.979407 ..</float_array>
<technique_common>
<accessor source="#geom-Line01-normals-array" count="2944" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="geom-Line01-map1">
<float_array id="geom-Line01-map1-array" count="4704">0.7679129 0.9745173 0.5042325 0.7959707 0.9707325 0.56463 0.8106505 0.9711242 0.5037578 0.8139344 0.954895 0.5085286 0.8090085 0.9120827 0.5159985 0.8043709 0.8602077 0.5033876 0.8214802 0.8594028 0.5001622 0.8328388 0.8622966 0.5 0.8367841 0.8614986 0.5 0.8301358 0.8596589 0.5 0.8179256 0.8579739 0.5003169 0.800105 0.8595144 ...</float_array>
<technique_common>
<accessor source="#geom-Line01-map1-array" count="1568" stride="3">
<param name="S" type="float"/>
<param name="T" type="float"/>
<param name="P" type="float"/>
</accessor>
</technique_common>
</source>
<vertices id="geom-Line01-vertices">
<input semantic="POSITION" source="#geom-Line01-positions"/>
</vertices>
<triangles material="Material__166_1" count="1302">
<input semantic="VERTEX" source="#geom-Line01-vertices" offset="0"/>
<input semantic="NORMAL" source="#geom-Line01-normals" offset="1"/>
<input semantic="TEXCOORD" source="#geom-Line01-map1" offset="2" set="0"/>
<p>0 0 0 1 1 ...</p>
</triangles>
<triangles material="klown1" count="1032">
<input semantic="VERTEX" source="#geom-Line01-vertices" offset="0"/>
<input semantic="NORMAL" source="#geom-Line01-normals" offset="1"/>
<input semantic="TEXCOORD" source="#geom-Line01-map1" offset="2" set="0"/>
<p>140 162 517 ...</p>
</triangles>
</mesh>

Here you can see three texture coordinates per vertex, how I can use the third? You may note that there is not 3D texture here, I don`t think that this is the projective texturing. The other thing which I have heard is UVW mapping and from the brief description of this technique I can assume that this is it.

Where does this collada data come from? Which modelling package do you use?

Ideally, you'd use your 3D package to do as much of the conversion to "game ready" data as possible.

E.g. if modelling with NURBS, then the package should convert to triangles when you export. Or if modelling with 3D texture coordinates, it should convert to 2D UV coordinates on export.
This model was exported from 3DS Max. Here is the original model: [font=verdana, arial, sans-serif]http://www.speedyshare.com/files/28223821/clown.zip.[/font]
If you have never loaded a 3D model, then really all you need is 2 uv coords. What are the 3rd coordinates all '0' ? A 3rd coordinate for a uv value really doesnt do anything unless you have multiple images. So collada might be default just set them all to 0 or 1 if you only have 1 image.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

This topic is closed to new replies.

Advertisement