Skip to content

Commit

Permalink
Add normal map support
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudwu committed Jul 9, 2019
1 parent df31127 commit d5af27e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 4 deletions.
50 changes: 47 additions & 3 deletions 3rdparty/astc/astc_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ namespace
{
{ 0, 1, 2, 3 }, // ASTC_RGBA
{ 2, 1, 0, 3 }, // ASTC_BGRA
{ 0, 0, 0, 1 }, // ASTC_RA
};

void alloc_temp_buffers(compress_symbolic_block_buffers* temp_buffers)
Expand Down Expand Up @@ -273,13 +274,20 @@ namespace
void setup_ewp(ASTC_COMPRESS_MODE mode, int ydim, int xdim, error_weighting_params& ewp)
{
float oplimit_autoset = 0.0;
float oplimit_user_specified = 0.0;
int oplimit_set_by_user = 0;

float dblimit_autoset_2d = 0.0;
float bmc_autoset = 0.0;
float mincorrel_autoset = 0.0;
float mincorrel_user_specified = 0.0;
int mincorrel_set_by_user = 0;

int plimit_autoset = -1;
int maxiters_autoset = 0;
int pcdiv = 1;
int dblimit_set_by_user = 0;
float dblimit_user_specified = 0.0;

float log10_texels_2d = log((float)(xdim * ydim)) / log(10.0f);

Expand Down Expand Up @@ -453,11 +461,47 @@ namespace
break;
}
}
else if (mode == ASTC_COMPRESS_NORMAL_PSNR)
{
ewp.rgba_weights[0] = 1.0f;
ewp.rgba_weights[1] = 0.0f;
ewp.rgba_weights[2] = 0.0f;
ewp.rgba_weights[3] = 1.0f;
ewp.ra_normal_angular_scale = 1;
oplimit_user_specified = 1000.0f;
oplimit_set_by_user = 1;
mincorrel_user_specified = 0.99f;
mincorrel_set_by_user = 1;
}
else if (mode == ASTC_COMPRESS_NORMAL_PERCEP)
{
ewp.rgba_weights[0] = 1.0f;
ewp.rgba_weights[1] = 0.0f;
ewp.rgba_weights[2] = 0.0f;
ewp.rgba_weights[3] = 1.0f;
ewp.ra_normal_angular_scale = 1;

oplimit_user_specified = 1000.0f;
oplimit_set_by_user = 1;
mincorrel_user_specified = 0.99f;
mincorrel_set_by_user = 1;

dblimit_user_specified = 999;
dblimit_set_by_user = 1;

ewp.block_artifact_suppression = 1.8f;
ewp.mean_stdev_radius = 3;
ewp.rgb_mean_weight = 0;
ewp.rgb_stdev_weight = 50;
ewp.rgb_mean_and_stdev_mixing = 0.0;
ewp.alpha_mean_weight = 0;
ewp.alpha_stdev_weight = 50;
}

int partitions_to_test = plimit_autoset;
float dblimit_2d = dblimit_autoset_2d;
float oplimit = oplimit_autoset;
float mincorrel = mincorrel_autoset;
float dblimit_2d = dblimit_set_by_user ? dblimit_user_specified : dblimit_autoset_2d;
float oplimit = oplimit_set_by_user ? oplimit_user_specified : oplimit_autoset;
float mincorrel = mincorrel_set_by_user ? mincorrel_user_specified : mincorrel_autoset;

int maxiters = maxiters_autoset;
ewp.max_refinement_iters = maxiters;
Expand Down
5 changes: 4 additions & 1 deletion 3rdparty/astc/astc_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ enum ASTC_COMPRESS_MODE // Trade-off compression quality for speed
ASTC_COMPRESS_MEDIUM,
ASTC_COMPRESS_THOROUGH,
ASTC_COMPRESS_EXHAUSTIVE,
ASTC_COMPRESS_NORMAL_PSNR,
ASTC_COMPRESS_NORMAL_PERCEP,
};

enum ASTC_DECODE_MODE
Expand All @@ -31,7 +33,8 @@ enum ASTC_DECODE_MODE
enum ASTC_CHANNELS
{
ASTC_RGBA,
ASTC_BGRA
ASTC_BGRA,
ASTC_RA,
};


Expand Down

0 comments on commit d5af27e

Please sign in to comment.