Comments (5)
Follow up : some troubles were on my end (I was writing back the indice field even though it's the data field that hold the incices... fml)
However, I did have to adjust a few things. I noticed that when decompressing the original texture, 99% of the blocks were coded with 8 values even if a lot of them had "0" as an endpoint. I changed to condition for bUsing4BlockCodec to only include 1f. I also adjusted other little things but I don't think they would matter much for you and this issue. It now works perfectly! I hope this was useful to you.
Cheers!
from directxtex.
Can you provide a code snippet of the minimal changes to address your concern?
from directxtex.
Sorry, had a little trouble with formatting on here. This was easier :
https://docs.google.com/document/d/1QsBMxPyZj9_lzJrnpqvJKkXbFfhw9CznZXGU2CePiG0/edit?usp=sharing
This is the code I use in my app (translated to C#)
Changes (other than pure C# translations) are highligthed.
I tested it with the texture provided above and none of the pixels have a difference of more than one shade of red with their original value as a byte (I.E. original : 87 red, new value = 86)
I also tested by enlarging the texture by 200% and re-importing to simulate changes and the import worked perfectly as well.
from directxtex.
In the C++ code, the bug I see for BC4 is that in FindEndPointsBC4U
, the iStart
, iEnd
variables should be uint8_t
and not int8_t
. That said, it looks like the compiler ignores the sign difference here and fails to mess it up.
The name bUsing4BlockCodec
is a little confusing. It refers to the "4 interpolated color values" rather than the "6 interpolated color values" as described in Block Compression on MSDN. The code does need a bit more extra commenting here to make that clear.
Your 'exact comparison' in FindClosestUNORM
is an optimization which in theory shouldn't matter since fabsf
should find the zero, but floating numbers aren't real numbers so that might be worth adding as well to short-cut the loop.
Note that your C# code is not forcing the use of the 4-interpolated color values case if the block contains 0, which you want to do to avoid generating transparent rather invisible alpha values. The BC4/BC5 compressors use the same logic as the original DXT2-5 (BC2/BC3) does for the alpha channel which is if alpha is 0 or 1 exactly, it uses the '4 interpolated values' mode rather than the '6 interpolated values' mode.
from directxtex.
I'm unable to repro your original issue with the texconv
release from December 2016. The RGBA32 -> BC4U compression looks correct to me even with the code "as is". Did you get the repro originally using your C# code?
Note that the D3DX DXTn/BC2/BC3/BC4/BC5 compression code for alpha uses the heuristic of choosing the 4 vs. 6 case based on the min/max values hitting the boundary. Other compressors sometimes compress a given block both ways and chooses the one with the least error.
from directxtex.
Related Issues (20)
- DDS files with a DDS_PIXELFORMAT size of 24 HOT 12
- .sln removal HOT 1
- Build /mt failed HOT 1
- Legacy DDS files with a DDS_HEADER size of 24
- Texconv.exe can not handle whitespaces in output path HOT 5
- -flist keep structure HOT 1
- Integrate Xbox functionality in the Auxiliary folder
- FAILED (80004005: Unspecified error ) HOT 2
- Move PPM/PFM I/O functions to the library HOT 1
- WIC loading is different from D3DX loading of WIC textures HOT 9
- GPU-compressed `BC7_UNORM_SRGB` textures contain red streaks when using texconv.exe under wine HOT 1
- (Question) Converting BC4 to BMP with texconv HOT 1
- Does DirectXTex directly depend on ZLIB? HOT 3
- Can't compile ddsdump HOT 2
- gcc Warnings in Linux -Wstringop-overflow HOT 4
- Does DirectX support direct reading of compressed textures? HOT 1
- Use fixed width integers for underlying enum types HOT 1
- I need pre-compiled shaders HOT 3
- Allow user to convert single lat-long hdri into cubemap HOT 1
- Low quality DXT compression HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from directxtex.