AcademySoftwareFoundation / AcademySoftwareFoundation/OpenImageIO

[FEATURE REQUEST] - float_half maketx/make_texture conversion

Open
#3,235 3 comments 0 reactions 0 assignees View on GitHub
good first issue texture / image cache
Dominant language
C++
Stars
2.4k
Forks
698
Avg merge
3d 9h
Merged PRs (30d)
48

Description

**Can the maketx argument --attrib half be applied ONLY when the source texture is float?**
I am trying to switch our own customized version of OpenImageIO to the mainline version and one of the last major differences is how texture conversion is handled. In our custom system, integer textures are converted "as-is", but floating-point textures are always deliberately converted to half-float for performance reasons (less data off disc = faster load time, and half-float = less memory in the texture cache and for us, half-float is plenty of precision at render-time).

If I call maketx like so (assuming the input file is a 32bit float texture):
`maketx --filter lanczos3 --fixnan box3 --oiio --wrap periodic --attrib tiff:half 1 --d half --threads 4 -o /path/to/outputfile.tx /path/to/inputfile.tif`

then the result will be half-float, which is fine, but so will all integer input textures (i.e. 8-bit integer textures will be up-converted to half-float which I don't want, as that will lower performance).

**I would instead like an option that ONLY applies to floating-point input textures, and allows them to be generated as half-float**
Would is make sense to half a new option called `--attribute tiff:float_half` or, alternatively, `--d float_half` which can specifically target floating-point input textures?

**Custom hacking is all I've considered**
Alternatively, writing code to open the file, and check the input before calling `OIIO::ImageBufAlgo::make_texture` is another option, but that feels "dirty" since I'd need to access the file-handle twice, one in my code to check it, then again in OIIO to do the conversion. I'd like it to be handled all in one place.

**Without this feature OpenImageIO is 30% slower than our existing system**
I expect that halving the data bandwidth will lower this difference in performance to 15%, which is MUCH closer to where I want to be.

Contributor guide

Open the contributing guide

Research direction

Start by reading maketx handling for --d and --attrib, then trace how those options reach OIIO::ImageBufAlgo::make_texture. The change is done when a documented option converts floating-point input to half-float while leaving integer input at its original type, with coverage for both cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.