PDA

View Full Version : how to handle texture outside range 0-1.0



giordi
06-22-2014, 10:12 AM
Hello everyone , I would like to load a model (obj ) in my 3d viewport , I can load it no proble all works good.
I also wish to load the texrure , only problem is that the texture ranges bigger then 0-1, the model is actually coming from
autodesk maya and maya support multiple tiles , I tink the texture range from -2 to 2 in both x and y.
How can I handle that? Is it there a way to tell opengl to not normalize my texture between 0-1? or I should let opengl normalize it and then I normalzie my texture
coords on the model as-well?

Cheers

carsten neumann
06-23-2014, 12:27 AM
What happens when accessing a texture with coordinates outside the [0,1] range is controlled by the GL_TEXTURE_WRAP_{S,R,T} settings of the texture object (or sampler object if one is active), see glTexParameter (http://www.opengl.org/sdk/docs/man/html/glTexParameter.xhtml).

giordi
06-23-2014, 04:01 AM
THank you for your answer , i knew the wrap methods , problem is I dont want any of them , I dont want to tile , I dont want to extend the color etc.
If I am correct when I load the texture no matter what that texture is gonna span a range 0-1 right? so If I know that my texturecoordinates span a -2, 2 range probably I can just normalize the range right?

carsten neumann
06-23-2014, 04:50 AM
If you are using the fixed function pipeline (i.e. no shader programs) you can also use the texture matrix to modify texture coordinates before they are used to access the texture. With shaders you can modify the tex coords in whatever way you need and in both cases you can modify them once after loading the data.

giordi
06-23-2014, 08:00 AM
I am using shader pipeline, that s what I was thinking , remapping the texture coordinate in the correct range, I was wondering if this was correct approach.
Now I need to find a way to figure out the correct range of the texture, I was thinking to proces the data and keep track of bot min and max value in u,v, but that doesnt mean
the value I get is going to reflext the correct range , since most likely I wont have the poly at the very edge of the texture.
mmmm tricky