|
@@ -205,6 +205,7 @@ void main(void) {
|
|
|
vec3 baseColor = surfaceAlbedo;
|
|
|
|
|
|
#ifdef REFLECTANCE
|
|
|
+ // *** NOT USED ANYMORE ***
|
|
|
// Following Frostbite Remapping,
|
|
|
// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf page 115
|
|
|
// vec3 f0 = 0.16 * reflectance * reflectance * (1.0 - metallic) + baseColor * metallic;
|
|
@@ -551,10 +552,17 @@ void main(void) {
|
|
|
#ifdef SHEEN_TEXTURE
|
|
|
sheenColor.rgb *= toLinearSpace(sheenMapData.rgb);
|
|
|
#endif
|
|
|
- float sheenRoughness = roughness;
|
|
|
+
|
|
|
+ #ifdef SHEEN_ROUGHNESS
|
|
|
+ float sheenRoughness = vSheenRoughness;
|
|
|
+ #else
|
|
|
+ float sheenRoughness = roughness;
|
|
|
+ #endif
|
|
|
|
|
|
// Sheen Lobe Layering.
|
|
|
- sheenIntensity *= (1. - reflectance);
|
|
|
+ #if !defined(SHEEN_ALBEDOSCALING)
|
|
|
+ sheenIntensity *= (1. - reflectance);
|
|
|
+ #endif
|
|
|
|
|
|
// Remap F0 and sheen.
|
|
|
sheenColor *= sheenIntensity;
|
|
@@ -886,8 +894,17 @@ void main(void) {
|
|
|
#endif
|
|
|
|
|
|
// _____________________________ Sheen Environment Oclusion __________________________
|
|
|
- #if defined(SHEEN) && defined(REFLECTION)
|
|
|
- vec3 sheenEnvironmentReflectance = getSheenReflectanceFromBRDFLookup(sheenColor, environmentBrdf);
|
|
|
+ #if defined(SHEEN) && defined(ENVIRONMENTBRDF)
|
|
|
+ /*#ifdef SHEEN_SOFTER
|
|
|
+ vec3 environmentSheenBrdf = vec3(0., 0., getBRDFLookupCharlieSheen(NdotV, sheenRoughness));
|
|
|
+ #else*/
|
|
|
+ #ifdef SHEEN_ROUGHNESS
|
|
|
+ vec3 environmentSheenBrdf = getBRDFLookup(NdotV, sheenRoughness);
|
|
|
+ #else
|
|
|
+ vec3 environmentSheenBrdf = environmentBrdf;
|
|
|
+ #endif
|
|
|
+ /*#endif*/
|
|
|
+ vec3 sheenEnvironmentReflectance = getSheenReflectanceFromBRDFLookup(sheenColor, environmentSheenBrdf);
|
|
|
|
|
|
#ifdef RADIANCEOCCLUSION
|
|
|
sheenEnvironmentReflectance *= seo;
|
|
@@ -900,6 +917,13 @@ void main(void) {
|
|
|
#endif
|
|
|
#endif
|
|
|
#endif
|
|
|
+
|
|
|
+ #if defined(SHEEN_ALBEDOSCALING)
|
|
|
+ // Sheen Lobe Layering.
|
|
|
+ // environmentSheenBrdf.b is (integral on hemisphere)[f_sheen*cos(theta)*dtheta*dphi], which happens to also be the directional albedo needed for albedo scaling.
|
|
|
+ // See section 6.2.3 in https://dassaultsystemes-technology.github.io/EnterprisePBRShadingModel/spec-2021x.md.html#components/sheen
|
|
|
+ float sheenAlbedoScaling = 1.0 - sheenIntensity * max(max(sheenColor.r, sheenColor.g), sheenColor.b) * environmentSheenBrdf.b;
|
|
|
+ #endif
|
|
|
#endif
|
|
|
|
|
|
// _________________________ Clear Coat Environment Oclusion __________________________
|
|
@@ -935,10 +959,10 @@ void main(void) {
|
|
|
|
|
|
#ifdef REFLECTION
|
|
|
environmentIrradiance *= absorption;
|
|
|
+ #endif
|
|
|
|
|
|
- #ifdef SHEEN
|
|
|
- sheenEnvironmentReflectance *= absorption;
|
|
|
- #endif
|
|
|
+ #if defined(SHEEN) && defined(ENVIRONMENTBRDF)
|
|
|
+ sheenEnvironmentReflectance *= absorption;
|
|
|
#endif
|
|
|
|
|
|
specularEnvironmentReflectance *= absorption;
|
|
@@ -952,10 +976,10 @@ void main(void) {
|
|
|
|
|
|
#ifdef REFLECTION
|
|
|
environmentIrradiance *= conservationFactor;
|
|
|
+ #endif
|
|
|
|
|
|
- #ifdef SHEEN
|
|
|
- sheenEnvironmentReflectance *= conservationFactor;
|
|
|
- #endif
|
|
|
+ #if defined(SHEEN) && defined(ENVIRONMENTBRDF)
|
|
|
+ sheenEnvironmentReflectance *= conservationFactor;
|
|
|
#endif
|
|
|
|
|
|
specularEnvironmentReflectance *= conservationFactor;
|
|
@@ -1040,6 +1064,10 @@ void main(void) {
|
|
|
#endif
|
|
|
#endif
|
|
|
|
|
|
+ #if defined(SHEEN) && defined(SHEEN_ALBEDOSCALING) && defined(ENVIRONMENTBRDF)
|
|
|
+ surfaceAlbedo.rgb = sheenAlbedoScaling * surfaceAlbedo.rgb;
|
|
|
+ #endif
|
|
|
+
|
|
|
// _____________________________ Irradiance ______________________________________
|
|
|
#ifdef REFLECTION
|
|
|
vec3 finalIrradiance = environmentIrradiance;
|
|
@@ -1059,6 +1087,10 @@ void main(void) {
|
|
|
#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
|
|
|
finalSpecularScaled *= energyConservationFactor;
|
|
|
#endif
|
|
|
+
|
|
|
+ #if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
|
|
|
+ finalSpecularScaled *= sheenAlbedoScaling;
|
|
|
+ #endif
|
|
|
#endif
|
|
|
|
|
|
// _____________________________ Radiance ________________________________________
|
|
@@ -1071,6 +1103,10 @@ void main(void) {
|
|
|
#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
|
|
|
finalRadianceScaled *= energyConservationFactor;
|
|
|
#endif
|
|
|
+
|
|
|
+ #if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
|
|
|
+ finalRadianceScaled *= sheenAlbedoScaling;
|
|
|
+ #endif
|
|
|
#endif
|
|
|
|
|
|
// _____________________________ Refraction ______________________________________
|
|
@@ -1079,6 +1115,27 @@ void main(void) {
|
|
|
finalRefraction *= refractionTransmittance;
|
|
|
#endif
|
|
|
|
|
|
+ // ________________________________ Sheen ________________________________________
|
|
|
+ #ifdef SHEEN
|
|
|
+ vec3 finalSheen = sheenBase * sheenColor;
|
|
|
+ finalSheen = max(finalSheen, 0.0);
|
|
|
+
|
|
|
+ vec3 finalSheenScaled = finalSheen * vLightingIntensity.x * vLightingIntensity.w;
|
|
|
+ // #if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
|
|
|
+ // The sheen does not use the same BRDF so not energy conservation is possible
|
|
|
+ // Should be less a problem as it is usually not metallic
|
|
|
+ // finalSheenScaled *= energyConservationFactor;
|
|
|
+ // #endif
|
|
|
+
|
|
|
+ #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
|
|
|
+ vec3 finalSheenRadiance = environmentSheenRadiance.rgb;
|
|
|
+ finalSheenRadiance *= sheenEnvironmentReflectance;
|
|
|
+
|
|
|
+ // Full value needed for alpha.
|
|
|
+ vec3 finalSheenRadianceScaled = finalSheenRadiance * vLightingIntensity.z;
|
|
|
+ #endif
|
|
|
+ #endif
|
|
|
+
|
|
|
// _____________________________ Clear Coat _______________________________________
|
|
|
#ifdef CLEARCOAT
|
|
|
vec3 finalClearCoat = clearCoatBase;
|
|
@@ -1107,27 +1164,6 @@ void main(void) {
|
|
|
#endif
|
|
|
#endif
|
|
|
|
|
|
- // ________________________________ Sheen ________________________________________
|
|
|
- #ifdef SHEEN
|
|
|
- vec3 finalSheen = sheenBase * sheenColor;
|
|
|
- finalSheen = max(finalSheen, 0.0);
|
|
|
-
|
|
|
- vec3 finalSheenScaled = finalSheen * vLightingIntensity.x * vLightingIntensity.w;
|
|
|
- // #if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
|
|
|
- // The sheen does not use the same BRDF so not energy conservation is possible
|
|
|
- // Should be less a problem as it is usually not metallic
|
|
|
- // finalSheenScaled *= energyConservationFactor;
|
|
|
- // #endif
|
|
|
-
|
|
|
- #ifdef REFLECTION
|
|
|
- vec3 finalSheenRadiance = environmentSheenRadiance.rgb;
|
|
|
- finalSheenRadiance *= sheenEnvironmentReflectance;
|
|
|
-
|
|
|
- // Full value needed for alpha.
|
|
|
- vec3 finalSheenRadianceScaled = finalSheenRadiance * vLightingIntensity.z;
|
|
|
- #endif
|
|
|
- #endif
|
|
|
-
|
|
|
// _____________________________ Highlights on Alpha _____________________________
|
|
|
#ifdef ALPHABLEND
|
|
|
float luminanceOverAlpha = 0.0;
|
|
@@ -1192,30 +1228,30 @@ void main(void) {
|
|
|
// finalSpecular * vLightingIntensity.x * vLightingIntensity.w +
|
|
|
finalSpecularScaled +
|
|
|
#endif
|
|
|
- #ifdef CLEARCOAT
|
|
|
- // Computed in the previous step to help with alpha luminance.
|
|
|
- // finalClearCoat * vLightingIntensity.x * vLightingIntensity.w +
|
|
|
- finalClearCoatScaled +
|
|
|
- #endif
|
|
|
#ifdef SHEEN
|
|
|
// Computed in the previous step to help with alpha luminance.
|
|
|
// finalSheen * vLightingIntensity.x * vLightingIntensity.w +
|
|
|
finalSheenScaled +
|
|
|
#endif
|
|
|
+ #ifdef CLEARCOAT
|
|
|
+ // Computed in the previous step to help with alpha luminance.
|
|
|
+ // finalClearCoat * vLightingIntensity.x * vLightingIntensity.w +
|
|
|
+ finalClearCoatScaled +
|
|
|
+ #endif
|
|
|
#ifdef REFLECTION
|
|
|
// Comupted in the previous step to help with alpha luminance.
|
|
|
// finalRadiance * vLightingIntensity.z +
|
|
|
finalRadianceScaled +
|
|
|
+ #if defined(SHEEN) && defined(ENVIRONMENTBRDF)
|
|
|
+ // Comupted in the previous step to help with alpha luminance.
|
|
|
+ // finalSheenRadiance * vLightingIntensity.z
|
|
|
+ finalSheenRadianceScaled +
|
|
|
+ #endif
|
|
|
#ifdef CLEARCOAT
|
|
|
// Comupted in the previous step to help with alpha luminance.
|
|
|
// finalClearCoatRadiance * vLightingIntensity.z
|
|
|
finalClearCoatRadianceScaled +
|
|
|
#endif
|
|
|
- #ifdef SHEEN
|
|
|
- // Comupted in the previous step to help with alpha luminance.
|
|
|
- // finalSheenRadiance * vLightingIntensity.z
|
|
|
- finalSheenRadianceScaled +
|
|
|
- #endif
|
|
|
#endif
|
|
|
#ifdef SS_REFRACTION
|
|
|
finalRefraction * vLightingIntensity.z +
|