View Full Version : M15 texturing - UV Coordinates
dcromley
04-04-2009, 23:18
Hello,
I am looking at the TBGL_0220_Samples/Bones/TBGL_0200_AnimatedCubes.tbasic.
This, with the Cubes.M15 model and the kp4_..bmp texture make a great demo.
I don't get the TextureUCoordinate (and V) POLY parameters at all.
For example, the first POLY has "282.237196,1024.955354" for the U,V.
The *.bmp is 256x256. Can you point me to somewhere? Thanks, Dave
Michael Hartlef
05-04-2009, 08:55
Hi dcromley,
welcome here on the forum. I can't answer the question 100% as I think the cube M15 model was made with thinEdge, Petr Schreibers model application.
When you look into the help file of TBGL and there under TBGL_TexCoord2D you will see that a value bigger then 1 means texture repitition. But then again, I can't see that in the output so Petr can answer that better.
Michael
Petr Schreiber
05-04-2009, 10:12
Welcome!,
Mike was correct of course.
TBGL / OpenGL texture coordinates do not store pixel positions, but relative positions. This way the UV mapping doesn't become damaged when you change texture to 2x bigger resolution for example.
I attach 2 pictures for you to explain.
If you are confused by the big numbers representing UV coords in the model, it is because in ThinEdge you can stretch and shift the texture over the model, so I got little mad and shifted and stretched ... too much :)
Petr
dcromley
05-04-2009, 23:26
Michael,
>welcome to the forum
Thanks! This thinBasic is awsome!
>help file of TBGL .. TBGL_TexCoord2D
I hadn't looked at TBGL texturing. Jumped ahead to M15 and missed it. Thanks.
But it still doesn't answer everything. Especially the repetition.
Petr,
>Welcome!
Thanks! This thinBasic/TBGL is awsome!
I have everything I want now, just using simple 0-1U and 0-1V. Thanks.
And I could repeat if I want (bigger than 1).
But that UV = "530.194719,1922.791202" in the Cubes.M15 file really blew my mind
and led me astray. The difference is 1392.596483. That's quite a bit bigger than 1.
And why all the decimals?
Don't go away guys -- I'll have more questions. As I learn this thinBasic, I have this
great plan to write great learning examples/tutorials while it's still fresh in my mind.
I wonder if I will follow up.
Petr Schreiber
06-04-2009, 08:21
To not confuse you,
I will prepair new version of the model, which will have "nice" UVs.
The current ones were done in ThinEdge after many texture transformations as I said, so I admit it looks odd.
I will update the help file with pictures in my last post as well.
Petr
Michael Hartlef
06-04-2009, 08:41
That sounds like a nice plan. Franck aka Lionheart008 does a similar thing reagrding tutorials and samples.
Why so many decimals? Well, simply you need them. Let's take a texture with 512x512 pixel. A polygon isn't allways texture with the full image, rather with just parts of it.
So let's say that your polygon needs a texture going from 0,0 to 308,125. If you calculate with 5 digits the texture coords would be 0.60156 , 0.24414 (308/512 and 125/512) .
If you would use only 1 digit, then the texture coordinates in pixel would be different. A texture coord of 0.6 , 0.2 would be 307,102 in pixel. Surely not something we want. You see, the more digits, the more precise the conversion from pixel to texture coords and vice versa will be.