akb825 / cuttlefish Goto Github PK
View Code? Open in Web Editor NEWTexture compression library and tool.
License: Apache License 2.0
Texture compression library and tool.
License: Apache License 2.0
There seems to be a color issue on the BC1 output. The red and yellows turn green and black. All encoded textures except the BC1 thumbnails look correct on macOS - so ASTC, BC7, ETC2. I don't think this is 565 vs. 888 issue either. I know BC1 only has the two endpoints and selectors for 2 other values, so maybe BC7 is just that much better at fitting the 4 colors in the 4x4 block.
Here's a snapshot of the thumbnails in macOS
The commands to generate BC1 vs BC7 for the png.
cuttlefish -f BC1_RGB --srgb -Q high -i AttribSimple.png -o AttribSimpleBC1s.ktx --alpha none
cuttlefish -f BC7 --srgb -Q high -i AttribSimple.png -o AttribSimpleBC7s.ktx --alpha none
I ended up adding a "--resize 8 8 box" to provide a 4x4 BC1 blocks for each corner.
68/83 Test #68: CuttlefishMipmapFilter ...............***Failed 0.01 sec
error: couldn't load image 'texture.png'
got exit code 2; expected 0
exit: Illegal number: -1
Start 69: CuttlefishMipmapLevelsFilter
69/83 Test #69: CuttlefishMipmapLevelsFilter .........***Failed 0.01 sec
error: couldn't load image 'texture.png'
got exit code 2; expected 0
exit: Illegal number: -1
Start 70: CuttlefishNormalimap
70/83 Test #70: CuttlefishNormalimap .................***Failed 0.01 sec
error: couldn't load image 'texture.png'
got exit code 2; expected 0
exit: Illegal number: -1
Version: 2.7.1
clang-14
FreeBSD 13.1
Currently it seems impossible to actually create certain types of DDS textures. Uncompressed format "A8B8G8R8" will always fail because of the error message in the title of this issue. It doesn't matter what is selected as the type: unorm, snorm, uint, int, ufloat, or float. The tool itself will also always try to use the default "unorm" type if the "--type" command is omitted completely, so the error message is always present.
Figured I'd also provide a bit more context. I am on Windows 11, using the x64 version of cuttlefish.exe. The command I am attempting can be the most basic possible using only (--input in.png --format A8B8G8R8 --output out.dds) and the error message above will still be triggered.
Edit: Ok this issue may be invalid, maybe I'm misunderstanding the type. I got A8B8G8R8 mixed up with B8G8R8A8 (the latter is what I was actually trying to make) and it works. Also, R8G8B8A8 also works. So it is just A8B8G8R8 this is giving the error message. Maybe I'm not understanding how to use that format.
63/84 Test #63: CuttlefishResizeCatmullRom ...........***Failed 0.01 sec
error: couldn't load image 'texture.png'
got exit code 2; expected 0
exit: Illegal number: -1
Start 64: CuttlefishResizePO2
64/84 Test #64: CuttlefishResizePO2 ..................***Failed 0.01 sec
error: couldn't load image 'texture.png'
got exit code 2; expected 0
exit: Illegal number: -1
Start 65: CuttlefishResizeInvalidX
65/84 Test #65: CuttlefishResizeInvalidX ............. Passed 0.01 sec
Start 66: CuttlefishResizeInvalidY
66/84 Test #66: CuttlefishResizeInvalidY ............. Passed 0.01 sec
Start 67: CuttlefishMipmap
67/84 Test #67: CuttlefishMipmap .....................***Failed 0.01 sec
error: couldn't load image 'texture.png'
got exit code 2; expected 0
exit: Illegal number: -1
Start 68: CuttlefishMipmapLevels
68/84 Test #68: CuttlefishMipmapLevels ...............***Failed 0.01 sec
error: couldn't load image 'texture.png'
got exit code 2; expected 0
exit: Illegal number: -1
Version: 2.7.1
clang-14
FreeBSD 13.1
/bin/ln -s /usr/ports/misc/cuttlefish/work/Cuttlefish-2.7.2/tool/test/texture.png /usr/ports/misc/cuttlefish/work/.build/ || true
ln: /usr/ports/misc/cuttlefish/work/.build//texture.png: File exists
GTest not installed. Skipping tests.
PVRTexLib not found.
-- Configuring done (0.1s)
-- Generating done (0.0s)
-- Build files have been written to: /usr/ports/misc/cuttlefish/work/.build
ninja: no work to do.
[ 0% 1/1] cd /usr/ports/misc/cuttlefish/work/.build && /usr/local/bin/ctest --force-new-ctest-process
Test project /usr/ports/misc/cuttlefish/work/.build
Start 1: CuttlefishNoArgs
1/83 Test #1: CuttlefishNoArgs ..................... Passed 0.01 sec
Start 2: CuttlefishHelp
2/83 Test #2: CuttlefishHelp ....................... Passed 0.01 sec
Start 3: CuttlefishSaveDds
3/83 Test #3: CuttlefishSaveDds ....................***Failed 0.01 sec
error: couldn't load image 'texture.png'
got exit code 2; expected 0
exit: Illegal number: -1
Start 4: CuttlefishSaveKtx
4/83 Test #4: CuttlefishSaveKtx ....................***Failed 0.01 sec
error: couldn't load image 'texture.png'
got exit code 2; expected 0
exit: Illegal number: -1
Start 5: CuttlefishSavePvr
5/83 Test #5: CuttlefishSavePvr ....................***Failed 0.01 sec
error: couldn't load image 'texture.png'
got exit code 2; expected 0
exit: Illegal number: -1
Start 6: CuttlefishSaveUnknownFileType
6/83 Test #6: CuttlefishSaveUnknownFileType ........ Passed 0.01 sec
Start 7: CuttlefishSaveMissingFileTypeParam
7/83 Test #7: CuttlefishSaveMissingFileTypeParam ... Passed 0.01 sec
Start 8: CuttlefishMissingOutput
8/83 Test #8: CuttlefishMissingOutput .............. Passed 0.01 sec
Start 9: CuttlefishMultipleOutput
9/83 Test #9: CuttlefishMultipleOutput ............. Passed 0.01 sec
Start 10: CuttlefishSaveBC3
10/83 Test #10: CuttlefishSaveBC3 ....................***Failed 0.01 sec
error: couldn't load image 'texture.png'
got exit code 2; expected 0
exit: Illegal number: -1
The project is built out-source, in /usr/ports/misc/cuttlefish/work/.build
There is a symbolic link that the port creates there for 'texture.png' but this error occurs any way.
System call log also contains this error:
46879 ctest GIO fd 3 wrote 212 bytes
"Command: "/usr/ports/misc/cuttlefish/work/Cuttlefish-2.7.2/tool/test/run-test.sh" "/usr/ports/misc/cuttlefish/work/.build/output/cuttlefish" "-i texture.png -f R8G8B8A8 -s rgb -o /dev/null --file-format pvr" "1"
"
46879 ctest RET write 212/0xd4
46879 ctest CALL write(0x3,0x82f60e840,0x46)
46879 ctest GIO fd 3 wrote 70 bytes
"Directory: /usr/ports/misc/cuttlefish/work/Cuttlefish-2.7.2/tool/test
"
46879 ctest RET write 70/0x46
46879 ctest CALL write(0x3,0x82f60e840,0x3e)
46879 ctest GIO fd 3 wrote 62 bytes
""CuttlefishSwizzleInvalidNumber" start time: May 31 08:24 PDT
"
46879 ctest RET write 62/0x3e
46879 ctest CALL write(0x3,0x82f60e840,0x8)
46879 ctest GIO fd 3 wrote 8 bytes
"Output:
"
46879 ctest RET write 8
46879 ctest CALL write(0x3,0x82f60e840,0x3b)
46879 ctest GIO fd 3 wrote 59 bytes
"----------------------------------------------------------
"
46879 ctest RET write 59/0x3b
46879 ctest CALL write(0x3,0x82f60e840,0x2467)
46879 ctest GIO fd 3 wrote 4096 bytes
"error: swizzle must contain 4 elements of r, g, b, a, or x
Usage: cuttlefish [options]
General options:
-h, --help display this help message
-j, --jobs [n] the number of jobs to convert with; if n is omitted, use all
available cores
-q, --quiet suppress all non-error output
-v, --verbose verbose output
Input files: at least one required, cannot mix different types
-i, --input file the input image for a standard texture
-a, --array [n] file the input image for an array or 3D texture:
n: the index of the image
file: the path to the image
-c, --cube face file the input image for a cube map:
face: the face, which is one of:
+x, -x, +y, -y, +z, -z
file: the path to the image
-C, --cube-array n face file the input image for a cube map:
n: the index of the image
face: the face, which is one of:
+x, -x, +y, -y, +z, -z
file: the path to the image
-I, --input-list type file specify a file with a list of image paths:
type: type of texture, which is one of the
following: image, array, cube, cube-array;
cube faces are in the order:
+x, -x, +y, -y, +z, -z
file: path to a file containing a list of
Version: 2.7.2
FreeBSD 13.2
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/FreeImage/Source/FreeImage/PluginPSD.cpp:130:10: error: cannot initialize return object of type 'BOOL' (aka 'int') with an rvalue of type 'nullptr_t'
return NULL;
^~~~
/usr/include/sys/_null.h:37:14: note: expanded from macro 'NULL'
#define NULL nullptr
^~~~~~~
1 error generated.
clang-13.1
I've been trying to swizzle some textures with the following command on macOS, but the channel ordering doesn't look correct. I looked over the swizzle sources, and it makes sense, so maybe the jpeg/png code is loading in images as rbga instead of rgba. I wasn't able to debug from the Xcode project, but I'll work on trying to correct it.
This works to get the g and a channels populated with data, but I'm setting ba = gr (confirmed data in PVRTexToolGUI)
cuttlefish --swizzle xxgr -f ASTC_4x4 --srgb -i Image.jpeg -o Image.ktx
cuttlefish --swizzle xxgr -f ASTC_4x4 --srgb -i Image.png -o Image.ktx
Was expecting to use, ga = gr
cuttlefish --swizzle xgxr -f ASTC_4x4 --srgb -i Image.jpeg -o Image.ktx
cuttlefish --swizzle xgxr -f ASTC_4x4 --srgb -i Image.png -o Image.ktx
This should be a noop, but the channels are reordered.
cuttlefish --swizzle rgba -f ASTC_4x4 --srgb -i Image.png -o Image.ktx
Channel info from first swizzle on a Image.jpeg.
This is an issue with choice to use NVTT, but perhaps a better/faster replacement for BC7 (and I assume BC6H) are needed.
Hi,
I have the following image without any alpha (fully white) which I wanted to convert into BC1_RGB. However when I do so I end-up with blocky artifacts in the Alpha channel/component of the texture. Using BC1_RGBA solves the issue. I'm not sure if that's the intended behavior, I would have expected something fully white or black, and not an hybrid.
(I'm checking out my files in RenderDoc.)
DDS image is produced with the following command:
cuttlefish --input "train_debug_RGB.png" --file-format dds --mipmap --format BC1_RGB --output "train_debug_RGB.dds"
When I check the alpha of the DDS file in RenderDoc this is what I see:
As I far I can see, my PNG file doesn't any alpha/transparency (other than fully white, so I'm considering it's opaque). So I don't understand why some blocks would end-up being 0 and not 255. I also noticed the issue on older versions as well, so it doesn't seem to be a regression.
Technical details:
===> Configuring for cuttlefish-texture-compressor-2.6.0
===> Performing out-of-source build
/bin/mkdir -p /disk-samsung/freebsd-ports/misc/cuttlefish/work/.build
-- The C compiler identification is Clang 13.0.0
-- The CXX compiler identification is Clang 13.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Found Threads: TRUE
-- Looking for FreeImage
FreeImage not found
PVRTexLib not found
-- Configuring done
-- Generating done
FreeBSD 13.1
Many tools that process textures often have subfolders that need to be created. I noted that cuttlefish was failing to write on these cases when I'd wipe the parent directory. It would be useful to have cuttlefish build subdirectories if they don't exist when providing an output path to simplify scripting and repeatability of texture processing.
I was trying cuttlefish after switching off PVRTexToolCLI, and this was one notable difference and breakage in the texture processing between these utilities.
This is the basic source to create the full path of directories and then open a file. This could be split out into a mkdir call, and the fopen call could just proceed normally then. Current behavior is a rather cryptic failure to write message,, so so I thought the encoder was failing.
// https://stackoverflow.com/questions/7430248/creating-a-new-directory-in-c
void rek_mkdir(char *path) {
char *sep = strrchr(path, '/');
if(sep != NULL) {
*sep = 0;
rek_mkdir(path);
*sep = '/';
}
if(mkdir(path, 0777) && errno != EEXIST)
printf("error while trying to create '%s'\n%m\n", path);
}
FILE *fopen_mkdir(char *path, char *mode) {
char *sep = strrchr(path, '/');
if(sep) {
char *path0 = strdup(path);
path0[ sep - path ] = 0;
rek_mkdir(path0);
free(path0);
}
return fopen(path,mode);
}
PVRTexTool has a --square argument for resizing since PVRTC must be square pow2 textures. Since Cuttlefish supports PVRTC, this would save scripts from having to compute the max(pow2(width), pow2(height)) to pass down for the resize option. I can do this in the shell/python scripts that I have for now.
--resize squarepo2 squarepo2 cubic
I honestly have no idea what is going on. I am using the latest windows binary with commands:
./cuttlefish.exe -i INPUT.tga -j -m -f BC7 -Q highest -v -o OUTPUT.dds
Here are the files if you want to take a look.
bin.zip
โฏ git pull --recurse-submodules
Fetching submodule lib/FreeImage
Fetching submodule lib/ISPCTextureCompressor
Fetching submodule lib/PVRTexToolLib
Fetching submodule lib/astc-encoder
Fetching submodule lib/astc-encoder/Source/GoogleTest
Fetching submodule lib/bc7enc_rdo
Fetching submodule lib/compressonator
Fetching submodule lib/etc2comp
Fetching submodule lib/glm
Fetching submodule lib/libsquish
Already up to date.
fatal: remote error: upload-pack: not our ref a9087786ced42a1a4ee137c1ad5bf197dd2d6b72
fatal: Fetched in submodule path 'lib/libsquish', but it did not contain a9087786ced42a1a4ee137c1ad5bf197dd2d6b72. Direct fetching of that commit failed.
a9087786ced42a1a4ee137c1ad5bf197dd2d6b72
is missing. It looks like libsquish over on github has no history. Only 5 commits.
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [lib/CMakeFiles/cuttlefish_lib.dir/libsquish/squish.cpp.o] Error 1
make[1]: *** [lib/CMakeFiles/cuttlefish_lib.dir/all] Error 2
make: *** [all] Error 2
Fails while building.
As title. With an attached image of WxH 256x1024 pixels, the returned value from Texture::maxMipmapLevels is 11, however any mipmap levels after 9 has a width of 0. This causes Texture::generateMipmaps to generate mipmaps that have an area of 0 and report that 11 mipmaps were created via Texture::mipLevelCount.
A workaround for this is to call Texture::maxMipLevels with the minimum of the width and height of the image, then pass that into Texture::generateMipmaps, but a better solution would seem to be to patch Texture::maxMipmapLevels to return the minimum of levelCount{Width,Height,Depth} instead of the maximum.
In file included from /disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/bc6_encode_kernel.cpp:23:
In file included from /disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/bc6_encode_kernel.h:28:
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/common_def.h:450:9: error: unknown type name 'CMP_Vec3ui'
typedef CMP_Vec3ui CGU_Vec3ui;
^
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/common_def.h:451:9: error: unknown type name 'CMP_Vec3ui'
typedef CMP_Vec3ui CGV_Vec3ui;
^
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/common_def.h:453:9: error: unknown type name 'CMP_Vec2f'
typedef CMP_Vec2f CGU_Vec2f;
^
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/common_def.h:454:9: error: unknown type name 'CMP_Vec3f'
typedef CMP_Vec3f CGU_Vec3f;
^
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/common_def.h:456:9: error: unknown type name 'CMP_Vec4uc'
typedef CMP_Vec4uc CGU_Vec4uc;
^
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/common_def.h:457:9: error: unknown type name 'CMP_Vec4uc'
typedef CMP_Vec4uc CGV_Vec4uc;
^
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/common_def.h:458:9: error: unknown type name 'CMP_Vec4i'
typedef CMP_Vec4i CGU_Vec4i;
^
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/common_def.h:459:9: error: unknown type name 'CMP_Vec4ui'
typedef CMP_Vec4ui CGU_Vec4ui;
^
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/common_def.h:460:9: error: unknown type name 'CMP_Vec4ui'
typedef CMP_Vec4ui CGV_Vec4ui;
^
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/common_def.h:461:9: error: unknown type name 'CMP_Vec4f'
typedef CMP_Vec4f CGU_Vec4f;
^
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/common_def.h:462:9: error: unknown type name 'CMP_Vec4f'
typedef CMP_Vec4f CGV_Vec4f;
^
In file included from /disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/bc6_encode_kernel.cpp:35:
In file included from /disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/bc6_common_encoder.h:30:
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/bcn_common_api.h:49:12: error: use of undeclared identifier 'fabs'
return fabs(x);
^
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/bcn_common_api.h:61:17: error: use of undeclared identifier 'fabs'
return (pow(fabs(Color), 1.0f / 2.4f) * 1.055f - 0.055f);
^
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/bcn_common_api.h:66:10: error: member reference base type 'CGU_Vec3f' (aka 'int') is not a structure or union
Color.x = cmp_linearToSrgbf(Color.x);
~~~~~^~
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/bcn_common_api.h:66:38: error: member reference base type 'CGU_Vec3f' (aka 'int') is not a structure or union
Color.x = cmp_linearToSrgbf(Color.x);
~~~~~^~
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/bcn_common_api.h:67:10: error: member reference base type 'CGU_Vec3f' (aka 'int') is not a structure or union
Color.y = cmp_linearToSrgbf(Color.y);
~~~~~^~
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/bcn_common_api.h:67:38: error: member reference base type 'CGU_Vec3f' (aka 'int') is not a structure or union
Color.y = cmp_linearToSrgbf(Color.y);
~~~~~^~
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/bcn_common_api.h:68:10: error: member reference base type 'CGU_Vec3f' (aka 'int') is not a structure or union
Color.z = cmp_linearToSrgbf(Color.z);
~~~~~^~
/disk-samsung/freebsd-ports/misc/cuttlefish/work/Cuttlefish-2.5.5/lib/compressonator/cmp_core/shaders/bcn_common_api.h:68:38: error: member reference base type 'CGU_Vec3f' (aka 'int') is not a structure or union
Color.z = cmp_linearToSrgbf(Color.z);
~~~~~^~
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
Version: 2.5.5
clang-13.1
FreeBSD 13.1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.