Skip to content

Commit b2071c1

Browse files
blackencinopstanczyk
authored andcommitted
Fixed misinterpretation of dtex samples in deepopacity case, updated README, comments, and ChangeLog to reflect fix.
1 parent cb66c20 commit b2071c1

File tree

4 files changed

+47
-27
lines changed

4 files changed

+47
-27
lines changed

Contrib/DtexToExr/ChangeLog

+9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
Version 1.0.0:
22
* Initial release of this code.
33

4+
Version 1.0.1:
5+
* Fixed misinterpretation of values read from "deepopacity" dtex files.
6+
The data stored is actually transmission, or 1.0-opacity, which means
7+
that "deepopacity" dtex values actually monotonically decrease from 1
8+
to 0. We have updated the comments and documentation to reflect this
9+
and have fixed the PxOneChanDeepOpacity file to convert the data
10+
as it is read out of the file.
11+
12+
413

Contrib/DtexToExr/PxDeepUtils.h

+8-6
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,15 @@ namespace PxDeep {
168168
// DEEP OPACITY
169169
//-*****************************************************************************
170170
// "Deep Opacity" refers to a depth function in which the sample at each point
171-
// represents the total accumulated alpha at that depth. This represents the
172-
// way that deep shadows would have been produced by renderman with the
173-
// Display Driver Line: "deepshad" "deepopacity". It is important to note
171+
// represents the total accumulated opacity at that depth. This represents
172+
// the way that deep shadows would have been produced by renderman with the
173+
// Display Driver Line: "deepshad" "deepopacity", except that the files actually
174+
// store the inverse (1.0-opacity) at each point. It is important to note
174175
// that for any given Dtex deepopacity sample, the value represents the
175-
// accumulation of alpha on the NEAR side of the sample - up to and including
176-
// the sample's depth, but no further in depth. Deep Opacity functions are
177-
// monotonically increasing in depth, and are always between 0 and 1.
176+
// accumulation of visibility on the NEAR side of the sample - up to and
177+
// including the sample's depth, but no further in depth. Deep Opacity
178+
// functions are monotonically decreasing in depth, and are always
179+
// between 0 and 1.
178180
//
179181
// A complication arises when the 0'th continuous deep opacity sample has a
180182
// non-zero deep opacity, because we don't have enough information to infer

Contrib/DtexToExr/PxOneChanDeepOpacity.h

+18-10
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,16 @@ void OneChanDeepOpacityContinuous<RGBA_T>::processDeepPixel( int i_numPts )
138138

139139
z = ClampDepth( z );
140140

141-
double deepOpac = ClampAlpha( pts[0] );
142-
143141
span_type& spanJ = (this->m_spans)[j];
144142
spanJ.clear();
145143
spanJ.in = z;
146144
spanJ.out = z;
147-
spanJ.deepViz = ClampViz( 1.0 - deepOpac );
145+
146+
// Data stored in dtex files for "deepopacity" is actually
147+
// "deeptransmission", monotonically decreasing from an initial
148+
// value of 1.0. We just convert it to viz directly.
149+
// (viz == transmissivity)
150+
spanJ.deepViz = ClampViz( pts[0] );
148151
spanJ.index = j;
149152
}
150153

@@ -191,9 +194,10 @@ void OneChanDeepOpacityContinuous<RGBA_T>::processDeepPixel( int i_numPts )
191194
{
192195
// This span has an identical depth to
193196
// the previous one, so we use whichever one has the
194-
// largest deep opacity.
197+
// largest deep opacity, which equates to the
198+
// smallest deep viz.
195199
spanActiveBegin.deepViz =
196-
std::max( spanActiveBegin.deepViz,
200+
std::min( spanActiveBegin.deepViz,
197201
spanNext.deepViz );
198202
spanNext.in = FLT_MAX;
199203
spanNext.out = FLT_MAX;
@@ -349,13 +353,16 @@ void OneChanDeepOpacityDiscrete<RGBA_T>::processDeepPixel( int i_numPts )
349353

350354
z = ClampDepth( z );
351355

352-
double deepOpac = ClampAlpha( pts[0] );
353-
354356
span_type& spanJ = (this->m_spans)[j];
355357
spanJ.clear();
356358
spanJ.in = z;
357359
spanJ.out = z;
358-
spanJ.deepViz = ClampViz( 1.0 - deepOpac );
360+
361+
// Data stored in dtex files for "deepopacity" is actually
362+
// "deeptransmission", monotonically decreasing from an initial
363+
// value of 1.0. We just convert it to viz directly.
364+
// (viz == transmissivity)
365+
spanJ.deepViz = ClampViz( pts[0] );
359366
spanJ.index = j;
360367
}
361368

@@ -400,9 +407,10 @@ void OneChanDeepOpacityDiscrete<RGBA_T>::processDeepPixel( int i_numPts )
400407
{
401408
// This span has an identical depth to
402409
// the previous one, so we use whichever one has the
403-
// largest deep opacity.
410+
// largest deep opacity, which equates to the
411+
// smallest deep viz.
404412
spanActiveBegin.deepViz =
405-
std::max( spanActiveBegin.deepViz,
413+
std::min( spanActiveBegin.deepViz,
406414
spanNext.deepViz );
407415
spanNext.in = FLT_MAX;
408416
spanNext.out = FLT_MAX;

Contrib/DtexToExr/README

+12-11
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,18 @@ out-of-order samples, precision issues, compression artifacts, and the
5353
differences between the "deepopacity" vs "deepalpha" interpretations.
5454

5555
With "deepopacity" (the pre-prman 16 usage), opacity values stored in
56-
dtex files were accumulated, so they were bounded between 0 and 1, and
57-
monotonically increased from fully transparent to fully opaque. This
58-
representation is ideal for meaningful error minimization during
59-
compression, and also for usage as a shadow map by a renderer, because
60-
the extinction at a particular depth, at a particular pixel, can be
61-
evaluated with a single look-up. However, this representation is
62-
poor for deep compositing, because each of the samples includes
63-
data from smaller depth samples, and recombination is difficult. With
64-
these types of files, when using volumetric (continuous) interpretation,
65-
the samples represent the accumulated alpha at the NEAR SIDE of a
66-
depth span, and our code paths take this into account.
56+
dtex files were accumulated, so they were bounded between 0 and 1. The
57+
values stored are actually not opacities, but rather transmissivities
58+
(1-opacity), and monotonically decreased from fully transparent (1)
59+
to fully opaque (0). This representation is ideal for meaningful error
60+
minimization during compression, and also for usage as a shadow map
61+
by a renderer, because the extinction at a particular depth, at a
62+
particular pixel, can be evaluated with a single look-up. However,
63+
this representation is poor for deep compositing, because each of the
64+
samples includes data from smaller depth samples, and recombination is
65+
difficult. With these types of files, when using volumetric (continuous)
66+
interpretation, the samples represent the accumulated transmissivity at
67+
the NEAR SIDE of a depth span, and our code paths take this into account.
6768

6869
With all other usages - "a" and "rgba", the values represent filtered
6970
samples of the given field at that point in space. The alpha values

0 commit comments

Comments
 (0)