Skip to content

Commit 85ac9cf

Browse files
committed
Add documentation for new texture CDF options (AcademySoftwareFoundation#3206)
Also, fixed the fact that direct calls to make_texture() were not given proper defaults for the cdfsigma and cdfbits options. Related to PR AcademySoftwareFoundation#3159
1 parent 20e622c commit 85ac9cf

File tree

4 files changed

+66
-6
lines changed

4 files changed

+66
-6
lines changed

src/doc/maketx.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,33 @@ Command-line arguments are:
462462

463463
(This option was added for OpenImageIO 2.3.)
464464

465+
.. option:: --cdf
466+
--cdfsigma <SIGMA>
467+
--cdfbits <BITS>
468+
469+
When `--cdf` is used, the output texture will write a Gaussian CDF and
470+
Inverse Gaussian CDF as per-channel metadata in the texture, which can be
471+
used by shaders to implement Histogram-Preserving Blending. This is only
472+
useful when the texture being created is written to an image format that
473+
supports arbitrary metadata (e.g. OpenEXR).
474+
475+
When `--cdf` has been enabled, the additional options `--cdfsigma` may be
476+
used to specify the CDF sigma value (defaulting to 1.0/6.0), and
477+
`--cdfbits` specifies the number of bits to use for the size of the CDF
478+
table (defaulting to 8, which means 256 bins).
479+
480+
References:
481+
482+
* Histogram-Preserving Blending for Randomized Texture Tiling," JCGT 8(4),
483+
2019.
484+
485+
* Heitz/Neyret, "High-Performance By-Example Noise using a
486+
Histogram-Preserving Blending Operator," ACM SIGGRAPH / Eurographics
487+
Symposium on High-Performance Graphics 2018.)
488+
489+
* Benedikt Bitterli https://benedikt-bitterli.me/histogram-tiling/
490+
491+
These options were first added in OpenImageIO 2.3.10.
465492

466493

467494
.. sec-oiiotooltex:

src/doc/oiiotool.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,19 @@ Writing images
12891289
`:bumpformat=` *string*
12901290
For `-obump` only, specifies the interpretation of 3-channel source
12911291
images as one of: `height`, `normal`, `auto` (default).
1292-
1292+
`:uvslopes_scale=` *float*
1293+
For `-obump` only, specifies the amount to scale the bump-map slopes
1294+
by. (default: 0.0, meaning not to use this feature)
1295+
`:cdf=` *int*
1296+
If nonzero, will add to the texture metadata the forward and inverse
1297+
Gaussian CDF, which can be used by shaders to implement
1298+
Histogram-Preserving blending. (default: 0)
1299+
`:cdfsigma=` *float*
1300+
In conjunction with `cdf=1`, specifies the sigma value to use for the
1301+
CDF (default: 1.0/6.0).
1302+
`:cdfbits=` *int*
1303+
In conjunction with `cdf=1`, specifies the number of bits to use for
1304+
the size of the CDF table (default: 8, meaning 256 bins).
12931305

12941306
Examples::
12951307

src/include/OpenImageIO/imagebufalgo.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,6 +2092,27 @@ enum MakeTextureMode {
20922092
/// factor. The default is 0, disabling the
20932093
/// feature. If you use this feature, a suggested
20942094
/// value is 256.
2095+
/// - `maketx:cdf` (int) :
2096+
/// If nonzero, will write a Gaussian CDF and
2097+
/// Inverse Gaussian CDF as per-channel metadata
2098+
/// in the texture, which can be used by shaders
2099+
/// to implement Histogram-Preserving Blending.
2100+
/// This is only useful when the texture being
2101+
/// created is written to an image format that
2102+
/// supports arbitrary metadata (e.g. OpenEXR).
2103+
/// (See Burley, "On Histogram-Preserving Blending
2104+
/// for Randomized Texture Tiling," JCGT 8(4), 2019,
2105+
/// and Heitz/Neyret, "High-Performance By-Example
2106+
/// Noise using a Histogram-Preserving Blending
2107+
/// Operator," ACM SIGGRAPH / Eurographics Symposium
2108+
/// on High-Performance Graphics 2018.) (default: 0)
2109+
/// - `maketx:cdfsigma` (float) :
2110+
/// When `maketx:cdf` is active, determines the
2111+
/// CDF sigma (default: 1.0/6).
2112+
/// - `maketx:cdfbits` (int) :
2113+
/// When `maketx:cdf` is active, determines the
2114+
/// number of bits to use for the size of the CDF
2115+
/// table. (default: 8, meaning 256 bins)
20952116
///
20962117
/// @param mode
20972118
/// Describes what type of texture file we are creating and may

src/libOpenImageIO/maketexture.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,16 +1198,16 @@ make_texture_impl(ImageBufAlgo::MakeTextureMode mode, const ImageBuf* input,
11981198
//
11991199
// Eric Heitz and Fabrice Neyret, High-Performance By-Example Noise
12001200
// using a Histogram-Preserving Blending Operator,
1201-
// https://hal.inria.fr/hal-01824773}, Proceedings of the ACM on
1201+
// https://hal.inria.fr/hal-01824773, Proceedings of the ACM on
12021202
// Computer Graphics and Interactive Techniques, ACM SIGGRAPH /
1203-
// Eurographics Symposium on High-Performance Graphics 2018,
1203+
// Eurographics Symposium on High-Performance Graphics 2018.
12041204
//
12051205
// Benedikt Bitterli
12061206
// https://benedikt-bitterli.me/histogram-tiling/
12071207

1208-
const float cdf_sigma = configspec.get_float_attribute(
1209-
"maketx:cdfsigma");
1210-
const int cdf_bits = configspec.get_int_attribute("maketx:cdfbits");
1208+
const float cdf_sigma
1209+
= configspec.get_float_attribute("maketx:cdfsigma", 1.0f / 6.0f);
1210+
const int cdf_bits = configspec.get_int_attribute("maketx:cdfbits", 8);
12111211
const uint64_t bins = 1 << cdf_bits;
12121212

12131213
// Normalization coefficient for the truncated normal distribution

0 commit comments

Comments
 (0)