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.

1 Answer 1


I think you would be better off re-sizing your textures to the nearest power-of-two. You won't need to adjust the texture coordinates as they are relative to the size of the texture image (although you may need to set v = 1 - v to account for the different origins).

The problem with wrapping the texture coordinates yourself is that filtering will not work correctly at the "seams" where a value goes suddenly from 1 -> 0.

  • \$\begingroup\$ Thanx, well i ended up by resizing all of my textures of my paid models. I am quite surprised there's no solution to this. In my opinion texture coordinates outside [0,1] are just wrong and weird and there's no solution for converting, yet Open/Web GL REPEAT mode is the default. I'm confused but hey, thanx for clearing that out :) \$\endgroup\$
    – user43436
    Commented Mar 17, 2014 at 22:26

You must log in to answer this question.