From f9ccdda5bd8db70562b308dabdaa51ebcddd5d46 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Tue, 13 Jul 2021 10:36:01 -0400 Subject: [PATCH] Multires thumbnail must be a power of two. WebGL 1 doesn't support REPEAT clamp mode for non-power-of-two images, which is needed to avoid some rendering artifacts for small previews. --- utils/multires/generate.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/utils/multires/generate.py b/utils/multires/generate.py index 73d9f10..9c3e2d5 100755 --- a/utils/multires/generate.py +++ b/utils/multires/generate.py @@ -146,7 +146,7 @@ parser.add_argument('-q', '--quality', dest='quality', default=75, type=int, parser.add_argument('--png', action='store_true', help='output PNG tiles instead of JPEG tiles') parser.add_argument('--thumbnailsize', dest='thumbnailSize', default=0, type=int, - help='width of equirectangular thumbnail preview (defaults to no thumbnail; >512 not recommended)') + help='width of equirectangular thumbnail preview (defaults to no thumbnail; must be power of two; >512 not recommended)') parser.add_argument('-n', '--nona', default=nona, required=nona is None, metavar='EXECUTABLE', help='location of the nona executable to use') @@ -157,6 +157,12 @@ parser.add_argument('-d', '--debug', action='store_true', args = parser.parse_args() +# Check argument +if args.thumbnailSize > 0: + if args.thumbnailSize & (args.thumbnailSize - 1) != 0: + print('Thumbnail size, if specified, must be a power of two') + sys.exit(1) + # Create output directory if os.path.exists(args.output): print('Output directory "' + args.output + '" already exists')