High-resolution skin support
deathcap opened this issue · 2 comments
Support skins with higher resolutions (multiples of 64x32).
Turns out they already work. avatar.js specifies UV coords as a fraction of 64x32, and box-geometry.js divides by 64 or 32:
var tw = 64, th = 32
var setCubeFaceUV = function(face,x,y,w,h,r) {
w = w || 8
h = h || 8
r = r || 0
var i = face * 8
uvArray[i + (0 + r) % 4 * 2 + 0] = x / tw
uvArray[i + (0 + r) % 4 * 2 + 1] = (y + h) / th
uvArray[i + (1 + r) % 4 * 2 + 0] = x / tw
uvArray[i + (1 + r) % 4 * 2 + 1] = y / th
uvArray[i + (2 + r) % 4 * 2 + 0] = (x + w) / tw
uvArray[i + (2 + r) % 4 * 2 + 1] = y / th
uvArray[i + (3 + r) % 4 * 2 + 0] = (x + w) / tw
uvArray[i + (3 + r) % 4 * 2 + 1] = (y + h) / th
}
making the UVs resolution-independent (as UV coordinates are by definition, 0.0 to 1.0). For testing, original 64x32 substack.png:
and 2x, 128x64 substack2.png, identical:
Another 128x64 test (which I call 'substack3.png'), not merely scaled up (although using https://github.com/deathcap/ndarray-upsample-epx to upsample could be interesting, used nearest-neighbor) but with added outline to prove high-resolution is working:
Closing, but just need to be sure to not break this functionality in the future. (But for what its worth, according to http://www.minecraftforum.net/topic/1048100-64x64-skin/ MC only supports high-res skins in texture packs, not online from the skin server – still, nice to support this extra feature anyways).