mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-11-22 10:35:16 +01:00
Pack normals into one byte instead of 4 to save space :)
This commit is contained in:
parent
6e68a8f0e0
commit
40119127ee
@ -87,9 +87,9 @@ private void writeNormalArray(TileModel model) throws IOException {
|
||||
writeString("normal");
|
||||
out.write(
|
||||
ATTRIBUTE_TYPE_FLOAT |
|
||||
ATTRIBUTE_NOT_NORMALIZED |
|
||||
ATTRIBUTE_NORMALIZED |
|
||||
ATTRIBUTE_CARDINALITY_3D_VEC |
|
||||
ATTRIBUTE_ENCODING_SIGNED_32BIT_FLOAT
|
||||
ATTRIBUTE_ENCODING_SIGNED_8BIT_INT
|
||||
);
|
||||
|
||||
writePadding();
|
||||
@ -105,9 +105,9 @@ private void writeNormalArray(TileModel model) throws IOException {
|
||||
);
|
||||
|
||||
for (j = 0; j < 3; j++) { // all 3 points
|
||||
writeFloat(normal.x);
|
||||
writeFloat(normal.y);
|
||||
writeFloat(normal.z);
|
||||
writeNormalizedSignedByteValue(normal.x);
|
||||
writeNormalizedSignedByteValue(normal.y);
|
||||
writeNormalizedSignedByteValue(normal.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -283,6 +283,11 @@ private void writeFloat(float value) throws IOException {
|
||||
write4byteValue(Float.floatToIntBits(value));
|
||||
}
|
||||
|
||||
private void writeNormalizedSignedByteValue(float value) throws IOException {
|
||||
byte normalized = (byte) (value * 0x80 - 0.5);
|
||||
out.write(normalized & 0xFF);
|
||||
}
|
||||
|
||||
private void writeNormalizedUnsignedByteValue(float value) throws IOException {
|
||||
int normalized = (int) (value * 0xFF);
|
||||
out.write(normalized & 0xFF);
|
||||
|
Loading…
Reference in New Issue
Block a user