Closed TechInterMezzo closed 1 year ago
There are various image formats; which one did you try?
What version of Unity do you have?
I used PNG files as source images and the Unity version is 2021.1.16f1.
I meant which crunch formats. Like these
cCRNFmtDXT1,
// cCRNFmtDXT3 is not currently supported when writing to CRN - only DDS.
cCRNFmtDXT3,
cCRNFmtDXT5,
// Various DXT5 derivatives
cCRNFmtDXT5_CCxY, // Luma-chroma
cCRNFmtDXT5_xGxR, // Swizzled 2-component
cCRNFmtDXT5_xGBR, // Swizzled 3-component
cCRNFmtDXT5_AGBR, // Swizzled 4-component
// ATI 3DC and X360 DXN
cCRNFmtDXN_XY,
cCRNFmtDXN_YX,
// DXT5 alpha blocks only
cCRNFmtDXT5A,
cCRNFmtETC1,
cCRNFmtETC2,
cCRNFmtETC2A,
cCRNFmtETC1S,
cCRNFmtETC2AS,
What do this change is doing? It seems to only change some header bits:
$ crunch-before -quality 255 -noNormalDetection -file door01a_d.png -out door01a_d.0.crn
$ crunch-after -quality 255 -noNormalDetection -file door01a_d.png -out door01a_d.1.crn
$ du -sb door01a_d.0.crn door01a_d.1.crn
49367 door01a_d.0.crn
49367 door01a_d.1.crn
$ hexdump -Cv door01a_d.0.crn > door01a_d.0.crn.hex
$ hexdump -Cv door01a_d.1.crn > door01a_d.1.crn.hex
$ diff door01a_d.0.crn.hex door01a_d.1.crn.hex
1,2c1,2
< 00000000 48 78 00 6e 33 f8 00 00 c0 d7 98 f1 01 00 02 00 |Hx.n3...........|
< 00000010 0a 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
---
> 00000000 48 78 00 6e 6b cd 00 00 c0 d7 98 f1 01 00 02 00 |Hx.nk...........|
> 00000010 0a 01 00 00 00 00 00 00 00 00 00 00 01 00 00 00 |................|
With emphasis on changes:
↓↓ ↓↓
< 00000000 48 78 00 6e[33 f8]00 00 c0 d7 98 f1 01 00 02 00 |Hx.n3...........|
< 00000010 0a 01 00 00 00 00 00 00 00 00 00 00[00]00 00 00 |................|
---
> 00000000 48 78 00 6e[6b cd]00 00 c0 d7 98 f1 01 00 02 00 |Hx.nk...........|
> 00000010 0a 01 00 00 00 00 00 00 00 00 00 00[01]00 00 00 |................|
↑↑
And I see that crunch-before
(with 0) can write a format readable by crunch-after
(with 1), like that:
$ crunch-before -file image.png -out image.crn
$ crunch-after -file image.crn -out image.png
And get something that looks as expected.
I also rebuilt tex-pk01
dpkdir with a crunch applying that change and neither Dæmon neither NetRadiant had trouble to decode the produced crn while being built with a crunch not applying that change.
I believe the point is that the Unity version treats it as a magic number while ours just ignores it.
I believe the point is that the Unity version treats it as a magic number while ours just ignores it.
Exactly, that is the point. Changing that bit makes the output of this fork compatible with up to date Unity versions. If that bit isn't set Unity complains and doesn't load the texture although it would be able to.
Unity knows the following texture formats regarding crunch: DXT1Crunched DXT5Crunched ETC_RGB4Crunched ETC2_RGBA8Crunched
They probably did that to detect CRN files produced with the the now-incompatible original crunch tool.
Since the time Unity released their enhanced crunch tool, the original author Rich Geldreich relicensed its original crunch under Public Domain, there was some articles and then people re-forked the original tool… probably producing new CRN files with it.
What surprises me is that Unity haven't bumped theat number in their own repository (commit from unity branch).
That is indeed strange. Maybe they just discarded the public repository and don't push back any changes. As you can see in my first post, there is a link to a post in their forum. The user is talking about that change and that it was suggested by the Unity support themselves.
@ TechInterMezzo this is now done:
Thank you for the information! 🙂️
See this post: https://forum.unity.com/threads/crunch-textures.522787/#post-4282222
If you change that field to 1, Unity won't complain about an old crunch version. https://github.com/DaemonEngine/crunch/blob/master/inc/crnlib.h#L229
I tested that change with your version locally and it works for me. I can load the crn files at runtime.