AcademySoftwareFoundation / OpenColorIO

A color management framework for visual effects and animation.
https://opencolorio.org
BSD 3-Clause "New" or "Revised" License
1.8k stars 460 forks source link

Incorrect output: ociolutimage --generate --cubesize 64 --output linear_64_LUT.exr #1458

Closed HogJonny-AMZN closed 2 years ago

HogJonny-AMZN commented 3 years ago

The above command creates an incorrectly formatted LUT. The dimensions are: w: 2048, h: 128 Should be: w: 4096, h: 64

The cells look like this image

LUT is attached.

linear_64_LUT.zip

EvanAW commented 3 years ago

Late here so I cannot test it out right now, but just looking at ociolutimage/main.cpp, maxwidth can be passed as an option to ociolutimage. Otherwise it defaults to 2048.

"--maxwidth %d", &maxwidth, "Specify maximum width of the image (default: 2048)",

If you set maxwidth to 4096, does that get you the result you are looking for?

Plugging in a cubesize of 64 and a maxwidth of 2048 into GetLutImageSize does set the output width to 2048 and height to 128, if my mental math is correct.

There is a 10 year old TODO inside that function that says:

// TODO: Do something smarter here to find a better multiple, // to create a more pleasing gradient rendition. // Use prime divisors / lowest common denominator, if possible?

I don't convert LUTs to images as part of my workflow, so I am out of my depth to judge how relevant that TODO is today.

HogJonny-AMZN commented 3 years ago

You are a sleuth @EvanAW. I was following some documentation, this tool and it's options aren't fully documented. I was so in the rabbit hole I didn't think about looking at the tool code itself. That works. I would be nice if it in fact was smarter, generating a 16 or 32 cube works fine without additional params. I am also making assumptions there about my usage (realtime 3d rendering engine) and power of two image dimensions - I don't know if others use this tool in another way. But seems like a cube / 3d textures, the width/length will always be increments of the height.

I probably wouldn't do this but it works fine "ociolutimage --generate --cubesize 19", so I guess it simply breaks and needs the additional param once the width overruns 2048.

remia commented 3 years ago

Also you can just run the tool without any arguments to get the usage help which includes the --maxwidth flag.

One other way the tool gets used is to sample proprietary color transformations by passing a simple image through the process / software then extracting the LUT with the --extract flag. This is where you might want to constrain the maximum width of your image so that it falls within the accepted texture size.

doug-walker commented 2 years ago

Closing this. As mentioned, one simply needs to set the maxwidth flag to get the desired result.