fix minimaps blp export
-default blp settings to blizzlike -update dxt compression lib
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* libtxc_dxtn
|
||||
* Version: 0.1
|
||||
* Version: 1.0
|
||||
*
|
||||
* Copyright (C) 2004 Roland Scheidegger All Rights Reserved.
|
||||
*
|
||||
@@ -255,7 +255,7 @@ static void storedxtencodedblock( GLubyte *blkaddr, GLubyte srccolors[4][4][4],
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < 3; i ++) {
|
||||
for (i = 0; i < 3; i++) {
|
||||
cv[0][i] = bestcolor[0][i];
|
||||
cv[1][i] = bestcolor[1][i];
|
||||
cv[2][i] = (bestcolor[0][i] * 2 + bestcolor[1][i]) / 3;
|
||||
@@ -282,7 +282,10 @@ static void storedxtencodedblock( GLubyte *blkaddr, GLubyte srccolors[4][4][4],
|
||||
bits |= enc << (2 * (j * 4 + i));
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 3; i ++) {
|
||||
/* some hw might disagree but actually decoding should always use 4-color encoding
|
||||
for non-dxt1 formats */
|
||||
if (type == GL_COMPRESSED_RGB_S3TC_DXT1_EXT || type == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) {
|
||||
for (i = 0; i < 3; i++) {
|
||||
cv[2][i] = (bestcolor[0][i] + bestcolor[1][i]) / 2;
|
||||
/* this isn't used. Looks like the black color constant can only be used
|
||||
with RGB_DXT1 if I read the spec correctly (note though that the radeon gpu disagrees,
|
||||
@@ -319,7 +322,9 @@ static void storedxtencodedblock( GLubyte *blkaddr, GLubyte srccolors[4][4][4],
|
||||
bits2 |= enc << (2 * (j * 4 + i));
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
testerror2 = 0xffffffff;
|
||||
}
|
||||
|
||||
/* finally we're finished, write back colors and bits */
|
||||
if ((testerror > testerror2) || (haveAlpha)) {
|
||||
@@ -368,7 +373,7 @@ static void encodedxtcolorblockfaster( GLubyte *blkaddr, GLubyte srccolors[4][4]
|
||||
for (j = 0; j < numypixels; j++) {
|
||||
for (i = 0; i < numxpixels; i++) {
|
||||
/* don't use this as a base color if the pixel will get black/transparent anyway */
|
||||
if ((type != GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) || (srccolors[j][i][3] <= ALPHACUT)) {
|
||||
if ((type != GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) || (srccolors[j][i][3] > ALPHACUT)) {
|
||||
testcv = srccolors[j][i][0] * srccolors[j][i][0] * REDWEIGHT +
|
||||
srccolors[j][i][1] * srccolors[j][i][1] * GREENWEIGHT +
|
||||
srccolors[j][i][2] * srccolors[j][i][2] * BLUEWEIGHT;
|
||||
@@ -835,3 +840,4 @@ void tx_compress_dxtn(GLint srccomps, GLint width, GLint height, const GLubyte *
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
25
src/external/PNG2BLP/libtxc_dxtn/txc_dxtn.h
vendored
25
src/external/PNG2BLP/libtxc_dxtn/txc_dxtn.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* libtxc_dxtn
|
||||
* Version: 0.1
|
||||
* Version: 1.0
|
||||
*
|
||||
* Copyright (C) 2004 Roland Scheidegger All Rights Reserved.
|
||||
*
|
||||
@@ -22,31 +22,18 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#ifndef _TXC_DXTN_H
|
||||
#define _TXC_DXTN_H
|
||||
|
||||
typedef uint8_t GLchan;
|
||||
typedef int32_t GLint;
|
||||
typedef uint8_t GLubyte;
|
||||
typedef void GLvoid;
|
||||
typedef uint32_t GLenum;
|
||||
typedef uint8_t GLboolean;
|
||||
typedef uint32_t GLuint;
|
||||
typedef uint16_t GLushort;
|
||||
typedef int16_t GLshort;
|
||||
#include <GL/gl.h>
|
||||
|
||||
typedef GLubyte GLchan;
|
||||
#define UBYTE_TO_CHAN(b) (b)
|
||||
#define CHAN_MAX 255
|
||||
#define RCOMP 0
|
||||
#define GCOMP 1
|
||||
#define BCOMP 2
|
||||
#define ACOMP 3
|
||||
#define GL_FALSE 0
|
||||
#define GL_TRUE 1
|
||||
|
||||
#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0
|
||||
#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 1
|
||||
#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 2
|
||||
#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 3
|
||||
|
||||
void fetch_2d_texel_rgb_dxt1(GLint srcRowStride, const GLubyte *pixdata,
|
||||
GLint i, GLint j, GLvoid *texel);
|
||||
@@ -60,3 +47,5 @@ void fetch_2d_texel_rgba_dxt5(GLint srcRowStride, const GLubyte *pixdata,
|
||||
void tx_compress_dxtn(GLint srccomps, GLint width, GLint height,
|
||||
const GLubyte *srcPixData, GLenum destformat,
|
||||
GLubyte *dest, GLint dstRowStride);
|
||||
|
||||
#endif /* _TXC_DXTN_H */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* libtxc_dxtn
|
||||
* Version: 0.1
|
||||
* Version: 1.0
|
||||
*
|
||||
* Copyright (C) 2004 Roland Scheidegger All Rights Reserved.
|
||||
*
|
||||
@@ -63,7 +63,7 @@ static void dxt135_decode_imageblock ( const GLubyte *img_block_src,
|
||||
rgba[BCOMP] = UBYTE_TO_CHAN( EXP5TO8B(color1) );
|
||||
break;
|
||||
case 2:
|
||||
if (color0 > color1) {
|
||||
if ((dxt_type > 1) || (color0 > color1)) {
|
||||
rgba[RCOMP] = UBYTE_TO_CHAN( ((EXP5TO8R(color0) * 2 + EXP5TO8R(color1)) / 3) );
|
||||
rgba[GCOMP] = UBYTE_TO_CHAN( ((EXP6TO8G(color0) * 2 + EXP6TO8G(color1)) / 3) );
|
||||
rgba[BCOMP] = UBYTE_TO_CHAN( ((EXP5TO8B(color0) * 2 + EXP5TO8B(color1)) / 3) );
|
||||
|
||||
@@ -1734,7 +1734,9 @@ bool WorldRender::saveMinimap(TileIndex const& tile_idx, MinimapRenderSettings*
|
||||
blp.load(reinterpret_cast<const void*>(bytes.constData()), bytes.size());
|
||||
|
||||
uint32_t file_size;
|
||||
void* blp_image = blp.createBlpDxtInMemory(true, FORMAT_DXT5, file_size);
|
||||
// void* blp_image = blp.createBlpDxtInMemory(true, FORMAT_DXT5, file_size);
|
||||
// this mirrors blizzards : dxt1, no mipmap
|
||||
void* blp_image = blp.createBlpDxtInMemory(false, FORMAT_DXT1, file_size);
|
||||
|
||||
// converts the texture name to an md5 hash like blizzard, this is used to avoid duplicates textures for ocean
|
||||
// downside is that if the file gets updated regularly there will be a lot of duplicates in the project folder
|
||||
|
||||
Reference in New Issue
Block a user