Browse Source

read/write BC1 & BC3 on DDS

clandrin 3 năm trước cách đây
mục cha
commit
e175b70fc9
2 tập tin đã thay đổi với 14 bổ sung1 xóa
  1. 8 1
      hxd/Pixels.hx
  2. 6 0
      hxd/res/Image.hx

+ 8 - 1
hxd/Pixels.hx

@@ -625,7 +625,7 @@ class Pixels {
 		var levels : Array<Array<Pixels>> = [];
 		var outSize = 0;
 		for( p in pixels ) {
-			if( p.format != fmt ) throw "All images must be of the same pixel format";
+			if( !p.format.equals(fmt) ) throw "All images must be of the same pixel format";
 			outSize += p.dataSize;
 			var found = false;
 			for( sz in levels ) {
@@ -722,6 +722,13 @@ class Pixels {
 			switch( fmt ) {
 			case RGBA:
 				write(28); // DXGI_FORMAT_R8G8B8A8_UNORM
+			case S3TC(n):
+				write(switch( n ) {
+				case 1: 71;
+				case 2: 74;
+				case 3: 77;
+				default: throw "Unnsupported format "+fmt;
+				});
 			default:
 				throw "Unsupported DXT10 format "+fmt;
 			}

+ 6 - 0
hxd/res/Image.hx

@@ -178,6 +178,12 @@ class Image extends Resource {
 				inf.pixelFormat = switch( dxgi ) {
 				case 28:
 					RGBA;
+				case 71: // BC1_UNORM
+					S3TC(1);
+				case 74: // BC2_UNORM
+					S3TC(2);
+				case 77: // BC3_UNORM
+					S3TC(3);
 				case 95: // BC6H_UF16
 					S3TC(6);
 				case 98: // BC7_UNORM