GafferHQ / gaffer

Gaffer is a node-based application for lookdev, lighting and automation
http://www.gafferhq.org
BSD 3-Clause "New" or "Revised" License
949 stars 205 forks source link

`ImageWriter`: Expose oiiomaketx flags #5959

Open pier-robot opened 2 months ago

pier-robot commented 2 months ago

Summary

Add options to the ImageWriter node for use when writing tx files.

User story

Recently at IE we've run into a couple of cases where we've wanted to write tx files but the default behaviour of the Image Writer doesn't produce what we want, so we subprocess a call to oiiomaketx ourselves. It would be useful to have some flags exposed on the ImageWriter in the same way that options appear when writing exrs.

What

The flags we tend to use are:

--format FILEFORMAT Specify output file format (default: guess from extension)

-u                       Update mode
--nchannels N            Specify the number of output image channels.
-d TYPE                  Set the output data format to one of: uint8, sint8, uint16, sint16, half, float
--wrap WRAP              Specify wrap mode (black, clamp, periodic, mirror)
--colorconvert IN OUT    Apply a color space conversion to the image.
--resize                 Resize textures to power of 2 (default: no)
--fixnan STRATEGY        Attempt to fix NaN/Inf values in the image (options: none, black, box3)
--constant-color-detect  Create 1-tile textures from constant color inputs
--monochrome-detect      Create 1-channel textures from monochrome inputs
--opaque-detect          Drop alpha channel that is always 1.0

--oiio                   Use OIIO-optimized settings for tile size, planarconfig, metadata.

with format being the most important.

Why

We want to be able to specify the format of the tx file in specific situations.

johnhaddon commented 1 month ago

I think there is a big enough difference in internal implementation that this might be better implemented as a separate TextureWriter node than as additional complexity in the ImageWriter node. If it were presented that way, would that cause any problems for your intended usage?

I suspect the most expedient implementation might also be to use an internal network with an ImageWriter/SystemCommand/LocalDispatcher combo rather than write more C++. So not all that far from what you're currently doing - just wrapped up nicely with a UI.

johnhaddon commented 1 month ago

The other thing that occurs to me is that it might also be nice to provide a node which can create textures for files which already exist on disk - then you could use Gaffer to do batch texture conversion with any supported Dispatcher. If we had that, then the TextureWriter could use that internally.

pier-robot commented 1 month ago

A TextureWriter node would certainly do the trick, there's no specific need for it to be an ImageWriter update. Thanks for the info! We can add this in IEGafferExtensions, as I imagine it's not the highest priority for you all.