diff --git a/bin/crunch_x64.exe b/bin/crunch_x64.exe index e1869b0..abc556f 100644 Binary files a/bin/crunch_x64.exe and b/bin/crunch_x64.exe differ diff --git a/crnlib/crn_dxt_hc.cpp b/crnlib/crn_dxt_hc.cpp index 431e5cb..a22d051 100644 --- a/crnlib/crn_dxt_hc.cpp +++ b/crnlib/crn_dxt_hc.cpp @@ -210,15 +210,17 @@ bool dxt_hc::compress( for (uint bx = 0; bx < block_width; bx++, b++) { bool top_match = by != 0; bool left_match = top_match || bx; + bool diag_match = m_params.m_format == cETC1 && top_match && bx; for (uint c = m_has_color_blocks ? 0 : cAlpha0; c < cAlpha0 + m_num_alpha_blocks; c++) { uint16 endpoint_index = (c ? alpha_endpoints_remap : color_endpoints_remap)[m_endpoint_indices[b].component[c]]; left_match = left_match && endpoint_index == endpoint_indices[b - 1].component[c]; top_match = top_match && endpoint_index == endpoint_indices[b - block_width].component[c]; + diag_match = diag_match && endpoint_index == endpoint_indices[b - block_width - 1].component[c]; endpoint_indices[b].component[c] = endpoint_index; uint16 selector_index = (c ? alpha_selectors_remap : color_selectors_remap)[m_selector_indices[b].component[c]]; selector_indices[b].component[c] = selector_index; } - endpoint_indices[b].reference = m_params.m_format == cETC1 && (b & 1) ? m_endpoint_indices[b].reference : left_match ? 1 : top_match ? 2 : 0; + endpoint_indices[b].reference = m_params.m_format == cETC1 && (b & 1) ? m_endpoint_indices[b].reference : left_match ? 1 : top_match ? 2 : diag_match ? 3 : 0; } } } diff --git a/inc/crn_decomp.h b/inc/crn_decomp.h index 434b0ec..9b78c69 100644 --- a/inc/crn_decomp.h +++ b/inc/crn_decomp.h @@ -3550,10 +3550,10 @@ class crn_unpacker { const uint32 height = output_height + 1 & ~1; const int32 delta_pitch_in_dwords = (output_pitch_in_bytes >> 2) - (width << 1); - if (m_block_buffer.size() < width) - m_block_buffer.resize(width); + if (m_block_buffer.size() < width << 1) + m_block_buffer.resize(width << 1); - uint32 color_endpoint_index = 0; + uint32 color_endpoint_index = 0, diagonal_color_endpoint_index = 0; uint8 reference_group = 0; for (uint32 f = 0; f < m_pHeader->m_faces; f++) { @@ -3562,7 +3562,7 @@ class crn_unpacker { bool visible = y < output_height; for (uint32 x = 0; x < width; x++, pData += 2) { visible = visible && x < output_width; - block_buffer_element &buffer = m_block_buffer[x]; + block_buffer_element &buffer = m_block_buffer[x << 1]; uint8 endpoint_reference, block_endpoint[4], e0[4], e1[4]; if (y & 1) { endpoint_reference = buffer.endpoint_reference; @@ -3578,6 +3578,8 @@ class crn_unpacker { buffer.color_endpoint_index = color_endpoint_index; } else if ((endpoint_reference & 3) == 1) { buffer.color_endpoint_index = color_endpoint_index; + } else if ((endpoint_reference & 3) == 3) { + buffer.color_endpoint_index = color_endpoint_index = diagonal_color_endpoint_index; } else { color_endpoint_index = buffer.color_endpoint_index; } @@ -3589,6 +3591,8 @@ class crn_unpacker { if (color_endpoint_index >= num_color_endpoints) color_endpoint_index -= num_color_endpoints; } + diagonal_color_endpoint_index = m_block_buffer[x << 1 | 1].color_endpoint_index; + m_block_buffer[x << 1 | 1].color_endpoint_index = color_endpoint_index; *(uint32*)&e1 = m_color_endpoints[color_endpoint_index]; if (visible) { uint32 block_selector = 0, flip = endpoint_reference >> 1 ^ 1, diff = 1;