-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Encode dds as ARGB instead of ABGR #423
base: develop
Are you sure you want to change the base?
Conversation
Actually I'm not sure if the encoding is now ARGB or BGRA, but it doesn't really matter. I tested that the map editor now correctly reads the texture and other software can still read it without problems. |
What are other maps encoded as? I thought the map gen did it in the same way other maps do |
private static byte[] getRawDDSImageBytes(int size, ByteBuffer imageByteBuffer) { | ||
DDSHeader ddsHeader = new DDSHeader(); | ||
ddsHeader.setWidth(size); | ||
ddsHeader.setHeight(size); | ||
ddsHeader.setRGBBitCount(32); | ||
ddsHeader.setRBitMask(0x000000FF); | ||
ddsHeader.setGBitMask(0x0000FF00); | ||
ddsHeader.setBBitMask(0x00FF0000); | ||
ddsHeader.setABitMask(0xFF000000); | ||
ddsHeader.toBytes(); | ||
byte[] headerBytes = ddsHeader.toBytes(); | ||
byte[] imageBytes = imageByteBuffer.array(); | ||
int headerLength = headerBytes.length; | ||
int imageLength = size * size * 4; | ||
byte[] allBytes = Arrays.copyOf(headerBytes, headerLength + imageLength); | ||
System.arraycopy(imageBytes, 0, allBytes, headerLength, imageLength); | ||
return allBytes; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this method deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was unused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that this also uses ABGR order. So instead of thinking a lot about if I need to change the byte order there as well I deleted it. Without the method being used I can't really decide which order is appropriate and I didn't want anyone to use it in the future, expecting it to behave similar to writeRawDDS
what do you mean? This is just about the mapwide texture that the map generator produces. Most maps don't have this texture at all |
That upper image should be correct. The sunset biome uses a different shader and in the current release the map editor can't yet display maps correctly that use this shader. You can go to the textures tab and confirm how the texture looks without the lighting applied. |
Ah didn't realize this was just the map wide |
ABGR is a pretty unusual format. Most software can deal with this just fine, but our unity map editor can't deal with it and reads it as ARGB which causes problems.
Instead of trying to fix the map editor, which would be complicated because unity doesn't even know the ABGR format, we can just output a more standard format here.