Skip to content

Commit d5af27e

Browse files
committed
Add normal map support
1 parent df31127 commit d5af27e

File tree

2 files changed

+51
-4
lines changed

2 files changed

+51
-4
lines changed

3rdparty/astc/astc_lib.cpp

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ namespace
5252
{
5353
{ 0, 1, 2, 3 }, // ASTC_RGBA
5454
{ 2, 1, 0, 3 }, // ASTC_BGRA
55+
{ 0, 0, 0, 1 }, // ASTC_RA
5556
};
5657

5758
void alloc_temp_buffers(compress_symbolic_block_buffers* temp_buffers)
@@ -273,13 +274,20 @@ namespace
273274
void setup_ewp(ASTC_COMPRESS_MODE mode, int ydim, int xdim, error_weighting_params& ewp)
274275
{
275276
float oplimit_autoset = 0.0;
277+
float oplimit_user_specified = 0.0;
278+
int oplimit_set_by_user = 0;
279+
276280
float dblimit_autoset_2d = 0.0;
277281
float bmc_autoset = 0.0;
278282
float mincorrel_autoset = 0.0;
283+
float mincorrel_user_specified = 0.0;
284+
int mincorrel_set_by_user = 0;
279285

280286
int plimit_autoset = -1;
281287
int maxiters_autoset = 0;
282288
int pcdiv = 1;
289+
int dblimit_set_by_user = 0;
290+
float dblimit_user_specified = 0.0;
283291

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

@@ -453,11 +461,47 @@ namespace
453461
break;
454462
}
455463
}
464+
else if (mode == ASTC_COMPRESS_NORMAL_PSNR)
465+
{
466+
ewp.rgba_weights[0] = 1.0f;
467+
ewp.rgba_weights[1] = 0.0f;
468+
ewp.rgba_weights[2] = 0.0f;
469+
ewp.rgba_weights[3] = 1.0f;
470+
ewp.ra_normal_angular_scale = 1;
471+
oplimit_user_specified = 1000.0f;
472+
oplimit_set_by_user = 1;
473+
mincorrel_user_specified = 0.99f;
474+
mincorrel_set_by_user = 1;
475+
}
476+
else if (mode == ASTC_COMPRESS_NORMAL_PERCEP)
477+
{
478+
ewp.rgba_weights[0] = 1.0f;
479+
ewp.rgba_weights[1] = 0.0f;
480+
ewp.rgba_weights[2] = 0.0f;
481+
ewp.rgba_weights[3] = 1.0f;
482+
ewp.ra_normal_angular_scale = 1;
483+
484+
oplimit_user_specified = 1000.0f;
485+
oplimit_set_by_user = 1;
486+
mincorrel_user_specified = 0.99f;
487+
mincorrel_set_by_user = 1;
488+
489+
dblimit_user_specified = 999;
490+
dblimit_set_by_user = 1;
491+
492+
ewp.block_artifact_suppression = 1.8f;
493+
ewp.mean_stdev_radius = 3;
494+
ewp.rgb_mean_weight = 0;
495+
ewp.rgb_stdev_weight = 50;
496+
ewp.rgb_mean_and_stdev_mixing = 0.0;
497+
ewp.alpha_mean_weight = 0;
498+
ewp.alpha_stdev_weight = 50;
499+
}
456500

457501
int partitions_to_test = plimit_autoset;
458-
float dblimit_2d = dblimit_autoset_2d;
459-
float oplimit = oplimit_autoset;
460-
float mincorrel = mincorrel_autoset;
502+
float dblimit_2d = dblimit_set_by_user ? dblimit_user_specified : dblimit_autoset_2d;
503+
float oplimit = oplimit_set_by_user ? oplimit_user_specified : oplimit_autoset;
504+
float mincorrel = mincorrel_set_by_user ? mincorrel_user_specified : mincorrel_autoset;
461505

462506
int maxiters = maxiters_autoset;
463507
ewp.max_refinement_iters = maxiters;

3rdparty/astc/astc_lib.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ enum ASTC_COMPRESS_MODE // Trade-off compression quality for speed
1919
ASTC_COMPRESS_MEDIUM,
2020
ASTC_COMPRESS_THOROUGH,
2121
ASTC_COMPRESS_EXHAUSTIVE,
22+
ASTC_COMPRESS_NORMAL_PSNR,
23+
ASTC_COMPRESS_NORMAL_PERCEP,
2224
};
2325

2426
enum ASTC_DECODE_MODE
@@ -31,7 +33,8 @@ enum ASTC_DECODE_MODE
3133
enum ASTC_CHANNELS
3234
{
3335
ASTC_RGBA,
34-
ASTC_BGRA
36+
ASTC_BGRA,
37+
ASTC_RA,
3538
};
3639

3740

0 commit comments

Comments
 (0)