Jump to content
  • Advertisement
Sign in to follow this  
dshader_t

normalize texture coordinates to [0,1] range

This topic is 1291 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hiho 

my question is simple.

SHORT QUESTION:

Can I normalize somehow (if yes, how?) 3D model texture coordinates to [0,1] range?

LONG QUESTION:

I mean, it looks like coordinates are sometimes out of [0,1] range but it's okay for GPU since it's using GL_REPEAT for image or equivalement for DX, but let's imagine that I have to store texcoords only in [0,1], would it affect model texture mapping or still look the same?

thank you for any ansawers!

Share this post


Link to post
Share on other sites
Advertisement

If coords are correct that looks the same, the flag GL_REPEAT is just there to say what behavior you want if outside the [0,1] range.

Share this post


Link to post
Share on other sites

would it affect model texture mapping or still look the same?

It would not look the same. Extra vertices and degenerate triangles would be required to get the same result.


L. Spiro

Share this post


Link to post
Share on other sites

Really, I was sure if coord was correct it looked the same.

EDIT : The interpolation of coords will not give the same result that's true like a lerp from 0.75 to 0.5 and 0.75 to 1.5 for example.

Edited by Alundra

Share this post


Link to post
Share on other sites

Okay, so when I want to merge two textures (two index buffers) into single batch, how can I do that? I have two meshes with 512x512 texture, and I wanted to create one mesh with 1024x512 texture. It "worked" so far but the texcoords are disturbed, so you are right.

Any workarounds?

Share this post


Link to post
Share on other sites

If they have repeating texture coordinates then you are kind of out of luck.

 

But say if they only repeat in one axis then you can combine them into either 1024x512 or 512x1024 and just repeat on the 512 axis. Like buckeys picture in the x/u direction you cant wrap, but you could in the y/v direction.

 

If they don't repeat you just need to divide the texture coordinates of the long axis each by 0.5 so now both textures go from 0-.5. Then whichever you place not at 0 in the texture you would add 0.5 to that axis. so you would get one that is 0-.5 and one that is .5-1 in say u and then in v both would go from 0 - 1 still. 

 

If you really need to wrap things then you could look at using a texture array of 512 x 512 x 2.

 

This can be one of the down sides of atlasing. If you need something to wrap you generally have to add in a new poly that repeats the same 0-1 range.

 

It's usually better to fix this in the art side so that combining them is the trivial case of shifting uv coordinates and merging textures.

Share this post


Link to post
Share on other sites


I wanted to create one mesh with 1024x512 texture.

 

As Eklipse mentions: can't be done if any tex coords for any vertex in either mesh is not in the range [0,1].

 


If you really need to wrap things then you could look at using a texture array of 512 x 512 x 2.

 

^^^ This.

 

That means you have to provide info at render-time to select the texture in the array.

 

Alternatively, load the textures separately, and, for the combined (re-indexed) mesh, render the first range of indices with the first texture, and the second range of indices with the second texture.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!