# UV Texture coordinates out of [0,1] (WebGL)

I'm creating a 3D game with WebGL and i'm using Wavefront Objects as a base model format. I recently found some models, their texture coordinates of which are out of the typical [0,1] range and i really don't know how to handle them (in code).

I know of course this is a known issue, texture coordinates can be outside of [0,1] and the solution is to use GL_REPEAT wrap mode.

But this is no solution to me since i have a lot of non-powered-by-2 textures and i need to use CLAMP_TO_EDGE wrap mode (the solution to non-pow-2 textures).

I tried to bypass this issue by coding, so to convert [0-,1+] ranges into [0,1] but with not much of success (although somewhat). Here's what i did: I looped "vt" entries (from my parser) and the cases i'm checking are these (pseudo):

U,V = texture coordinates as they come from file

if (U<0) {
U = U + Math.abs( Math.floor(U) );
}
if (U>1) {
U = U - Math.floor(U);
}
if (V>=0) {
V = Math.ceil(V) - V;
}
if (V<0) {
V = Math.abs( Math.floor(V) - V );
}


The above fragment will take a U,V of unknown range and will convert it into [0,1], taking also care the WebGL texture coordination system (0,0 buttom-left for WebGL but 0,1 for Wavefront, the 3rd case above)

The numbers are calculated correctly but the result is not the expected and i'm afraid there is a misunderstanding by my side on how the GL_REPEAT mode works.

So my question(s)

• Can this be solved by code, so i can use CLAMP_TO_EDGE?
• In case there's no way, is there any program than can take a model of REPEAT-ed coordinates and produce one in [0,1] range? I'm already using Blender but could not find a setting for this in exporter.