matt77hias / MAGE-v0

🧙 MAGE v0
https://matt77hias.github.io/MAGE-v0-Doc
GNU General Public License v3.0
266 stars 20 forks source link

Half-float texture values #61

Closed matt77hias closed 6 years ago

matt77hias commented 6 years ago

Absolute texture coordinates are in the range [0.0, width] x [0.0, height]. Normalized texture coordinates (i.e. UV) are in the range [0.0, 1.0] x [0.0, 1.0].

The corresponding absolute texture coordinates of a texel are of the form: (x + 0.5, y + 0.5) with x in [0, width - 1] and y in [0, height - 1]. The top-left texel has absolute texture coordinates (0.5, 0.5). The bottom-right texel has absolute texture coordinates (width - 1.0 + 0.5, height - 1.0 + 0.5) = (width - 0.5, height - 0.5).

The corresponding normalized texture coordinates of a texel are of the form: ((x + 0.5) / width, (y + 0.5) / height) with x in [0, width - 1] and y in [0, height - 1]. The top-left texel has absolute texture coordinates (0.5 / width, 0.5 / height). The bottom-right texel has absolute texture coordinates ((width - 1.0 + 0.5) / width, (height - 1.0 + 0.5) / height) = (1.0 - 0.5/width, 1.0 - 0.5/height).

Therefore, normalization factors should be equal to (1/width, 1/height) instead of (1/(width - 0.5), 1/(height - 0.5)) or (1/(width - 1), 1/(height - 1)).