Permalink
Browse files

Fixed DecompressDxt5Block to properly read the 48-bit alpha code allo…

…wing for correct transparency on DXT compressed Textures.
  • Loading branch information...
1 parent 4289922 commit dcaca6ecac91b5724c31c6208fcd31d084ea8f63 @nfurtwangler nfurtwangler committed Feb 19, 2013
Showing with 8 additions and 5 deletions.
  1. +8 −5 MonoGame.Framework/Graphics/DxtUtil.cs
View
13 MonoGame.Framework/Graphics/DxtUtil.cs
@@ -338,11 +338,14 @@ private static void DecompressDxt5Block(BinaryReader imageReader, int x, int y,
{
byte alpha0 = imageReader.ReadByte();
byte alpha1 = imageReader.ReadByte();
-
- ulong alphaMask = imageReader.ReadUInt32 ();
- alphaMask <<= 16;
- alphaMask += imageReader.ReadUInt16 ();
-
+
+ ulong alphaMask = 0;
+
+ for (int i = 0; i < 6; i++)
+ {
+ alphaMask += ((ulong)imageReader.ReadByte()) << i * 8;
+ }
+
ushort c0 = imageReader.ReadUInt16();
ushort c1 = imageReader.ReadUInt16();

0 comments on commit dcaca6e

Please sign in to comment.