Quote:
Originally Posted by shabtronic
u=(float)((Xpixel+(i8&)XCoordinate))/255
v=(float)((Ypixel+(i8&)YCoordinate))/255
it seems they built in the edge correction because of issues with earlier vid cards and all that.
|
Yep, I noticed the unsigned to signed discrepancy too.
But using your formula, wouldn't that make uv edges go from 0 to (254/255)? That means, for u, the max value is a little to the left of the left side of the rightmost pixel.
In the original game engine I noticed that texture coordinates were aligned to pixel centers, so I wonder if it's not more like this:
u=((float)((Xpixel+(i8&)XCoordinate))/255) + (1/512)
Edit: nope, that's not right either. A full tile goes from
Xpixel 0 Xcoord 0
to
Xpixel FF Xcoord FF
Half a tile is
Xpixel 0 Xcoord 0
to
Xpixel 7F Xcoord FF
In fact, it seems that we can throw away Xcoord, like so
u_pixel_center=(Xpixel+0.5)/256
v_pixel_center=(Ypixel+0.5)/256
That way a tile goes from 1/512 to 511/512
and a half tile goes from 1/512 to 255/512
Thoughts?