From a20bef0534e87ce61671940c0e25e1c90318fdad Mon Sep 17 00:00:00 2001 From: Lee Kerley <154285602+ld-kerley@users.noreply.github.com> Date: Wed, 7 Aug 2024 09:00:00 -0700 Subject: [PATCH 1/4] Fix incorrectly transposed matrix for displayp3 colorspaces (#1960) When originally authored the matrix was authored transposed. Further internal testing revealed this to manifest as an undesired shift towards red. --- libraries/cmlib/cmlib_ng.mtlx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/cmlib/cmlib_ng.mtlx b/libraries/cmlib/cmlib_ng.mtlx index f6f844f48e..4ac94c2f7a 100644 --- a/libraries/cmlib/cmlib_ng.mtlx +++ b/libraries/cmlib/cmlib_ng.mtlx @@ -315,7 +315,8 @@ - + @@ -354,7 +355,8 @@ - + From 65dc595340e1595f8ea7d4eaa4bea7d7066299dd Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Wed, 7 Aug 2024 09:00:25 -0700 Subject: [PATCH 2/4] Assign PugiXML to External source folder (#1961) This changelist assigns the PugiXML project to the External source folder, improving clarity in Visual Studio builds. --- source/MaterialXFormat/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/source/MaterialXFormat/CMakeLists.txt b/source/MaterialXFormat/CMakeLists.txt index 2f65ab09b2..d75bbc537c 100644 --- a/source/MaterialXFormat/CMakeLists.txt +++ b/source/MaterialXFormat/CMakeLists.txt @@ -1,4 +1,5 @@ add_subdirectory(External/PugiXML) +set_property(TARGET pugixml PROPERTY FOLDER "External") file(GLOB materialx_source "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp") file(GLOB materialx_headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h*") From 67702daa934d6bb397ec6e540b7dd41bc5c12650 Mon Sep 17 00:00:00 2001 From: Malia Kuo Date: Wed, 7 Aug 2024 13:05:31 -0700 Subject: [PATCH 3/4] Additional improvements to MaterialX Lama nodes (#1955) - Updated LamaGeneralizedSchlick implementation (changed the transmission component from a dielectric BSDF to a generalized schlick BSDF, adjusted implementation of reflectionTint) - Updated LamaSSS and LamaTranslucent (removed LobeName and matte inputs as they are renderer-specific) - Updated default values and help documentation of MaterialX Lama nodes to be consistent with Renderman Lama nodes. --- libraries/bxdf/lama/lama_conductor.mtlx | 18 ++- libraries/bxdf/lama/lama_dielectric.mtlx | 24 ++-- libraries/bxdf/lama/lama_emission.mtlx | 2 +- .../bxdf/lama/lama_generalized_schlick.mtlx | 116 ++++++++---------- libraries/bxdf/lama/lama_iridescence.mtlx | 34 ++++- libraries/bxdf/lama/lama_sheen.mtlx | 2 +- libraries/bxdf/lama/lama_sss.mtlx | 26 ++-- libraries/bxdf/lama/lama_surface.mtlx | 6 +- libraries/bxdf/lama/lama_translucent.mtlx | 4 - .../surfaceshader/lama/lama_conductor.mtlx | 2 +- .../surfaceshader/lama/lama_emission.mtlx | 2 +- .../surfaceshader/lama/lama_iridescence.mtlx | 1 + .../surfaceshader/lama/lama_translucent.mtlx | 2 - 13 files changed, 115 insertions(+), 124 deletions(-) diff --git a/libraries/bxdf/lama/lama_conductor.mtlx b/libraries/bxdf/lama/lama_conductor.mtlx index 07a7b7fcd6..4b6b80f64a 100644 --- a/libraries/bxdf/lama/lama_conductor.mtlx +++ b/libraries/bxdf/lama/lama_conductor.mtlx @@ -3,15 +3,15 @@ - + - @@ -21,7 +21,7 @@ doc="Defines the amount of anisotropy, changing the co-tangent axis roughness from the original value to 1 (or to 0 with a negative value)." /> - @@ -40,13 +40,13 @@ - - + + - - + + @@ -110,8 +110,6 @@ - - diff --git a/libraries/bxdf/lama/lama_dielectric.mtlx b/libraries/bxdf/lama/lama_dielectric.mtlx index 5e98670dd7..eb5509033c 100644 --- a/libraries/bxdf/lama/lama_dielectric.mtlx +++ b/libraries/bxdf/lama/lama_dielectric.mtlx @@ -5,12 +5,12 @@ doc="Color multiplier for external reflection. It should be used with parcimony, as a non-white value breaks physicality." /> - + - + - - + doc="Interior volume absorption color. It is defined as the negative logarithm of the extinction coefficient, with values between 0 and 1, such that the object itself and its shadows are tinted proportionnally. If set to 1, there is no absorption, and if set to 0, the object will be completely opaque. Note that for single scattering to kick in, the value must be inferior to 1. This value will also act as coating color, when this node is used as the top material in a layer node." /> + + doc="Color (aka scattering albedo) of the medium, defines what proportion of the light hitting volumetric particles is scattered around by the phase function (as opposed to just absorbed), for each color channel. Only takes effect if the corresponding channel has a non-null density, in other words if the Absorption Color value for that channel is inferior to 1." /> + doc="Anisotropy of the medium's phase function, ranging from full backward scattering at -1 to forward scattering at 1. Only takes effect if the Scatter Color is non-null." /> @@ -47,8 +47,8 @@ - - + + diff --git a/libraries/bxdf/lama/lama_emission.mtlx b/libraries/bxdf/lama/lama_emission.mtlx index 87da14bd91..3f731442c1 100644 --- a/libraries/bxdf/lama/lama_emission.mtlx +++ b/libraries/bxdf/lama/lama_emission.mtlx @@ -1,7 +1,7 @@ - diff --git a/libraries/bxdf/lama/lama_generalized_schlick.mtlx b/libraries/bxdf/lama/lama_generalized_schlick.mtlx index c8c5f40f5b..fd7c2ade5d 100644 --- a/libraries/bxdf/lama/lama_generalized_schlick.mtlx +++ b/libraries/bxdf/lama/lama_generalized_schlick.mtlx @@ -4,47 +4,41 @@ - + doc="Color multiplier for rays going inside the medium (covers external transmission and internal reflection). It should be used sparingly, as a non-white value breaks physicality. The prefered way to define the color of a dielectric is through the Interior attributes right below." /> + + doc="Index of refraction (often denoted by eta), defining the amount reflected by the surface in the normal direction, and how the rays are bent by refraction. A separate value can be specified for each color channel, if desired." /> - - - + - - + doc="Interior volume absorption color. It is defined as the negative logarithm of the extinction coefficient, with values between 0 and 1, such that the object itself and its shadows are tinted proportionally. If set to 1, there is no absorption, and if set to 0, the object will be completely opaque. Note that for single scattering to kick in, the value must be inferior to 1. This value will also act as coating color, when this node is used as top layer in a stack." /> + + doc="Color (aka scattering albedo) of the medium, defines what proportion of the light hitting volumetric particles is scattered around by the phase function (as opposed to just absorbed), for each color channel. Only takes effect if the corresponding channel has a non-null density, in other words if the Absorption Color value for that channel is inferior to 1." /> + doc="Anisotropy of the medium's phase function, ranging from full backward scattering at -1 to forward scattering at 1. Only takes effect if the Scatter Color is non-null." /> - - - - - - - + @@ -64,25 +58,19 @@ - - - - - + - - - - - + - - - - - - + + + + + + + + @@ -91,30 +79,15 @@ - - - - - - - + - - - + - - - - - - - - - + + - + @@ -156,27 +129,32 @@ - - + + - - + + + - - + + + + + + - + - - + + @@ -184,10 +162,14 @@ + + + + - + diff --git a/libraries/bxdf/lama/lama_iridescence.mtlx b/libraries/bxdf/lama/lama_iridescence.mtlx index 914f70ae1b..aaf3617965 100644 --- a/libraries/bxdf/lama/lama_iridescence.mtlx +++ b/libraries/bxdf/lama/lama_iridescence.mtlx @@ -5,13 +5,17 @@ doc="Micro-facet distribution roughness." /> - + + - - - @@ -53,6 +57,27 @@ + + + + + + + + + + + + + + + + /> + + + + + @@ -66,6 +91,7 @@ + diff --git a/libraries/bxdf/lama/lama_sheen.mtlx b/libraries/bxdf/lama/lama_sheen.mtlx index 76c7b9597d..8accb41837 100644 --- a/libraries/bxdf/lama/lama_sheen.mtlx +++ b/libraries/bxdf/lama/lama_sheen.mtlx @@ -4,7 +4,7 @@ + doc="Roughness of the sheen effect. Very rough sheen can be used to create a rough diffuse look (when combined with a diffuse node by a layer or mix)." /> diff --git a/libraries/bxdf/lama/lama_sss.mtlx b/libraries/bxdf/lama/lama_sss.mtlx index ded26871ff..f09d2da51d 100644 --- a/libraries/bxdf/lama/lama_sss.mtlx +++ b/libraries/bxdf/lama/lama_sss.mtlx @@ -6,39 +6,29 @@ - + doc="Diffuse Mean Free Path, expressed for each color channel in mm. Indicates on average how much the light travels under the surface before being scattered. The higher the value, the softer the result will be. If zero (black), which is the default value, the computation simplifies to a Lambertian reflection lobe with no subsurface scattering." /> + - + - + doc="Controls how strongly normals are considered in the subsurface computation. For path-traced sss (sssMode 0 and 1), the followTopology parameter reduces sss paths being blocked by backsides behind a surface, but also reduces sss from one side to another in convex regions such as ridges and ears. For diffusion sss (sssMode 2 and 3), the followTopology parameter reduces sss from one side to another in concave regions such as crevasses and wrinkles." /> + doc="This is the multiplier that converts between millimeters and scene units. Both mean free path and diffuse mean free path are specified in millimeters and this parameter is used for the unit conversion. The default value of 0.00328 converts millimeters to feet. For centimeter scene units, this would be 0.1, for meters it would be 0.001 etc." /> - - - - - diff --git a/libraries/bxdf/lama/lama_surface.mtlx b/libraries/bxdf/lama/lama_surface.mtlx index 4ffa9a63df..b7e84a510c 100644 --- a/libraries/bxdf/lama/lama_surface.mtlx +++ b/libraries/bxdf/lama/lama_surface.mtlx @@ -2,11 +2,11 @@ + doc="Material used on the front side (as defined by the geometric normal)." /> + doc="Material used on the back side (as defined by the geometric normal)." /> + doc="Connect a mask here to apply a cutout pattern to your object. This is useful for cutouts like creating leaves and other thin, complex shapes. It can also be used as opacity for gray values for semi-opaque results when seen directly by the camera." /> diff --git a/libraries/bxdf/lama/lama_translucent.mtlx b/libraries/bxdf/lama/lama_translucent.mtlx index 9577e9c14f..ec3e968e09 100644 --- a/libraries/bxdf/lama/lama_translucent.mtlx +++ b/libraries/bxdf/lama/lama_translucent.mtlx @@ -9,10 +9,6 @@ doc="Shading normal, typically defined by bump or normal mapping. Defaults to the smooth surface normal if not set." /> - - diff --git a/resources/Materials/TestSuite/pbrlib/surfaceshader/lama/lama_conductor.mtlx b/resources/Materials/TestSuite/pbrlib/surfaceshader/lama/lama_conductor.mtlx index ee0852899f..87cc8211e7 100644 --- a/resources/Materials/TestSuite/pbrlib/surfaceshader/lama/lama_conductor.mtlx +++ b/resources/Materials/TestSuite/pbrlib/surfaceshader/lama/lama_conductor.mtlx @@ -8,7 +8,7 @@ - + diff --git a/resources/Materials/TestSuite/pbrlib/surfaceshader/lama/lama_emission.mtlx b/resources/Materials/TestSuite/pbrlib/surfaceshader/lama/lama_emission.mtlx index cae5722d1f..f21d752d20 100644 --- a/resources/Materials/TestSuite/pbrlib/surfaceshader/lama/lama_emission.mtlx +++ b/resources/Materials/TestSuite/pbrlib/surfaceshader/lama/lama_emission.mtlx @@ -3,7 +3,7 @@ - + diff --git a/resources/Materials/TestSuite/pbrlib/surfaceshader/lama/lama_iridescence.mtlx b/resources/Materials/TestSuite/pbrlib/surfaceshader/lama/lama_iridescence.mtlx index a6bc228773..1125e34aa7 100644 --- a/resources/Materials/TestSuite/pbrlib/surfaceshader/lama/lama_iridescence.mtlx +++ b/resources/Materials/TestSuite/pbrlib/surfaceshader/lama/lama_iridescence.mtlx @@ -5,6 +5,7 @@ + diff --git a/resources/Materials/TestSuite/pbrlib/surfaceshader/lama/lama_translucent.mtlx b/resources/Materials/TestSuite/pbrlib/surfaceshader/lama/lama_translucent.mtlx index a5d9b80bc3..3b7fa03988 100644 --- a/resources/Materials/TestSuite/pbrlib/surfaceshader/lama/lama_translucent.mtlx +++ b/resources/Materials/TestSuite/pbrlib/surfaceshader/lama/lama_translucent.mtlx @@ -6,8 +6,6 @@ - - From 67d2e2836fb3d7aee4ddd3cea273a9f85f82725a Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Thu, 8 Aug 2024 13:46:56 -0700 Subject: [PATCH 4/4] Fix Fresnel computation in GLSL transmission (#1962) This changelist fixes an error in the Fresnel computation for GLSL transmission, improving the visual parity of transmissive materials across shading languages. With this fix in place, the graph definition of LamaGeneralizedSchlick no longer requires a manual inversion of its F0 and F90 inputs for transmission, as this inversion is handled correctly in GLSL as well as OSL and MDL. --- .../bxdf/lama/lama_generalized_schlick.mtlx | 12 +---- .../genglsl/lib/mx_environment_fis.glsl | 4 +- .../genglsl/mx_generalized_schlick_bsdf.glsl | 2 +- .../pbrlib/bsdf/generalized_schlick.mtlx | 54 +++++++------------ 4 files changed, 24 insertions(+), 48 deletions(-) diff --git a/libraries/bxdf/lama/lama_generalized_schlick.mtlx b/libraries/bxdf/lama/lama_generalized_schlick.mtlx index fd7c2ade5d..887273de45 100644 --- a/libraries/bxdf/lama/lama_generalized_schlick.mtlx +++ b/libraries/bxdf/lama/lama_generalized_schlick.mtlx @@ -63,14 +63,6 @@ - - - - - - - - @@ -132,8 +124,8 @@ - - + + diff --git a/libraries/pbrlib/genglsl/lib/mx_environment_fis.glsl b/libraries/pbrlib/genglsl/lib/mx_environment_fis.glsl index 0b28f3645f..1d61576650 100644 --- a/libraries/pbrlib/genglsl/lib/mx_environment_fis.glsl +++ b/libraries/pbrlib/genglsl/lib/mx_environment_fis.glsl @@ -43,8 +43,8 @@ vec3 mx_environment_radiance(vec3 N, vec3 V, vec3 X, vec2 alpha, int distributio // Compute the geometric term. float G = mx_ggx_smith_G2(NdotL, NdotV, avgAlpha); - // Compute the combined FG term, which is inverted for refraction. - vec3 FG = fd.refraction ? vec3(1.0) - (F * G) : F * G; + // Compute the combined FG term, which simplifies to inverted Fresnel for refraction. + vec3 FG = fd.refraction ? vec3(1.0) - F : F * G; // Add the radiance contribution of this sample. // From https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf diff --git a/libraries/pbrlib/genglsl/mx_generalized_schlick_bsdf.glsl b/libraries/pbrlib/genglsl/mx_generalized_schlick_bsdf.glsl index 764412b90d..f4598dd0d0 100644 --- a/libraries/pbrlib/genglsl/mx_generalized_schlick_bsdf.glsl +++ b/libraries/pbrlib/genglsl/mx_generalized_schlick_bsdf.glsl @@ -66,7 +66,7 @@ void mx_generalized_schlick_bsdf_transmission(vec3 V, float weight, vec3 color0, { float avgF0 = dot(safeColor0, vec3(1.0 / 3.0)); fd.ior = vec3(mx_f0_to_ior(avgF0)); - bsdf.response = mx_surface_transmission(N, V, X, safeAlpha, distribution, fd, safeColor0) * weight; + bsdf.response = mx_surface_transmission(N, V, X, safeAlpha, distribution, fd, vec3(1.0)) * weight; } } diff --git a/resources/Materials/TestSuite/pbrlib/bsdf/generalized_schlick.mtlx b/resources/Materials/TestSuite/pbrlib/bsdf/generalized_schlick.mtlx index 05eb071558..bc31308a47 100644 --- a/resources/Materials/TestSuite/pbrlib/bsdf/generalized_schlick.mtlx +++ b/resources/Materials/TestSuite/pbrlib/bsdf/generalized_schlick.mtlx @@ -2,11 +2,8 @@ - - - - - + + @@ -15,11 +12,8 @@ - - - - - + + @@ -28,11 +22,8 @@ - - - - - + + @@ -50,11 +41,9 @@ - - - - - + + + @@ -63,11 +52,9 @@ - - - - - + + + @@ -76,11 +63,9 @@ - - - - - + + + @@ -98,11 +83,10 @@ - - - - - + + + +