brendan-duncan / image

Dart Image Library for opening, manipulating, and saving various different image file formats.
MIT License
1.18k stars 266 forks source link

Adding GPU textureformats #29

Closed pjako closed 3 years ago

pjako commented 10 years ago

Not sure this fits this library but: Support various GPU texture formats would be helpful for WebGL applications. ETC, PVRTC, S3TC/DXTC and maybe crunch. Not sure if its possible to write compression/decompression for all these formats in dart because some of them may have no public spec. Maybe it is easier to use binaries here.

brendan-duncan commented 10 years ago

It would be awesome to add codecs for some texture compression formats. I'll have to look into that.

Fox32 commented 10 years ago

Btw, dds supports seems to be available in the spectre package already. Never used that and I don't know if it is a help. https://github.com/johnmccutchan/spectre/tree/master/lib/src/spectre_asset_pack

Ok I think the decompressing is done in hardware, only the container is read in that code.

pjako commented 10 years ago

Yes it only reads the container. We only need encoding.

brendan-duncan commented 10 years ago

I wonder if doing a dart port of crunch ( https://code.google.com/p/crunch) would work... On Sep 16, 2014 12:06 PM, "Peter Jakobs" notifications@github.com wrote:

Yes it only reads the container. So in the end we only need encoding.

— Reply to this email directly or view it on GitHub https://github.com/brendan-duncan/image/issues/29#issuecomment-55796499.

pjako commented 10 years ago

Crunch would be nice for DXT and ETC.

Maybe this could be helpful: https://github.com/Mokosha/FasTC

brendan-duncan commented 10 years ago

That looks like a good candidate for porting, which I'd be glad to do, but the only problem with FasTC is that is has a very restrictive license, requiring explicit permission for commercial usage. Crunch has a much better license (ZLIB), I'll have to investigate how difficult the port will be.

pjako commented 10 years ago

There are multiple license files in the FasTC project can you link the one you are referring to?

brendan-duncan commented 10 years ago

I don't see any actual license files, I'm looking at the top comment in all of the source/header files which says:

That makes me a bit nervous... I wouldn't want to impose the requirement of written permission to anyone using the library for commercial purposes. Maybe it could be ported into a separate package outside of the image library, so it would be clearer to someone wanting to use it...

pjako commented 10 years ago

For ETC/DXT Rich Geldreichs work could be used.

For PVRTC may look into this: https://github.com/Volcore/quickpvr

The license on FasTC is to restrictive.

brendan-duncan commented 10 years ago

Cool, I'll check it out.

brendan-duncan commented 10 years ago

The QuickPVR project only has a PVRTC decompressor. What's with these formats with such limited support? So far the only people I've found that have worked on PVRTC compressors are FasTC and Rich Geldreichs (https://sites.google.com/site/richgel99/pvrtc-compression2), but it doesn't appear as though he ever got around to integrating it onto Crunch.

pjako commented 10 years ago

PVRTC is mostly for apple devices. Most of the compressors for these GPU formats are closed source. I guess most companies just use the compressor within xcode or the compiled library of imgtec. Update: There is also: http://roartindon.blogspot.de/2014/08/pvr-texture-compression-exploration.html

tatumizer commented 10 years ago

For port of the library, you can contact original author, and talk it over. This works on case-by-case basis AFAIK. He can give you completely different license for the port.

brendan-duncan commented 10 years ago

That's great. I'll look into expanding on Jeffery Lim's code for a PVRTC compressor. If I get stuck on that, I'll try contacting Pavel Krajcevski to see if he can be persuaded to a more lenient license for a port of FasTC. DXT and ETC compressors seem to be more plentiful, so they shouldn't be a problem. Now the only challenge is to find the time to do it, I should be able to squeeze a few hours here and there, I don't think it should take too long. I like a good challenge :-).

brendan-duncan commented 10 years ago

An update on PVRTC: I worked with Jeff Lim (from http://roartindon.blogspot.de/2014/08/pvr-texture-compression-exploration.html) and got his C++ realtime PVRTC encoder/decoder working, and will be finishing up the Dart port of that soon.

pjako commented 10 years ago

Nice to have both. I'm curious how the dart port will compare performance wise.

brendan-duncan commented 10 years ago

I got the PVRTC encoding and decoding working in Dart! So far I added the RGB_4BPP, and I'll finish adding the other formats, RGB_2BPP, RGBA_4BPP and RGBA_2BPP shortly. I also have a simple PVR format encoder, which is generating files that are loading correctly by PVRTexTool!

I'll start doing some benchmark tests against the C++ version too. That'll be interesting to see. I know there are a few places I can optimize the Dart code...I'll save that as an exercise for later.

I'll work on DXT and ETC after I wrap up PVRTC. I'm not expecting as much trouble with those as with PVRTC. Like with the PVRTC encoder, I'm planning on implementing the real-time variants of these, where the quality won't be quite as nice as the slow off-line compressors, but will be much faster, targeting on-the-fly compression.

brendan-duncan commented 10 years ago

BTW, I'm still working on this. Work got busy so updates will be slow for a bit.

CelerityAbbottPC commented 9 years ago

I'll start doing some benchmark tests against the C++ version too. That'll be interesting to see. I know there are a few places I can optimize the Dart code...I'll save that as an exercise for later.

Hi Brendan:

Got around to do the benchmark?

(Personally I'd mostly be interested in large 16bit grayscale Tiff images.)

brendan-duncan commented 9 years ago

Sorry, I haven't.