Questions about the texture coordinates

Hi there,

I’ve been poking around in the town scene from the hello collision example and I’m a bit confused about texture coordinates

Why do the vertices in level.mesh.xml have two texture coordinates per vertex? Also, my understanding of texcoords is that they are within the range [0, 1] denoting how far into the texture we are, why is the first texcoord in the vertices outside that range? At first I thought it might have been referring to a bump map or some other uniform but there’s nothing like that in the example. Also, when I export a simple scene with uv mapped textures from blender myself, there’s only one texcoord per vertex.

You can have more than one texture buffer per mesh, it might be useful if you are using multiple textures, and they don’t have the same coords (generally you will only have 1).

The UV map coords go from 0 to 1, but you can reference outside this range. There are texture wrapping functions: repeat, clamp etc which will be used when you reference outside 0 -> 1. You will get 1 texcoord normally from Blender, unless you add extra UV maps to the same mesh.

Thanks wezrule, I understand the concept of sending multiple textures to the shader, it would be for stuff like decals and bumpmaps right? For when you need extra uniform textures that you can do stuff with in your shader. I just don’t get it in the town example what those extra texcoords reference because there doesn’t seem to be a second texture being sent anywhere, and the extra (first) texcoords seem to be random and arbitrary. This was leading me to believe there was something I wasn’t really understanding with these files

For example, here’s a submesh from that scene (it’s shorter than most of the others). Everything in this snippet makes sense to me except those extra texcoords

[java]<submesh material=“estrada-cruz.jpg” usesharedvertices=“false”>
<faces count=“8”>
<face v1=“0” v2=“1” v3=“3”/>
<face v1=“1” v2=“2” v3=“3”/>
<face v1=“4” v2=“5” v3=“7”/>
<face v1=“5” v2=“6” v3=“7”/>
<face v1=“8” v2=“9” v3=“11”/>
<face v1=“9” v2=“10” v3=“11”/>
<face v1=“12” v2=“13” v3=“15”/>
<face v1=“13” v2=“14” v3=“15”/>
</faces>
<geometry vertexcount=“16”>
<vertexbuffer positions=“true” normals=“true” texture_coords=“2”>
<vertex>
<position x="-90.000000" y="-12.500000" z="-30.166672"/>
<normal x=“0.000000” y=“1.000000” z=“0.000000”/>
<texcoord u=“0.000000” v=“0.000000”/>
<texcoord u=“0.632662” v=“0.118999”/>
</vertex>
<vertex>
<position x="-90.000000" y="-12.500000" z="-40.166672"/>
<normal x=“0.000000” y=“1.000000” z=“0.000000”/>
<texcoord u=“0.000000” v=“1.000000”/>
<texcoord u=“0.595060” v=“0.118999”/>
</vertex>
<vertex>
<position x="-100.000000" y="-12.500000" z="-40.166672"/>
<normal x=“0.000000” y=“1.000000” z=“0.000000”/>
<texcoord u=“1.000000” v=“1.000000”/>
<texcoord u=“0.595060” v=“0.081001”/>
</vertex>
<vertex>
<position x="-100.000000" y="-12.500000" z="-30.166672"/>
<normal x=“0.000000” y=“1.000000” z=“0.000000”/>
<texcoord u=“1.000000” v=“0.000000”/>
<texcoord u=“0.632662” v=“0.081001”/>
</vertex>
<vertex>
<position x="-10.000000" y="-12.500000" z="-40.166672"/>
<normal x=“0.000000” y=“1.000000” z=“0.000000”/>
<texcoord u=“0.000000” v=“0.000000”/>
<texcoord u=“0.593058” v=“0.118999”/>
</vertex>
<vertex>
<position x="-10.000000" y="-12.500000" z="-30.166672"/>
<normal x=“0.000000” y=“1.000000” z=“0.000000”/>
<texcoord u=“0.000000” v=“1.000000”/>
<texcoord u=“0.555456” v=“0.118999”/>
</vertex>
<vertex>
<position x=“0.000000” y="-12.500000" z="-30.166672"/>
<normal x=“0.000000” y=“1.000000” z=“0.000000”/>
<texcoord u=“1.000000” v=“1.000000”/>
<texcoord u=“0.555456” v=“0.081001”/>
</vertex>
<vertex>
<position x=“0.000000” y="-12.500000" z="-40.166672"/>
<normal x=“0.000000” y=“1.000000” z=“0.000000”/>
<texcoord u=“1.000000” v=“0.000000”/>
<texcoord u=“0.593058” v=“0.081001”/>
</vertex>
<vertex>
<position x="-90.000000" y="-12.500000" z=“29.833328”/>
<normal x=“0.000000” y=“1.000000” z=“0.000000”/>
<texcoord u=“0.000000” v=“0.000000”/>
<texcoord u=“0.870286” v=“0.078999”/>
</vertex>
<vertex>
<position x="-100.000000" y="-12.500000" z=“29.833328”/>
<normal x=“0.000000” y=“1.000000” z=“0.000000”/>
<texcoord u=“0.000000” v=“1.000000”/>
<texcoord u=“0.832684” v=“0.078999”/>
</vertex>
<vertex>
<position x="-100.000000" y="-12.500000" z=“39.833328”/>
<normal x=“0.000000” y=“1.000000” z=“0.000000”/>
<texcoord u=“1.000000” v=“1.000000”/>
<texcoord u=“0.832684” v=“0.041001”/>
</vertex>
<vertex>
<position x="-90.000000" y="-12.500000" z=“39.833328”/>
<normal x=“0.000000” y=“1.000000” z=“0.000000”/>
<texcoord u=“1.000000” v=“0.000000”/>
<texcoord u=“0.870286” v=“0.041001”/>
</vertex>
<vertex>
<position x=“0.000000” y="-12.500000" z=“29.833328”/>
<normal x=“0.000000” y=“1.000000” z=“0.000000”/>
<texcoord u=“0.000000” v=“0.000000”/>
<texcoord u=“0.830682” v=“0.078999”/>
</vertex>
<vertex>
<position x="-10.000000" y="-12.500000" z=“29.833328”/>
<normal x=“0.000000” y=“1.000000” z=“0.000000”/>
<texcoord u=“0.000000” v=“1.000000”/>
<texcoord u=“0.793080” v=“0.078999”/>
</vertex>
<vertex>
<position x="-10.000000" y="-12.500000" z=“39.833328”/>
<normal x=“0.000000” y=“1.000000” z=“0.000000”/>
<texcoord u=“1.000000” v=“1.000000”/>
<texcoord u=“0.793080” v=“0.041001”/>
</vertex>
<vertex>
<position x="-0.000015" y="-12.500000" z=“39.833321”/>
<normal x=“0.000000” y=“1.000000” z=“0.000000”/>
<texcoord u=“1.000000” v=“0.000000”/>
<texcoord u=“0.830682” v=“0.041001”/>
</vertex>
</vertexbuffer>
</geometry>
</submesh>[/java]

My guess would be they are for some kind of lightmap or something. I’ve never looked at the scene, though.