Skip to content

Commit 72e0a8a

Browse files
authored
final edits (#4650)
1 parent 81b2f92 commit 72e0a8a

File tree

3 files changed

+49
-46
lines changed

3 files changed

+49
-46
lines changed

packages/model-viewer/src/three-components/Renderer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ export class Renderer extends
437437
const env = element.environmentImage;
438438
const sky = element.skyboxImage;
439439
const compensateExposure = toneMapping === CustomToneMapping &&
440-
(env === 'neutral' || env === 'legacy' || (env == null && sky == null));
440+
(env === 'neutral' || env === 'legacy' || (!env && !sky));
441441
this.threeRenderer.toneMappingExposure =
442442
(exposureIsNumber ? exposure : 1.0) *
443443
(compensateExposure ? COMMERCE_EXPOSURE : 1.0);

packages/modelviewer.dev/examples/color.html

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -577,28 +577,13 @@ <h3 id="takeaway">What's the takeaway?</h3>
577577
material baseColor, which is what allows the demo below to be compellingly
578578
realistic.</p>
579579

580-
<figure>
581-
<model-viewer
582-
id="environments"
583-
src="../assets/ShopifyModels/Mixer.glb"
584-
skybox-image="../../shared-assets/environments/neutral.hdr"
585-
tone-mapping="commerce"
586-
camera-controls
587-
alt="3D model of a blender"
588-
>
589-
</model-viewer>
590-
<figcaption>Note how much different the product's colors are in each
591-
environment, yet how that is exactly what makes it appear
592-
realistic.</figcaption>
593-
</figure>
594-
595580
<p>Still, for most e-commerce vendors that are likely managing separate
596-
contracts for 3D model generation and interactive website design, simplicity
581+
contracts for 3D model creation and interactive website design, simplicity
597582
is key to cost-effectiveness. My recommendation is to use our Commerce tone
598583
mapping and if you already have approved marketing colors for your products,
599584
then tell your artists to use those for the baseColor. Use a grayscale
600-
lighting environment, adjusting if necessary to place highlights and change
601-
exposure.</p>
585+
lighting environment (like our default), adjusting if necessary to place
586+
highlights and change exposure.</p>
602587

603588
<p>If the color is not known, but being matched by eye, then ensure the
604589
artist's tools also use the Commerce tone mapper and a lighting environment
@@ -612,6 +597,21 @@ <h3 id="takeaway">What's the takeaway?</h3>
612597
<code>tone-mapping="commerce"</code>. This way they can calibrate and ensure
613598
the end user will see realistic colors.</p>
614599

600+
<figure>
601+
<model-viewer
602+
id="environments"
603+
src="../assets/ShopifyModels/Mixer.glb"
604+
skybox-image="../../shared-assets/environments/neutral.hdr"
605+
tone-mapping="commerce"
606+
camera-controls
607+
alt="3D model of a blender"
608+
>
609+
</model-viewer>
610+
<figcaption>Note how much different the product's colors are in each
611+
environment, yet how that is exactly what makes it appear
612+
realistic.</figcaption>
613+
</figure>
614+
615615
</div>
616616
<div style="margin-top:24px"></div>
617617
<div class="footer">

packages/modelviewer.dev/examples/tone-mapping.html

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ <h2>Tone Mapping Considerations for Physically-Based Rendering</h2>
135135
<a href="#tradeoffs">Tradeoffs</a><br/>
136136
<a href="#needs">The needs of e-commerce</a><br/>
137137
<a href="#commerce">Commerce tone mapper</a><br/>
138+
<a href="#validation">Validation</a><br/>
138139
<a href="#white">White point</a><br/>
139140
</p>
140141

@@ -252,7 +253,7 @@ <h3 id="purpose">The purpose of tone mapping</h3>
252253
the level of ambient lighting around it, but this data is unlikely to be
253254
available.</p>
254255

255-
<h3 id="#tradeoffs">Tradeoffs</h3>
256+
<h3 id="tradeoffs">Tradeoffs</h3>
256257

257258
<p>The difficulty with compressing a nearly infinite HDR range down to sRGB
258259
is the necessary loss of information. For the highlights to be discernable,
@@ -299,10 +300,10 @@ <h3 id="#tradeoffs">Tradeoffs</h3>
299300
system to compensate for the loss of saturation, allowing the image to still
300301
look good, instead of washed-out.</p>
301302

302-
<h3 id="#needs">The needs of e-commerce</h3>
303+
<h3 id="needs">The needs of e-commerce</h3>
303304

304305
<p>Unfortunately, the needs of e-commerce are quite different than the needs
305-
of film or gaming. On a website, a 3D product model will side-by-side with
306+
of film or gaming. On a website, a 3D product model will be side-by-side with
306307
sRGB product photos, and a user may often compare the image on their screen
307308
to a printed image in a catalogue or to the physical product they have
308309
received. Of course it is exceedingly difficult to succeed in these
@@ -348,7 +349,7 @@ <h3 id="#needs">The needs of e-commerce</h3>
348349
these situations, but there will be additional challenges beyond tone
349350
mapping as well.</p>
350351

351-
<h3 id="#commerce">Commerce tone mapper</h3>
352+
<h3 id="commerce">Commerce tone mapper</h3>
352353

353354
<p>The Commerce tone mapper is designed to be simple to implement, fast to
354355
run, and faithfully reproduce color as much as possible while eliminating
@@ -375,7 +376,7 @@ <h3 id="#commerce">Commerce tone mapper</h3>
375376

376377
<p>Since tone mapping is about fitting into the sRGB cube, I intentionally
377378
avoid any use of luminance weights, as the edges of the sRGB cube are not at
378-
all constant luminance. Instead I scale down colors by a simple multiplier,
379+
all constant luminance. Instead I scale down colors by a scalar multiplier,
379380
thus preserving hue and saturation while reducing brightness (there are many
380381
definitions for these terms, so please bear with my imprecision). The
381382
brightness metric I use is the maximum value of R, G, and B, and the goal is
@@ -386,10 +387,10 @@ <h3 id="#commerce">Commerce tone mapper</h3>
386387
a single parameter: the value where we switch from the linear to the
387388
nonlinear function. The purpose of the Commerce tone mapper is to be a
388389
standard and thus without parameters, so I chose 0.8 after much testing.
389-
However, this is likely the most natural place to adjust the curve for HDR
390-
output rather than sRGB.</p>
390+
However, this is likely the most natural place to adjust the curve to HDR
391+
output from sRGB.</p>
391392

392-
<p>Converting 0.8 to sRGB gives 231, so any baseColor with R, B, and B
393+
<p>Converting 0.8 to sRGB gives 231, so any baseColor with R, G, and B
393394
values below 231 will be faithfully reproduced under even, white lighting.
394395
The compression reduces 255 to 243, so all highlights that would be clipped
395396
end up mapped to the 243-255 range.</p>
@@ -407,7 +408,7 @@ <h3 id="#commerce">Commerce tone mapper</h3>
407408
only other parameter in this tone mapper controls the rate of desaturation,
408409
which I chose as 0.15, which is significantly slower to approach its
409410
asymptote than the compression function. This is what helps produce our
410-
smoother gradients and hide the aggressiveness of our compression. In some
411+
smoother gradients and hide the aggressiveness of our compression. In a
411412
sense I am replacing the lost brightness with desaturation, thus giving the
412413
brain an alternate perceptual cue, which smoothly encodes several orders of
413414
magnitude more brightness than is available in the output screen.</p>
@@ -446,12 +447,14 @@ <h3 id="#commerce">Commerce tone mapper</h3>
446447
<figcaption>Same as above, but with the input brightness in log scale.</figcaption>
447448
</figure>
448449

449-
<p>The following demo uses a test model based on a Macbeth color chart. For each color,
450-
there is a matte sphere, shiny dielectric sphere and an unlit sphere for
451-
baseColor comparison. Along the top is an additional row with saturated
452-
colors and shiny metallic spheres - this is useful for demonstrating the
453-
problems with Linear/Clamped tone mapping. Along the left and right are
454-
columns of shiny metals.</p>
450+
<p>The following demo uses a test model based on a Macbeth color chart. For
451+
each color, there is a matte sphere, shiny dielectric sphere and an unlit
452+
sphere for baseColor comparison. Along the top is an additional row with
453+
saturated colors and shiny metallic spheres - this is useful for
454+
demonstrating the problems with Linear/Clamped tone mapping - note the
455+
extreme hue skews of the highlights. Along the left and right are columns of
456+
shiny metals.</p>
457+
455458
<p>Try the different tone mappers under both
456459
neutral and outdoor lighting. This test is intentionally designed to show
457460
off HDR artifacts.</p>
@@ -491,7 +494,7 @@ <h3 id="#commerce">Commerce tone mapper</h3>
491494
<figcaption>Tone mapper test demo.</figcaption>
492495
</figure>
493496

494-
<h3 id="#validation">Validation</h3>
497+
<h3 id="validation">Validation</h3>
495498

496499
<p>The best end-to-end validation we have for color accuracy is to apply an
497500
unrealistic, analytic lighting environment: a white furnace test, where the
@@ -517,25 +520,25 @@ <h3 id="#validation">Validation</h3>
517520
shadow-intensity="1"
518521
>
519522
</model-viewer>
520-
<figcaption>Commerce tone mapper validation.</figcaption>
523+
<figcaption>Commerce tone mapper white furnace validation.</figcaption>
521524
</figure>
522525

523-
<p>The first difference is from the Fresnel effect: on shiny materials, the
526+
<p>The first difference is due to multi-scattering, which causes the
527+
dark-colored matte (front) spheres to be slightly darker than their unlit
528+
comparisons. This is intentional, as matte materials are rough, thus
529+
forming microscopic cavities that cause slight ambient occlusion and allow
530+
dark materials more light bounces to absorb energy. Accurate PBR renderers
531+
include this effect because a single material will in fact become brighter
532+
as it is polished.</p>
533+
534+
<p>The second difference is from the Fresnel effect: on shiny materials, the
524535
reflection loses material color near grazing angles. This is a physical
525536
reality and causes the white halos on the edges of the shiny (back) spheres.
526537
If you turn the model until the unlit spheres overlap the middle of the
527538
shiny spheres, you'll see that the color match is exact at normal (center)
528539
reflection.</p>
529540

530-
<p>The second effect is multi-scattering, which causes the dark-colored
531-
matte (front) spheres to be slightly darker than their unlit comparisons.
532-
This is also intentional, as matte materials are rough, thus forming
533-
microscopic cavities that cause slight ambient occlusion and allow dark
534-
materials more light bounces to absorb energy. Accurate PBR renderers
535-
include this effect because a single material will in fact become brighter
536-
as it is polished.</p>
537-
538-
<h3 id="#white">White point</h3>
541+
<h3 id="white">White point</h3>
539542

540543
<p>The tl;dr of this section is that you can safely skip it. It is a
541544
discussion of the difference between physically correct and practical

0 commit comments

Comments
 (0)