Hi,
A couple of weeks ago whilst experimenting with DDO I discovered its png exporter had two major failings. Firstly it does not include the relevant alpha channel data (e.g. gloss in a spec/gloss map), such data is just missing from the exported file, but is included in say tga. Secondly it ignored png's lossless compression, meaning file sizes were vastly larger than they needed to be.
This post provides scripts and details as to how to address both these issues and its my hope that Quixel will consider and implement them in a future release.
Alpha channel support is a problem inherent with Photoshop's png exporter. Its been like this for decades, holding to the letter of the png format, which does not explicitly support alpha channels but instead transparency. This is why many people use
SuperPNG, a free plugin (updated in 2014) that offers a host of options to make effective use of the png format.
There are two solutions to alpha channel issue, the first is to convert the final output maps alpha channel to transparency before exporting to png. The second is to export using SuperPNG instead of Photoshop's native PNG exporter, where SuperPNG can be set to use the alpha channel instead of transparency, it can also produce a nice clean rgb image too (see SuperPNG manual).
The problem with compression is easy to fix in code, it just needs an additional line added. However using maximum compression setting in PNG will make file export unpleasantly slow. Luckily there is a happy medium using a compression setting of 50% results in nearly the same level of compression but in a fraction of the time.
Below you'll find a link to a zip that contains the necessary instructions and code you need to add/change in Quixel to get improved png support. Sadly its a little convoluted at the moment as I realised just before posting this that Quixel may not be happy with me posting an amended version of one of their main scripts (functions.jsx). For that reason i've supplied my functions as a new file that you can just drop into Quixel, but also instructions that need to be followed to update Quixels functions.jsx file.
If Quixel read this and are happy for me to post my amended functions.jsx file i'll update the zip as this will make the process much simpler for people. Essentially you'll just need to drop in two jsx files into quixel/common folder and you're done (though you want to back up Quixels original functions.jsx first).
Download the Quixel Suite PNG Fixes
http://www.noisecrime.com/random/quixel/QuixelSuite_NoiseCrime_PNG_Fix.zip
You MUST read the supplied text file in the download as it contains information on how to set this up, options and most importantly the code changes you must make to functions.jsx
The changes should be pretty self-explanatory, they are clearly commented. I spent quite a bit of time testing the conversion of alpha to transparency so pretty sure its correct. However if you have any problems, please post in this thread and i'll see what I can do.
Hopefully the developers of DDO can take a quick look and incorporate some or all of the fixes. I would also like to request that the developer includes settings in the exporter for additional file format options, such as selecting the level of compression for PNG files.
One aspect I was unable to change was to add a new fileType (e.g. .spng) which would have allowed me to include SuperPNG to be an explicit option in the exporter dropdown, instead of currently just over-riding PNG. The output type would still be .png, i'd just use .spng to differentiate between png and superpng in the dropdown.
Alternatively if the exporter window could be expanded to support additional options then superPNG could be added as a sub-option to png along with being able to specify specific compression settings (0-9).
Replies
- Teddy
I forgot to mention that this has only been tested in CC 2014 and i'm unsure which version of Photoshop made available that png compression setting, or if indeed it was simply there from the start and undocumented. In fact I discovered this function later, but never got around to testing it.
The rest of the code was grabbed via Photoshop's script listener which i'm sure you are aware of and I think it should work fine for any version of PS as its all pretty generic stuff.
In case it was missed in the above wall of text, I would like to re-iterate my request for adding support to save via SuperPNG. There just needs to be an additional type added to the exporter dropdown, but pretty sure all that code is within your dll's. I meant to look to see if Photoshops scripting api provided a means to check if a plug-in was installed as that would be nice to avoid any errors. Though I did test without the plug-in, PS provided an error dialog but nothing bad happened.
BTW - i've noticed if you use a compressed png for your 'Color ID Map', DDO will open it, then re-save it with no compression ( so a 45k file can grow to 12MB for a 2048x2048 simple color map). Think its related to different png code in BaseFunctions.jsx, but I wasn't too sure what was going on there so didn't want to change it.