Skip to content

Commit ee0d9d3

Browse files
sebavanbghgary
andauthored
Fix Legacy Specular Energy Conservation (#17008)
Co-authored-by: Gary Hsu <[email protected]>
1 parent 9a39450 commit ee0d9d3

File tree

5 files changed

+10
-12
lines changed

5 files changed

+10
-12
lines changed

packages/dev/core/src/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents.fx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
vec3 finalDiffuse = diffuseBase;
33
finalDiffuse *= surfaceAlbedo;
44

5-
#if defined(SS_REFRACTION) && !defined(UNLIT)
5+
#if defined(SS_REFRACTION) && !defined(UNLIT) && !defined(LEGACY_SPECULAR_ENERGY_CONSERVATION)
66
finalDiffuse *= subSurfaceOut.refractionOpacity;
77
#endif
88
#if defined(SS_TRANSLUCENCY) && !defined(UNLIT)

packages/dev/core/src/Shaders/ShadersInclude/pbrBlockSubSurface.fx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -439,12 +439,11 @@ struct subSurfaceOutParams
439439
environmentRefraction.rgb *= surfaceAlbedo.rgb;
440440
#endif
441441

442+
outParams.surfaceAlbedo = surfaceAlbedo;
443+
outParams.refractionOpacity = 1. - refractionIntensity;
444+
442445
#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
443-
outParams.surfaceAlbedo = surfaceAlbedo * (1.-refractionIntensity);
444-
outParams.refractionOpacity = 1.0;
445-
#else
446-
outParams.surfaceAlbedo = surfaceAlbedo;
447-
outParams.refractionOpacity = (1. - refractionIntensity);
446+
outParams.surfaceAlbedo *= outParams.refractionOpacity;
448447
#endif
449448

450449
#ifdef UNUSED_MULTIPLEBOUNCES

packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrBlockFinalUnlitComponents.fx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// _____________________________ Diffuse ________________________________________
22
var finalDiffuse: vec3f = diffuseBase;
33
finalDiffuse *= surfaceAlbedo;
4-
#if defined(SS_REFRACTION) && !defined(UNLIT)
4+
#if defined(SS_REFRACTION) && !defined(UNLIT) && !defined(LEGACY_SPECULAR_ENERGY_CONSERVATION)
55
finalDiffuse *= subSurfaceOut.refractionOpacity;
66
#endif
77
#if defined(SS_TRANSLUCENCY) && !defined(UNLIT)

packages/dev/core/src/ShadersWGSL/ShadersInclude/pbrBlockSubSurface.fx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -463,12 +463,11 @@ struct subSurfaceOutParams
463463
environmentRefraction = vec4f(environmentRefraction.rgb * surfaceAlbedo.rgb, environmentRefraction.a);
464464
#endif
465465

466+
outParams.surfaceAlbedo = surfaceAlbedo;
467+
outParams.refractionOpacity = 1. - refractionIntensity;
468+
466469
#ifdef LEGACY_SPECULAR_ENERGY_CONSERVATION
467-
outParams.surfaceAlbedo = surfaceAlbedo * (1.-refractionIntensity);
468-
outParams.refractionOpacity = 1.0;
469-
#else
470-
outParams.surfaceAlbedo = surfaceAlbedo;
471-
outParams.refractionOpacity = (1. - refractionIntensity);
470+
outParams.surfaceAlbedo *= outParams.refractionOpacity;
472471
#endif
473472

474473
#ifdef UNUSED_MULTIPLEBOUNCES
633 Bytes
Loading

0 commit comments

Comments
 (0)