castano / nvidia-texture-tools

Texture processing tools with support for Direct3D 10 and 11 formats.
https://github.com/castano/nvidia-texture-tools/wiki
Other
574 stars 215 forks source link

System.AccessViolationException compressing texture, and c# port #272

Open vpenades opened 6 years ago

vpenades commented 6 years ago

Hi

I've been having exception issues with NVTT used in monogame when processing textures, After some discussions with monogame maintainers, they expressed desire to remove NVTT in favour of a pure c# implementation.

I did a c# port of the original LibSquish here , and I'm in the process of replacing the NVTT method calls to LibSquish calls.

My questions are these:

In monogame code, they set AlphaMode to PreMultiplied when the texture format is not Dxt1. What SetAlphaMode does? it tells the library to premultiply the colors with alpha? or it is just to tell the library that the input bitmap has already been alpha-premultiplied?

I've found your repository after porting LibSquish, after reviewing nvidia-texture-tools code, I've found you've improved cluster block compression. Would you agree to let me port your code to c# too? My c# port also uses a MIT license.

let me know about it

castano commented 6 years ago

On Mon, Dec 11, 2017 at 3:13 AM, Vicente Penades notifications@github.com wrote:

Hi

I've been having exception issues https://github.com/MonoGame/MonoGame/issues/6093 with NVTT used in monogame when processing textures, After some discussions with monogame maintainers, they expressed desire to remove NVTT in favour of a pure c# implementation.

I did a c# port of the original LibSquish here https://github.com/vpenades/TextureSquish , and I'm in the process of replacing the NVTT method calls https://github.com/MonoGame/MonoGame/blob/develop/MonoGame.Framework.Content.Pipeline/Graphics/DxtBitmapContent.cs#L207 to LibSquish calls.

I'm not surprised, the C# wrapper has not received much attention lately.

My questions are these:

In monogame code, they set AlphaMode to PreMultiplied

https://github.com/MonoGame/MonoGame/blob/develop/MonoGame.Framework.Content.Pipeline/Graphics/DxtBitmapContent.cs#L199 when the texture format is not Dxt1. What SetAlphaMode does? it tells the library to premultiply the colors with alpha? or it is just to tell the library that the input bitmap has already been alpha-premultiplied?

The latter. It tells the library that the alpha is already pre-multiplied.

I've found your repository after porting LibSquish, after reviewing nvidia-texture-tools code, I've found you've improved cluster block compression. Would you agree to let me port your code to c# too? My c# port also uses a MIT license.

let me know about it

Sure, just credit the contributors to the original version and you should be free to make any changes.

-- Ignacio Castaño castano@gmail.com

vpenades commented 6 years ago

Thanks

Certainly, NVTT seems to cover a lot more than just encoding Dxt blocks, which is the only part I'm interested in.

Could it be possible for you to tell me which the minimal set of files related to block compression?

Upon initial review, it seems to me the code is in CompressorDXT1 and CompressorDXT5_RGBM , should I assume most of the actual code is there? and... is that code the one used for maximum quality?

I understand that QuickCompressDXT is a path for fast, low quality compression...

castano commented 6 years ago

For DXT1 compression I think all the relevant code is in CompressorDXT1.cpp/h and ClusterFit.cpp/h. For DXT5 the alpha compressor is still in Optimal/Quick compressDXT. I'm in the process of changing the code layout by format rather than speed or quality, but the alpha compression code is still in the old files. In the process I'm trying to make the compressors more independent from the rest of the code and expose them through a C-like API, but currently they are very far from a single-file library, so you will need to pull a bunch of additional files.

On Wed, Dec 13, 2017 at 7:20 AM, Vicente Penades notifications@github.com wrote:

Thanks

Certainly, NVTT seems to cover a lot more than just encoding Dxt blocks, which is the only part I'm interested in.

Could it be possible for you to tell me which the minimal set of files related to block compression?

Upon initial review, it seems to me the code is in CompressorDXT1 and CompressorDXT5_RGBM , should I assume most of the actual code is there? and... is that code the one used for maximum quality?

I understand that QuickCompressDXT is a path for fast, low quality compression...

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/castano/nvidia-texture-tools/issues/272#issuecomment-351422549, or mute the thread https://github.com/notifications/unsubscribe-auth/AAhcM1HIJHwdRB7nciZbcjav_CB1EACpks5s_-tNgaJpZM4Q9Ojn .

-- Ignacio Castaño castano@gmail.com