From 1bd3a426e866ac286e9a0270117a4ebe513dda37 Mon Sep 17 00:00:00 2001 From: Niklas Harrysson Date: Wed, 24 Mar 2021 00:02:24 +0100 Subject: [PATCH 01/15] Added initial draft for OSL closures --- libraries/stdlib/osl/stdosl.h | 162 ++++++++++++++++++++++++++++++++++ 1 file changed, 162 insertions(+) diff --git a/libraries/stdlib/osl/stdosl.h b/libraries/stdlib/osl/stdosl.h index 6254476b93..9d383cc375 100644 --- a/libraries/stdlib/osl/stdosl.h +++ b/libraries/stdlib/osl/stdosl.h @@ -573,6 +573,168 @@ closure color volume_matte() BUILTIN; closure color subsurface(float eta, float g, color mfp, color albedo) BUILTIN; #endif +// ******************* MATERIALX PBS LIBRARY CLOSURES - DRAFT BEGIN ******************* // + +// -------------------------------------------------------------// +// BSDF closures // +// -------------------------------------------------------------// +​ +// Constructs a diffuse reflection BSDF based on the Oren-Nayar reflectance model. +// A roughness of 0.0 gives Lambertian reflectance. +// +closure color oren_nayar_diffuse_bsdf(normal N, color albedo, float roughness) BUILTIN; +​ +// Constructs a diffuse reflection BSDF based on the corresponding component of +// the Disney Principled shading model. +// +closure color burley_diffuse_bsdf(normal N, color albedo, float roughness) BUILTIN; +​ +// Constructs a reflection and/or transmission BSDF based on a microfacet reflectance +// model and a Fresnel curve for dielectrics. The two tint parameters control the +// contribution of each reflection/transmission lobe. The tints should remain 100% white +// for a physically correct dielectric, but can be tweaked for artistic control or set +// to 0.0 for disabling a lobe. +// The closure may be vertically layered over a base BSDF for the surface beneath the +// dielectric layer. By chaining multiple dielectric_bsdf closures you can describe a surface +// with multiple specular lobes. If transmission is enabled (transmission_tint > 0.0) the +// closure may be layered over a VDF closure describing the surface interior to handle +// absorption and scattering inside the medium. +// +closure color dielectric_bsdf(normal N, vector U, color reflection_tint, color transmission_tint, float roughness_x, float roughness_y, float ior, string distribution) BUILTIN; +​ +// Constructs a reflection BSDF based on a microfacet reflectance model. +// Uses a Fresnel curve with complex refraction index for conductors/metals. +// If an artistic parametrization is preferred the artistic_ior() utility function +// can be used to convert from artistic to physical parameters. +// +closure color conductor_bsdf(normal N, vector U, float roughness_x, float roughness_y, color ior, color extinction, string distribution) BUILTIN; +​ +// Constructs a reflection and/or transmission BSDF based on a microfacet reflectance model +// and a generalized Schlick Fresnel curve. The two tint parameters control the contribution +// of each reflection/transmission lobe. +// The closure may be vertically layered over a base BSDF for the surface beneath the +// dielectric layer. By chaining multiple dielectric_bsdf closures you can describe a surface +// with multiple specular lobes. If transmission is enabled (transmission_tint > 0.0) the +// closure may be layered over a VDF closure describing the surface interior to handle +// absorption and scattering inside the medium. +// +// TODO: +// - Transmission handling for this node has not been fully defined yet in MaterialX. +// In particular how is IOR for refractions derived from the f0, f90 parameterization? +// Do we just derive it from f0? For an artist it seems hard to control refractions that way. +// @Jonathan Stone you mentioned Lucasfilm (Naty Hoffman) had some feedback and ideas for how to handle this? +// +closure color generalized_schlick_bsdf(normal N, vector U, color reflection_tint, color transmission_tint, float roughness_x, float roughness_y, color f0, color f90, float exponent, string distribution) BUILTIN; +​ +// Constructs a translucent (diffuse transmission) BSDF based on the Lambert reflectance model. +// +closure color translucent_bsdf(normal N, color albedo) BUILTIN; + +// Constructs a closure that represents straight transmission through a surface. +// +// NOTE: +// - This is not a node in the MaterialX library, but the surface shader constructor +// node has an 'opacity' parameter to control textured cutout opacity. +// +closure color transparent_bsdf() BUILTIN; +​ +// Constructs a BSSRDF for subsurface scattering within a homogeneous medium. +// +// TODO: +// - Do we want/need this dedicated BSSRDF closure? We have had discussions before about +// describing this more rigorously as a BSDF layered over a VDF instead. +// In the MaterialX library we want this as a node for the user friendly interface, +// but for back-end implementation maybe a dedicated closure is not needed? +// +closure color subsurface_bssrdf(normal N, color albedo, color radius, float anisotropy) BUILTIN; +​ +// Constructs a microfacet BSDF for the back-scattering properties of cloth-like materials. +// This closure may be vertically layered over a base BSDF, where energy that is not reflected +// will be transmitted to the base closure. +// +closure color sheen_bsdf(normal N, color albedo, float roughness) BUILTIN; +​ +// Adds an iridescent thin film layer over a microfacet base BSDF. This must be layered over +// another base BSDF using the layer() closure, as this is a modifier and cannot be used as a +// standalone closure. +// +// TODO: +// - This might be better to represent as optional extra arguments on the closures that do support +// thin-film iridescence (dielectric_bsdf, conductor_bsdf and generalized_schlick_bsdf)? +// +closure color thin_film_bsdf(float thickness, float ior) BUILTIN; +​ +​ +// -------------------------------------------------------------// +// EDF closures // +// -------------------------------------------------------------// +​ +// Constructs an EDF emitting light uniformly in all directions. +// +closure color uniform_edf(color emittance) BUILTIN; + +// Constructs an EDF emitting light inside a code around the normal direction. +// +closure color conical_edf(color emittance, normal N, float inner_angle, float outer_angle) BUILTIN; + +// Constructs an EDF emitting light according to a measured IES light profile. +// +closure color measured_edf(color emittance, normal N, string file) BUILTIN; +​ +​ +// -------------------------------------------------------------// +// VDF closures // +// -------------------------------------------------------------// +​ +// Constructs a VDF for pure volumetric absorption. +// +closure color absorption_vdf(color absorption) BUILTIN; +​ +// Constructs a VDF scattering light for a participating medium, based on the Henyey-Greenstein +// phase function. Forward, backward and uniform scattering is supported and controlled by the +// anisotropy input. +// +closure color anisotropic_vdf(color absorption, color scattering, float anisotropy) BUILTIN; +​ +​ +// -------------------------------------------------------------// +// Layering closures // +// -------------------------------------------------------------// +​ +// Vertically layer a layerable BSDF such as dielectric_bsdf, generalized_schlick_bsdf or +// sheen_bsdf over a BSDF or VDF. The implementation is target specific, but a standard way +// of handling this is by albedo scaling, using "base*(1-reflectance(top)) + top", where +// reflectance() calculates the directional albedo of a given top BSDF. +// +// TODO: +// - This could also be achived by closure nesting where each layerable closure takes +// a closure color "base" input instead. +// - One advantage having a dedicated layer() closure is that in the future we may want to +// introduce parameters to describe the sandwitched medium between the layer interfaces. +// Such parameterization could then be added on this layer() closure as extra arguments. +// - Do we want/need parameters for the medium here now, or do we look at that later? +// +closure color layer(closure color top, closure color base) BUILTIN; +​ +// Mix two closures according to a weight. Performs horizontal layering by linear interpolation +// between the two inputs: "bg∗(1−weight) + fg∗weight". +// +closure color mix(closure color bg, closure color fg, float weight); +​ +​ +// -------------------------------------------------------------// +// Utility functions // +// -------------------------------------------------------------// +​ +// Converts the artistic parameterization reflectivity and edge_color to complex IOR values. +// To be used with the conductor_bsdf() closure. +// +void artistic_ior(color reflectivity, color edge_color, output color ior, output color extinction); +​ + +// ******************* MATERIALX PBS LIBRARY CLOSURES - DRAFT END ******************* // + + // Renderer state int backfacing () BUILTIN; int raytype (string typename) BUILTIN; From 7c3c87514b055fc0e85a202535e25db7772705e8 Mon Sep 17 00:00:00 2001 From: Niklas Harrysson Date: Wed, 24 Mar 2021 00:40:14 +0100 Subject: [PATCH 02/15] Fix typos and some clarifications --- libraries/stdlib/osl/stdosl.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/libraries/stdlib/osl/stdosl.h b/libraries/stdlib/osl/stdosl.h index 9d383cc375..c2c854c20f 100644 --- a/libraries/stdlib/osl/stdosl.h +++ b/libraries/stdlib/osl/stdosl.h @@ -595,10 +595,11 @@ closure color burley_diffuse_bsdf(normal N, color albedo, float roughness) BUILT // for a physically correct dielectric, but can be tweaked for artistic control or set // to 0.0 for disabling a lobe. // The closure may be vertically layered over a base BSDF for the surface beneath the -// dielectric layer. By chaining multiple dielectric_bsdf closures you can describe a surface -// with multiple specular lobes. If transmission is enabled (transmission_tint > 0.0) the -// closure may be layered over a VDF closure describing the surface interior to handle -// absorption and scattering inside the medium. +// dielectric layer. This is done using the layer() closure. By chaining multiple +// dielectric_bsdf closures you can describe a surface with multiple specular lobes. +// If transmission is enabled (transmission_tint > 0.0) the closure may be layered over +// a VDF closure describing the surface interior to handle absorption and scattering +// inside the medium. // closure color dielectric_bsdf(normal N, vector U, color reflection_tint, color transmission_tint, float roughness_x, float roughness_y, float ior, string distribution) BUILTIN; ​ @@ -613,16 +614,16 @@ closure color conductor_bsdf(normal N, vector U, float roughness_x, float roughn // and a generalized Schlick Fresnel curve. The two tint parameters control the contribution // of each reflection/transmission lobe. // The closure may be vertically layered over a base BSDF for the surface beneath the -// dielectric layer. By chaining multiple dielectric_bsdf closures you can describe a surface -// with multiple specular lobes. If transmission is enabled (transmission_tint > 0.0) the -// closure may be layered over a VDF closure describing the surface interior to handle -// absorption and scattering inside the medium. +// dielectric layer. This is done using the layer() closure. By chaining multiple +// dielectric_bsdf closures you can describe a surface with multiple specular lobes. +// If transmission is enabled (transmission_tint > 0.0) the closure may be layered over +// a VDF closure describing the surface interior to handle absorption and scattering +// inside the medium. // // TODO: // - Transmission handling for this node has not been fully defined yet in MaterialX. // In particular how is IOR for refractions derived from the f0, f90 parameterization? // Do we just derive it from f0? For an artist it seems hard to control refractions that way. -// @Jonathan Stone you mentioned Lucasfilm (Naty Hoffman) had some feedback and ideas for how to handle this? // closure color generalized_schlick_bsdf(normal N, vector U, color reflection_tint, color transmission_tint, float roughness_x, float roughness_y, color f0, color f90, float exponent, string distribution) BUILTIN; ​ @@ -673,7 +674,7 @@ closure color thin_film_bsdf(float thickness, float ior) BUILTIN; // closure color uniform_edf(color emittance) BUILTIN; -// Constructs an EDF emitting light inside a code around the normal direction. +// Constructs an EDF emitting light inside a cone around the normal direction. // closure color conical_edf(color emittance, normal N, float inner_angle, float outer_angle) BUILTIN; From 743f74bc2e43bfc7a782b5056d817c73e9aff628 Mon Sep 17 00:00:00 2001 From: Niklas Harrysson Date: Sun, 11 Apr 2021 12:19:25 +0200 Subject: [PATCH 03/15] Remove closure mix() since it already exists in OSL --- libraries/stdlib/osl/stdosl.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libraries/stdlib/osl/stdosl.h b/libraries/stdlib/osl/stdosl.h index c2c854c20f..349fe953a3 100644 --- a/libraries/stdlib/osl/stdosl.h +++ b/libraries/stdlib/osl/stdosl.h @@ -716,11 +716,8 @@ closure color anisotropic_vdf(color absorption, color scattering, float anisotro // - Do we want/need parameters for the medium here now, or do we look at that later? // closure color layer(closure color top, closure color base) BUILTIN; -​ -// Mix two closures according to a weight. Performs horizontal layering by linear interpolation -// between the two inputs: "bg∗(1−weight) + fg∗weight". -// -closure color mix(closure color bg, closure color fg, float weight); + +// NOTE: For "horisontal layering" closure mix() already exists in OSL. ​ ​ // -------------------------------------------------------------// From 33c22e5a71ff7b6cafa007e8202e4abda1ea8b8d Mon Sep 17 00:00:00 2001 From: Niklas Harrysson Date: Sun, 11 Apr 2021 12:22:25 +0200 Subject: [PATCH 04/15] Remove measured_edf as it's not practically useful in OSL --- libraries/stdlib/osl/stdosl.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libraries/stdlib/osl/stdosl.h b/libraries/stdlib/osl/stdosl.h index 349fe953a3..89019911df 100644 --- a/libraries/stdlib/osl/stdosl.h +++ b/libraries/stdlib/osl/stdosl.h @@ -677,10 +677,6 @@ closure color uniform_edf(color emittance) BUILTIN; // Constructs an EDF emitting light inside a cone around the normal direction. // closure color conical_edf(color emittance, normal N, float inner_angle, float outer_angle) BUILTIN; - -// Constructs an EDF emitting light according to a measured IES light profile. -// -closure color measured_edf(color emittance, normal N, string file) BUILTIN; ​ ​ // -------------------------------------------------------------// From a8073dd043b0d183dad56966160e66f291fe15ee Mon Sep 17 00:00:00 2001 From: Niklas Harrysson Date: Sun, 11 Apr 2021 12:25:12 +0200 Subject: [PATCH 05/15] Remove absorption_vdf as it's just a subset of anisotropic_vdf --- libraries/stdlib/osl/stdosl.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libraries/stdlib/osl/stdosl.h b/libraries/stdlib/osl/stdosl.h index 89019911df..b75b4de755 100644 --- a/libraries/stdlib/osl/stdosl.h +++ b/libraries/stdlib/osl/stdosl.h @@ -683,10 +683,6 @@ closure color conical_edf(color emittance, normal N, float inner_angle, float ou // VDF closures // // -------------------------------------------------------------// ​ -// Constructs a VDF for pure volumetric absorption. -// -closure color absorption_vdf(color absorption) BUILTIN; -​ // Constructs a VDF scattering light for a participating medium, based on the Henyey-Greenstein // phase function. Forward, backward and uniform scattering is supported and controlled by the // anisotropy input. From 9b6129cbe3e9a3290138a9eb107ccbf7e56ce93b Mon Sep 17 00:00:00 2001 From: Niklas Harrysson Date: Sun, 11 Apr 2021 13:16:11 +0200 Subject: [PATCH 06/15] Update parameterization of subsurface_bssrdf --- libraries/stdlib/osl/stdosl.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libraries/stdlib/osl/stdosl.h b/libraries/stdlib/osl/stdosl.h index b75b4de755..e5ec2adf25 100644 --- a/libraries/stdlib/osl/stdosl.h +++ b/libraries/stdlib/osl/stdosl.h @@ -640,14 +640,15 @@ closure color translucent_bsdf(normal N, color albedo) BUILTIN; closure color transparent_bsdf() BUILTIN; ​ // Constructs a BSSRDF for subsurface scattering within a homogeneous medium. +// \param N Normal of the surface point beeing shaded. +// \param albedo Surface albedo. +// \param sss_depth Mean-free path in units of scene length. +// \param sss_color Scattering color / transmittance. The desired color resulting from white light transmitted a distance of 'sss_depth' +// through the surface. +// \param anisotropy Scattering anisotropy [-1,1]. Negative values give backwards scattering, positive values give forward scattering, +// and 0.0 gives uniform scattering. // -// TODO: -// - Do we want/need this dedicated BSSRDF closure? We have had discussions before about -// describing this more rigorously as a BSDF layered over a VDF instead. -// In the MaterialX library we want this as a node for the user friendly interface, -// but for back-end implementation maybe a dedicated closure is not needed? -// -closure color subsurface_bssrdf(normal N, color albedo, color radius, float anisotropy) BUILTIN; +closure color subsurface_bssrdf(normal N, color albedo, float sss_depth, color sss_color, float anisotropy) BUILTIN; ​ // Constructs a microfacet BSDF for the back-scattering properties of cloth-like materials. // This closure may be vertically layered over a base BSDF, where energy that is not reflected From a932213ccc34d8750080b52e674e8af9c1831331 Mon Sep 17 00:00:00 2001 From: Niklas Harrysson Date: Sun, 11 Apr 2021 13:39:18 +0200 Subject: [PATCH 07/15] Update parameterization of anisotropic_vdf --- libraries/stdlib/osl/stdosl.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libraries/stdlib/osl/stdosl.h b/libraries/stdlib/osl/stdosl.h index e5ec2adf25..4efae0fc0a 100644 --- a/libraries/stdlib/osl/stdosl.h +++ b/libraries/stdlib/osl/stdosl.h @@ -687,8 +687,14 @@ closure color conical_edf(color emittance, normal N, float inner_angle, float ou // Constructs a VDF scattering light for a participating medium, based on the Henyey-Greenstein // phase function. Forward, backward and uniform scattering is supported and controlled by the // anisotropy input. +// \param albedo Volume albedo. +// \param extinction Volume extinction coefficient. +// \param anisotropy Scattering anisotropy [-1,1]. Negative values give backwards scattering, positive values give forward scattering, +// and 0.0 gives uniform scattering. +// \param ior Optional float parameter for refraction index of a homogeneous medium. +// \param priority Optional int parameter for priority of a homogeneous medium (for nested dielectrics). // -closure color anisotropic_vdf(color absorption, color scattering, float anisotropy) BUILTIN; +closure color anisotropic_vdf(color albedo, color extinction, float anisotropy) BUILTIN; ​ ​ // -------------------------------------------------------------// From ad87d938216d34f42dfb3585ef02643229ad7ae7 Mon Sep 17 00:00:00 2001 From: Niklas Harrysson Date: Sun, 11 Apr 2021 14:32:01 +0200 Subject: [PATCH 08/15] Added parameter documentation for all closures --- libraries/stdlib/osl/stdosl.h | 77 +++++++++++++++++++++++++++++++---- 1 file changed, 69 insertions(+), 8 deletions(-) diff --git a/libraries/stdlib/osl/stdosl.h b/libraries/stdlib/osl/stdosl.h index 4efae0fc0a..ebfa03cb9e 100644 --- a/libraries/stdlib/osl/stdosl.h +++ b/libraries/stdlib/osl/stdosl.h @@ -580,13 +580,20 @@ closure color subsurface(float eta, float g, color mfp, color albedo) BUILTIN; // -------------------------------------------------------------// ​ // Constructs a diffuse reflection BSDF based on the Oren-Nayar reflectance model. -// A roughness of 0.0 gives Lambertian reflectance. +// +// \param N Normal vector of the surface point beeing shaded. +// \param albedo Surface albedo. +// \param roughness Surface roughness [0,1]. A value of 0.0 gives Lambertian reflectance. // closure color oren_nayar_diffuse_bsdf(normal N, color albedo, float roughness) BUILTIN; ​ // Constructs a diffuse reflection BSDF based on the corresponding component of // the Disney Principled shading model. // +// \param N Normal vector of the surface point beeing shaded. +// \param albedo Surface albedo. +// \param roughness Surface roughness [0,1]. +// closure color burley_diffuse_bsdf(normal N, color albedo, float roughness) BUILTIN; ​ // Constructs a reflection and/or transmission BSDF based on a microfacet reflectance @@ -601,6 +608,17 @@ closure color burley_diffuse_bsdf(normal N, color albedo, float roughness) BUILT // a VDF closure describing the surface interior to handle absorption and scattering // inside the medium. // +// \param N Normal vector of the surface point beeing shaded. +// \param U Tangent vector of the surface point beeing shaded. +// \param reflection_tint Weight per color channel for the reflection lobe. Should be (1,1,1) for a physically-correct dielectric surface, +// but can be tweaked for artistic control. Set to (0,0,0) to disable reflection. +// \param transmission_tint Weight per color channel for the transmission lobe. Should be (1,1,1) for a physically-correct dielectric surface, +// but can be tweaked for artistic control. Set to (0,0,0) to disable transmission. +// \param roughness_x Surface roughness in the U direction. Valid range [0,1] with a perceptually linear response over the range. +// \param roughness_y Surface roughness in the V direction. Valid range [0,1] with a perceptually linear response over the range. +// \param ior Refraction index. +// \param distribution Microfacet distribution. An implementation is expected to support the following distributions: { "ggx" } +// closure color dielectric_bsdf(normal N, vector U, color reflection_tint, color transmission_tint, float roughness_x, float roughness_y, float ior, string distribution) BUILTIN; ​ // Constructs a reflection BSDF based on a microfacet reflectance model. @@ -608,6 +626,14 @@ closure color dielectric_bsdf(normal N, vector U, color reflection_tint, color t // If an artistic parametrization is preferred the artistic_ior() utility function // can be used to convert from artistic to physical parameters. // +// \param N Normal vector of the surface point beeing shaded. +// \param U Tangent vector of the surface point beeing shaded. +// \param roughness_x Surface roughness in the U direction. Valid range [0,1] with a perceptually linear response over the range. +// \param roughness_y Surface roughness in the V direction. Valid range [0,1] with a perceptually linear response over the range. +// \param ior Refraction index. +// \param extinction Extinction coefficient. +// \param distribution Microfacet distribution. An implementation is expected to support the following distributions: { "ggx" } +// closure color conductor_bsdf(normal N, vector U, float roughness_x, float roughness_y, color ior, color extinction, string distribution) BUILTIN; ​ // Constructs a reflection and/or transmission BSDF based on a microfacet reflectance model @@ -620,15 +646,23 @@ closure color conductor_bsdf(normal N, vector U, float roughness_x, float roughn // a VDF closure describing the surface interior to handle absorption and scattering // inside the medium. // -// TODO: -// - Transmission handling for this node has not been fully defined yet in MaterialX. -// In particular how is IOR for refractions derived from the f0, f90 parameterization? -// Do we just derive it from f0? For an artist it seems hard to control refractions that way. +// \param N Normal vector of the surface point beeing shaded. +// \param U Tangent vector of the surface point beeing shaded. +// \param reflection_tint Weight per color channel for the reflection lobe. Set to (0,0,0) to disable reflection. +// \param transmission_tint Weight per color channel for the transmission lobe. Set to (0,0,0) to disable transmission. +// \param roughness_x Surface roughness in the U direction. Valid range [0,1] with a perceptually linear response over the range. +// \param roughness_y Surface roughness in the V direction. Valid range [0,1] with a perceptually linear response over the range. +// \param f0 Reflectivity per color channel at facing angles. +// \param f90 Reflectivity per color channel at grazing angles. +// \param distribution Microfacet distribution. An implementation is expected to support the following distributions: { "ggx" } // closure color generalized_schlick_bsdf(normal N, vector U, color reflection_tint, color transmission_tint, float roughness_x, float roughness_y, color f0, color f90, float exponent, string distribution) BUILTIN; ​ // Constructs a translucent (diffuse transmission) BSDF based on the Lambert reflectance model. // +// \param N Normal vector of the surface point beeing shaded. +// \param albedo Surface albedo. +// closure color translucent_bsdf(normal N, color albedo) BUILTIN; // Constructs a closure that represents straight transmission through a surface. @@ -640,7 +674,8 @@ closure color translucent_bsdf(normal N, color albedo) BUILTIN; closure color transparent_bsdf() BUILTIN; ​ // Constructs a BSSRDF for subsurface scattering within a homogeneous medium. -// \param N Normal of the surface point beeing shaded. +// +// \param N Normal vector of the surface point beeing shaded. // \param albedo Surface albedo. // \param sss_depth Mean-free path in units of scene length. // \param sss_color Scattering color / transmittance. The desired color resulting from white light transmitted a distance of 'sss_depth' @@ -654,6 +689,10 @@ closure color subsurface_bssrdf(normal N, color albedo, float sss_depth, color s // This closure may be vertically layered over a base BSDF, where energy that is not reflected // will be transmitted to the base closure. // +// \param N Normal vector of the surface point beeing shaded. +// \param albedo Surface albedo. +// \param roughness Surface roughness [0,1]. +// closure color sheen_bsdf(normal N, color albedo, float roughness) BUILTIN; ​ // Adds an iridescent thin film layer over a microfacet base BSDF. This must be layered over @@ -664,6 +703,9 @@ closure color sheen_bsdf(normal N, color albedo, float roughness) BUILTIN; // - This might be better to represent as optional extra arguments on the closures that do support // thin-film iridescence (dielectric_bsdf, conductor_bsdf and generalized_schlick_bsdf)? // +// \param thickness Thickness of the thin film. +// \param ior Refraction index of the thin film. +// closure color thin_film_bsdf(float thickness, float ior) BUILTIN; ​ ​ @@ -673,10 +715,18 @@ closure color thin_film_bsdf(float thickness, float ior) BUILTIN; ​ // Constructs an EDF emitting light uniformly in all directions. // +// \param emittance Radiant emittance of light leaving the surface. +// closure color uniform_edf(color emittance) BUILTIN; // Constructs an EDF emitting light inside a cone around the normal direction. // +// \param emittance Radiant emittance of light leaving the surface. +// \param N Cone direction vector. +// \param inner_angle Angle of inner cone where emission falloff starts. +// \param outer_angle Angle of outer cone where emission goes to zero. If set to a smaller value +// than inner_angle no falloff will occur within the cone. +// closure color conical_edf(color emittance, normal N, float inner_angle, float outer_angle) BUILTIN; ​ ​ @@ -687,7 +737,8 @@ closure color conical_edf(color emittance, normal N, float inner_angle, float ou // Constructs a VDF scattering light for a participating medium, based on the Henyey-Greenstein // phase function. Forward, backward and uniform scattering is supported and controlled by the // anisotropy input. -// \param albedo Volume albedo. +// +// \param albedo Volume single scattering albedo. // \param extinction Volume extinction coefficient. // \param anisotropy Scattering anisotropy [-1,1]. Negative values give backwards scattering, positive values give forward scattering, // and 0.0 gives uniform scattering. @@ -706,6 +757,9 @@ closure color anisotropic_vdf(color albedo, color extinction, float anisotropy) // of handling this is by albedo scaling, using "base*(1-reflectance(top)) + top", where // reflectance() calculates the directional albedo of a given top BSDF. // +// \param top Closure defining the top layer. +// \param base Closure defining the base layer. +// // TODO: // - This could also be achived by closure nesting where each layerable closure takes // a closure color "base" input instead. @@ -725,8 +779,15 @@ closure color layer(closure color top, closure color base) BUILTIN; ​ // Converts the artistic parameterization reflectivity and edge_color to complex IOR values. // To be used with the conductor_bsdf() closure. +// [OG14] "Artist Friendly Metallic Fresnel", http://jcgt.org/published/0003/04/03/paper.pdf +// +// \param reflectivity Reflectivity per color channel at facing angles ('r' parameter in [OG14]). +// \param edge_tint Color bias for grazing angles ('g' parameter in [OG14]). +// NOTE: This is not equal to 'f90' in a Schlick Fresnel parameterization. +// \param ior Output refraction index. +// \param extinction Output extinction coefficient. // -void artistic_ior(color reflectivity, color edge_color, output color ior, output color extinction); +void artistic_ior(color reflectivity, color edge_tint, output color ior, output color extinction); ​ // ******************* MATERIALX PBS LIBRARY CLOSURES - DRAFT END ******************* // From cec87b6812cade058c2615fee8f14df7668bfd32 Mon Sep 17 00:00:00 2001 From: Niklas Harrysson Date: Tue, 13 Apr 2021 09:41:03 +0200 Subject: [PATCH 09/15] Added optional 'label' parameter to name the components for use in AOV/LPE --- libraries/stdlib/osl/stdosl.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libraries/stdlib/osl/stdosl.h b/libraries/stdlib/osl/stdosl.h index ebfa03cb9e..9db0cbc1c2 100644 --- a/libraries/stdlib/osl/stdosl.h +++ b/libraries/stdlib/osl/stdosl.h @@ -584,6 +584,7 @@ closure color subsurface(float eta, float g, color mfp, color albedo) BUILTIN; // \param N Normal vector of the surface point beeing shaded. // \param albedo Surface albedo. // \param roughness Surface roughness [0,1]. A value of 0.0 gives Lambertian reflectance. +// \param label Optional string parameter to name this component. For use in AOVs / LPEs. // closure color oren_nayar_diffuse_bsdf(normal N, color albedo, float roughness) BUILTIN; ​ @@ -593,6 +594,7 @@ closure color oren_nayar_diffuse_bsdf(normal N, color albedo, float roughness) B // \param N Normal vector of the surface point beeing shaded. // \param albedo Surface albedo. // \param roughness Surface roughness [0,1]. +// \param label Optional string parameter to name this component. For use in AOVs / LPEs. // closure color burley_diffuse_bsdf(normal N, color albedo, float roughness) BUILTIN; ​ @@ -618,6 +620,7 @@ closure color burley_diffuse_bsdf(normal N, color albedo, float roughness) BUILT // \param roughness_y Surface roughness in the V direction. Valid range [0,1] with a perceptually linear response over the range. // \param ior Refraction index. // \param distribution Microfacet distribution. An implementation is expected to support the following distributions: { "ggx" } +// \param label Optional string parameter to name this component. For use in AOVs / LPEs. // closure color dielectric_bsdf(normal N, vector U, color reflection_tint, color transmission_tint, float roughness_x, float roughness_y, float ior, string distribution) BUILTIN; ​ @@ -633,6 +636,7 @@ closure color dielectric_bsdf(normal N, vector U, color reflection_tint, color t // \param ior Refraction index. // \param extinction Extinction coefficient. // \param distribution Microfacet distribution. An implementation is expected to support the following distributions: { "ggx" } +// \param label Optional string parameter to name this component. For use in AOVs / LPEs. // closure color conductor_bsdf(normal N, vector U, float roughness_x, float roughness_y, color ior, color extinction, string distribution) BUILTIN; ​ @@ -655,6 +659,7 @@ closure color conductor_bsdf(normal N, vector U, float roughness_x, float roughn // \param f0 Reflectivity per color channel at facing angles. // \param f90 Reflectivity per color channel at grazing angles. // \param distribution Microfacet distribution. An implementation is expected to support the following distributions: { "ggx" } +// \param label Optional string parameter to name this component. For use in AOVs / LPEs. // closure color generalized_schlick_bsdf(normal N, vector U, color reflection_tint, color transmission_tint, float roughness_x, float roughness_y, color f0, color f90, float exponent, string distribution) BUILTIN; ​ @@ -662,11 +667,14 @@ closure color generalized_schlick_bsdf(normal N, vector U, color reflection_tint // // \param N Normal vector of the surface point beeing shaded. // \param albedo Surface albedo. +// \param label Optional string parameter to name this component. For use in AOVs / LPEs. // closure color translucent_bsdf(normal N, color albedo) BUILTIN; // Constructs a closure that represents straight transmission through a surface. // +// \param label Optional string parameter to name this component. For use in AOVs / LPEs. +// // NOTE: // - This is not a node in the MaterialX library, but the surface shader constructor // node has an 'opacity' parameter to control textured cutout opacity. @@ -682,6 +690,7 @@ closure color transparent_bsdf() BUILTIN; // through the surface. // \param anisotropy Scattering anisotropy [-1,1]. Negative values give backwards scattering, positive values give forward scattering, // and 0.0 gives uniform scattering. +// \param label Optional string parameter to name this component. For use in AOVs / LPEs. // closure color subsurface_bssrdf(normal N, color albedo, float sss_depth, color sss_color, float anisotropy) BUILTIN; ​ @@ -692,6 +701,7 @@ closure color subsurface_bssrdf(normal N, color albedo, float sss_depth, color s // \param N Normal vector of the surface point beeing shaded. // \param albedo Surface albedo. // \param roughness Surface roughness [0,1]. +// \param label Optional string parameter to name this component. For use in AOVs / LPEs. // closure color sheen_bsdf(normal N, color albedo, float roughness) BUILTIN; ​ @@ -716,6 +726,7 @@ closure color thin_film_bsdf(float thickness, float ior) BUILTIN; // Constructs an EDF emitting light uniformly in all directions. // // \param emittance Radiant emittance of light leaving the surface. +// \param label Optional string parameter to name this component. For use in AOVs / LPEs. // closure color uniform_edf(color emittance) BUILTIN; @@ -726,6 +737,7 @@ closure color uniform_edf(color emittance) BUILTIN; // \param inner_angle Angle of inner cone where emission falloff starts. // \param outer_angle Angle of outer cone where emission goes to zero. If set to a smaller value // than inner_angle no falloff will occur within the cone. +// \param label Optional string parameter to name this component. For use in AOVs / LPEs. // closure color conical_edf(color emittance, normal N, float inner_angle, float outer_angle) BUILTIN; ​ @@ -744,10 +756,11 @@ closure color conical_edf(color emittance, normal N, float inner_angle, float ou // and 0.0 gives uniform scattering. // \param ior Optional float parameter for refraction index of a homogeneous medium. // \param priority Optional int parameter for priority of a homogeneous medium (for nested dielectrics). +// \param label Optional string parameter to name this component. For use in AOVs / LPEs. // closure color anisotropic_vdf(color albedo, color extinction, float anisotropy) BUILTIN; ​ -​ + // -------------------------------------------------------------// // Layering closures // // -------------------------------------------------------------// From 78e913a9eb4dbe977447d22376b7441b15b7cab4 Mon Sep 17 00:00:00 2001 From: Niklas Harrysson Date: Tue, 13 Apr 2021 10:03:45 +0200 Subject: [PATCH 10/15] Replace thin_film_bsdf with optional parameters for thin-film on dielectric_bsdf, generalized_schlick_bsdf and conductor_bsdf --- libraries/stdlib/osl/stdosl.h | 77 ++++++++++++++++------------------- 1 file changed, 35 insertions(+), 42 deletions(-) diff --git a/libraries/stdlib/osl/stdosl.h b/libraries/stdlib/osl/stdosl.h index 9db0cbc1c2..9a1c5c74c9 100644 --- a/libraries/stdlib/osl/stdosl.h +++ b/libraries/stdlib/osl/stdosl.h @@ -610,17 +610,19 @@ closure color burley_diffuse_bsdf(normal N, color albedo, float roughness) BUILT // a VDF closure describing the surface interior to handle absorption and scattering // inside the medium. // -// \param N Normal vector of the surface point beeing shaded. -// \param U Tangent vector of the surface point beeing shaded. -// \param reflection_tint Weight per color channel for the reflection lobe. Should be (1,1,1) for a physically-correct dielectric surface, -// but can be tweaked for artistic control. Set to (0,0,0) to disable reflection. -// \param transmission_tint Weight per color channel for the transmission lobe. Should be (1,1,1) for a physically-correct dielectric surface, -// but can be tweaked for artistic control. Set to (0,0,0) to disable transmission. -// \param roughness_x Surface roughness in the U direction. Valid range [0,1] with a perceptually linear response over the range. -// \param roughness_y Surface roughness in the V direction. Valid range [0,1] with a perceptually linear response over the range. -// \param ior Refraction index. -// \param distribution Microfacet distribution. An implementation is expected to support the following distributions: { "ggx" } -// \param label Optional string parameter to name this component. For use in AOVs / LPEs. +// \param N Normal vector of the surface point beeing shaded. +// \param U Tangent vector of the surface point beeing shaded. +// \param reflection_tint Weight per color channel for the reflection lobe. Should be (1,1,1) for a physically-correct dielectric surface, +// but can be tweaked for artistic control. Set to (0,0,0) to disable reflection. +// \param transmission_tint Weight per color channel for the transmission lobe. Should be (1,1,1) for a physically-correct dielectric surface, +// but can be tweaked for artistic control. Set to (0,0,0) to disable transmission. +// \param roughness_x Surface roughness in the U direction. Valid range [0,1] with a perceptually linear response over the range. +// \param roughness_y Surface roughness in the V direction. Valid range [0,1] with a perceptually linear response over the range. +// \param ior Refraction index. +// \param distribution Microfacet distribution. An implementation is expected to support the following distributions: { "ggx" } +// \param thinfilm_thickness Optional float parameter for thickness of an iridescent thin film layer on top of this BSDF. Given in nanometers. +// \param thinfilm_ior Optional float parameter for refraction index of the thin film layer. +// \param label Optional string parameter to name this component. For use in AOVs / LPEs. // closure color dielectric_bsdf(normal N, vector U, color reflection_tint, color transmission_tint, float roughness_x, float roughness_y, float ior, string distribution) BUILTIN; ​ @@ -629,14 +631,16 @@ closure color dielectric_bsdf(normal N, vector U, color reflection_tint, color t // If an artistic parametrization is preferred the artistic_ior() utility function // can be used to convert from artistic to physical parameters. // -// \param N Normal vector of the surface point beeing shaded. -// \param U Tangent vector of the surface point beeing shaded. -// \param roughness_x Surface roughness in the U direction. Valid range [0,1] with a perceptually linear response over the range. -// \param roughness_y Surface roughness in the V direction. Valid range [0,1] with a perceptually linear response over the range. -// \param ior Refraction index. -// \param extinction Extinction coefficient. -// \param distribution Microfacet distribution. An implementation is expected to support the following distributions: { "ggx" } -// \param label Optional string parameter to name this component. For use in AOVs / LPEs. +// \param N Normal vector of the surface point beeing shaded. +// \param U Tangent vector of the surface point beeing shaded. +// \param roughness_x Surface roughness in the U direction. Valid range [0,1] with a perceptually linear response over the range. +// \param roughness_y Surface roughness in the V direction. Valid range [0,1] with a perceptually linear response over the range. +// \param ior Refraction index. +// \param extinction Extinction coefficient. +// \param distribution Microfacet distribution. An implementation is expected to support the following distributions: { "ggx" } +// \param thinfilm_thickness Optional float parameter for thickness of an iridescent thin film layer on top of this BSDF. Given in nanometers. +// \param thinfilm_ior Optional float parameter for refraction index of the thin film layer. +// \param label Optional string parameter to name this component. For use in AOVs / LPEs. // closure color conductor_bsdf(normal N, vector U, float roughness_x, float roughness_y, color ior, color extinction, string distribution) BUILTIN; ​ @@ -650,16 +654,18 @@ closure color conductor_bsdf(normal N, vector U, float roughness_x, float roughn // a VDF closure describing the surface interior to handle absorption and scattering // inside the medium. // -// \param N Normal vector of the surface point beeing shaded. -// \param U Tangent vector of the surface point beeing shaded. -// \param reflection_tint Weight per color channel for the reflection lobe. Set to (0,0,0) to disable reflection. -// \param transmission_tint Weight per color channel for the transmission lobe. Set to (0,0,0) to disable transmission. -// \param roughness_x Surface roughness in the U direction. Valid range [0,1] with a perceptually linear response over the range. -// \param roughness_y Surface roughness in the V direction. Valid range [0,1] with a perceptually linear response over the range. -// \param f0 Reflectivity per color channel at facing angles. -// \param f90 Reflectivity per color channel at grazing angles. -// \param distribution Microfacet distribution. An implementation is expected to support the following distributions: { "ggx" } -// \param label Optional string parameter to name this component. For use in AOVs / LPEs. +// \param N Normal vector of the surface point beeing shaded. +// \param U Tangent vector of the surface point beeing shaded. +// \param reflection_tint Weight per color channel for the reflection lobe. Set to (0,0,0) to disable reflection. +// \param transmission_tint Weight per color channel for the transmission lobe. Set to (0,0,0) to disable transmission. +// \param roughness_x Surface roughness in the U direction. Valid range [0,1] with a perceptually linear response over the range. +// \param roughness_y Surface roughness in the V direction. Valid range [0,1] with a perceptually linear response over the range. +// \param f0 Reflectivity per color channel at facing angles. +// \param f90 Reflectivity per color channel at grazing angles. +// \param distribution Microfacet distribution. An implementation is expected to support the following distributions: { "ggx" } +// \param thinfilm_thickness Optional float parameter for thickness of an iridescent thin film layer on top of this BSDF. Given in nanometers. +// \param thinfilm_ior Optional float parameter for refraction index of the thin film layer. +// \param label Optional string parameter to name this component. For use in AOVs / LPEs. // closure color generalized_schlick_bsdf(normal N, vector U, color reflection_tint, color transmission_tint, float roughness_x, float roughness_y, color f0, color f90, float exponent, string distribution) BUILTIN; ​ @@ -705,19 +711,6 @@ closure color subsurface_bssrdf(normal N, color albedo, float sss_depth, color s // closure color sheen_bsdf(normal N, color albedo, float roughness) BUILTIN; ​ -// Adds an iridescent thin film layer over a microfacet base BSDF. This must be layered over -// another base BSDF using the layer() closure, as this is a modifier and cannot be used as a -// standalone closure. -// -// TODO: -// - This might be better to represent as optional extra arguments on the closures that do support -// thin-film iridescence (dielectric_bsdf, conductor_bsdf and generalized_schlick_bsdf)? -// -// \param thickness Thickness of the thin film. -// \param ior Refraction index of the thin film. -// -closure color thin_film_bsdf(float thickness, float ior) BUILTIN; -​ ​ // -------------------------------------------------------------// // EDF closures // From f2500135c70de40ff1356e8a7c81dfc2ebe1fab7 Mon Sep 17 00:00:00 2001 From: Niklas Harrysson Date: Tue, 13 Apr 2021 10:10:35 +0200 Subject: [PATCH 11/15] Remove conical_edf as it's not practically useful in OSL at this point --- libraries/stdlib/osl/stdosl.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/libraries/stdlib/osl/stdosl.h b/libraries/stdlib/osl/stdosl.h index 9a1c5c74c9..6ff10fa3d4 100644 --- a/libraries/stdlib/osl/stdosl.h +++ b/libraries/stdlib/osl/stdosl.h @@ -722,17 +722,6 @@ closure color sheen_bsdf(normal N, color albedo, float roughness) BUILTIN; // \param label Optional string parameter to name this component. For use in AOVs / LPEs. // closure color uniform_edf(color emittance) BUILTIN; - -// Constructs an EDF emitting light inside a cone around the normal direction. -// -// \param emittance Radiant emittance of light leaving the surface. -// \param N Cone direction vector. -// \param inner_angle Angle of inner cone where emission falloff starts. -// \param outer_angle Angle of outer cone where emission goes to zero. If set to a smaller value -// than inner_angle no falloff will occur within the cone. -// \param label Optional string parameter to name this component. For use in AOVs / LPEs. -// -closure color conical_edf(color emittance, normal N, float inner_angle, float outer_angle) BUILTIN; ​ ​ // -------------------------------------------------------------// From 7791e3fa5eaa9492c14ec819495ee24c8600399f Mon Sep 17 00:00:00 2001 From: Niklas Harrysson Date: Tue, 20 Apr 2021 21:36:25 +0200 Subject: [PATCH 12/15] Clarification to parameterization of subsurface_bssrdf --- libraries/stdlib/osl/stdosl.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/libraries/stdlib/osl/stdosl.h b/libraries/stdlib/osl/stdosl.h index 6ff10fa3d4..99a3d1ce29 100644 --- a/libraries/stdlib/osl/stdosl.h +++ b/libraries/stdlib/osl/stdosl.h @@ -689,14 +689,15 @@ closure color transparent_bsdf() BUILTIN; ​ // Constructs a BSSRDF for subsurface scattering within a homogeneous medium. // -// \param N Normal vector of the surface point beeing shaded. -// \param albedo Surface albedo. -// \param sss_depth Mean-free path in units of scene length. -// \param sss_color Scattering color / transmittance. The desired color resulting from white light transmitted a distance of 'sss_depth' -// through the surface. -// \param anisotropy Scattering anisotropy [-1,1]. Negative values give backwards scattering, positive values give forward scattering, -// and 0.0 gives uniform scattering. -// \param label Optional string parameter to name this component. For use in AOVs / LPEs. +// \param N Normal vector of the surface point beeing shaded. +// \param albedo Single-scattering albedo of the medium. +// \param transmission_depth Distance travelled inside the medium by white light before its color becomes transmission_color by Beer's law. +// Together with transmission_color this determines the extinction coefficient of the medium. +// \param transmission_color Desired color resulting from white light transmitted a distance of 'transmission_depth' through the medium. +// Together with transmission_depth this determines the extinction coefficient of the medium. +// \param anisotropy Scattering anisotropy [-1,1]. Negative values give backwards scattering, positive values give forward scattering, +// and 0.0 gives uniform scattering. +// \param label Optional string parameter to name this component. For use in AOVs / LPEs. // closure color subsurface_bssrdf(normal N, color albedo, float sss_depth, color sss_color, float anisotropy) BUILTIN; ​ From 84ed703149a2705c70ecbe9c3eecb4f844049e57 Mon Sep 17 00:00:00 2001 From: Niklas Harrysson Date: Tue, 20 Apr 2021 22:06:51 +0200 Subject: [PATCH 13/15] Added a separate medium_vdf for homogenous media --- libraries/stdlib/osl/stdosl.h | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/libraries/stdlib/osl/stdosl.h b/libraries/stdlib/osl/stdosl.h index 99a3d1ce29..4cb50ea1a9 100644 --- a/libraries/stdlib/osl/stdosl.h +++ b/libraries/stdlib/osl/stdosl.h @@ -692,14 +692,15 @@ closure color transparent_bsdf() BUILTIN; // \param N Normal vector of the surface point beeing shaded. // \param albedo Single-scattering albedo of the medium. // \param transmission_depth Distance travelled inside the medium by white light before its color becomes transmission_color by Beer's law. -// Together with transmission_color this determines the extinction coefficient of the medium. +// Given in scene length units, range [0,infinity). Together with transmission_color this determines the extinction +// coefficient of the medium. // \param transmission_color Desired color resulting from white light transmitted a distance of 'transmission_depth' through the medium. // Together with transmission_depth this determines the extinction coefficient of the medium. // \param anisotropy Scattering anisotropy [-1,1]. Negative values give backwards scattering, positive values give forward scattering, // and 0.0 gives uniform scattering. // \param label Optional string parameter to name this component. For use in AOVs / LPEs. // -closure color subsurface_bssrdf(normal N, color albedo, float sss_depth, color sss_color, float anisotropy) BUILTIN; +closure color subsurface_bssrdf(normal N, color albedo, float transmission_depth, color transmission_color, float anisotropy) BUILTIN; ​ // Constructs a microfacet BSDF for the back-scattering properties of cloth-like materials. // This closure may be vertically layered over a base BSDF, where energy that is not reflected @@ -729,20 +730,34 @@ closure color uniform_edf(color emittance) BUILTIN; // VDF closures // // -------------------------------------------------------------// ​ -// Constructs a VDF scattering light for a participating medium, based on the Henyey-Greenstein -// phase function. Forward, backward and uniform scattering is supported and controlled by the -// anisotropy input. +// Constructs a VDF scattering light for a general participating medium, based on the Henyey-Greenstein +// phase function. Forward, backward and uniform scattering is supported and controlled by the anisotropy input. // -// \param albedo Volume single scattering albedo. +// \param albedo Volume single-scattering albedo. // \param extinction Volume extinction coefficient. // \param anisotropy Scattering anisotropy [-1,1]. Negative values give backwards scattering, positive values give forward scattering, // and 0.0 gives uniform scattering. -// \param ior Optional float parameter for refraction index of a homogeneous medium. -// \param priority Optional int parameter for priority of a homogeneous medium (for nested dielectrics). // \param label Optional string parameter to name this component. For use in AOVs / LPEs. // closure color anisotropic_vdf(color albedo, color extinction, float anisotropy) BUILTIN; -​ + +// Constructs a VDF for light passing through a dielectric homogenous medium, such as glass or liquids. +// The parameters transmission_depth and transmission_color control the extinction coefficient of the medium +// in and artist-friendly way. A priority can be set to determine the ordering of overlapping media. +// +// \param albedo Single-scattering albedo of the medium. +// \param transmission_depth Distance travelled inside the medium by white light before its color becomes transmission_color by Beer's law. +// Given in scene length units, range [0,infinity). Together with transmission_color this determines the extinction +// coefficient of the medium. +// \param transmission_color Desired color resulting from white light transmitted a distance of 'transmission_depth' through the medium. +// Together with transmission_depth this determines the extinction coefficient of the medium. +// \param anisotropy Scattering anisotropy [-1,1]. Negative values give backwards scattering, positive values give forward scattering, +// and 0.0 gives uniform scattering. +// \param ior Refraction index of the medium. +// \param priority Priority of this medium (for nested dielectrics). +// \param label Optional string parameter to name this component. For use in AOVs / LPEs. +// +closure color media_vdf(color albedo, float transmission_depth, color transmission_color, float anisotropy, float ior, int priority) BUILTIN; // -------------------------------------------------------------// // Layering closures // From 22acb3fd5f4baa25d102a465311da7362de2854c Mon Sep 17 00:00:00 2001 From: Niklas Harrysson Date: Tue, 20 Apr 2021 22:12:41 +0200 Subject: [PATCH 14/15] Some cleanups and clarifications --- libraries/stdlib/osl/stdosl.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libraries/stdlib/osl/stdosl.h b/libraries/stdlib/osl/stdosl.h index 4cb50ea1a9..cf7c1c2a36 100644 --- a/libraries/stdlib/osl/stdosl.h +++ b/libraries/stdlib/osl/stdosl.h @@ -616,8 +616,8 @@ closure color burley_diffuse_bsdf(normal N, color albedo, float roughness) BUILT // but can be tweaked for artistic control. Set to (0,0,0) to disable reflection. // \param transmission_tint Weight per color channel for the transmission lobe. Should be (1,1,1) for a physically-correct dielectric surface, // but can be tweaked for artistic control. Set to (0,0,0) to disable transmission. -// \param roughness_x Surface roughness in the U direction. Valid range [0,1] with a perceptually linear response over the range. -// \param roughness_y Surface roughness in the V direction. Valid range [0,1] with a perceptually linear response over the range. +// \param roughness_x Surface roughness in the U direction with a perceptually linear response over its range. +// \param roughness_y Surface roughness in the V direction with a perceptually linear response over its range. // \param ior Refraction index. // \param distribution Microfacet distribution. An implementation is expected to support the following distributions: { "ggx" } // \param thinfilm_thickness Optional float parameter for thickness of an iridescent thin film layer on top of this BSDF. Given in nanometers. @@ -633,8 +633,8 @@ closure color dielectric_bsdf(normal N, vector U, color reflection_tint, color t // // \param N Normal vector of the surface point beeing shaded. // \param U Tangent vector of the surface point beeing shaded. -// \param roughness_x Surface roughness in the U direction. Valid range [0,1] with a perceptually linear response over the range. -// \param roughness_y Surface roughness in the V direction. Valid range [0,1] with a perceptually linear response over the range. +// \param roughness_x Surface roughness in the U direction with a perceptually linear response over its range. +// \param roughness_y Surface roughness in the V direction with a perceptually linear response over its range. // \param ior Refraction index. // \param extinction Extinction coefficient. // \param distribution Microfacet distribution. An implementation is expected to support the following distributions: { "ggx" } @@ -658,8 +658,8 @@ closure color conductor_bsdf(normal N, vector U, float roughness_x, float roughn // \param U Tangent vector of the surface point beeing shaded. // \param reflection_tint Weight per color channel for the reflection lobe. Set to (0,0,0) to disable reflection. // \param transmission_tint Weight per color channel for the transmission lobe. Set to (0,0,0) to disable transmission. -// \param roughness_x Surface roughness in the U direction. Valid range [0,1] with a perceptually linear response over the range. -// \param roughness_y Surface roughness in the V direction. Valid range [0,1] with a perceptually linear response over the range. +// \param roughness_x Surface roughness in the U direction with a perceptually linear response over its range. +// \param roughness_y Surface roughness in the V direction with a perceptually linear response over its range. // \param f0 Reflectivity per color channel at facing angles. // \param f90 Reflectivity per color channel at grazing angles. // \param distribution Microfacet distribution. An implementation is expected to support the following distributions: { "ggx" } @@ -757,7 +757,7 @@ closure color anisotropic_vdf(color albedo, color extinction, float anisotropy) // \param priority Priority of this medium (for nested dielectrics). // \param label Optional string parameter to name this component. For use in AOVs / LPEs. // -closure color media_vdf(color albedo, float transmission_depth, color transmission_color, float anisotropy, float ior, int priority) BUILTIN; +closure color medium_vdf(color albedo, float transmission_depth, color transmission_color, float anisotropy, float ior, int priority) BUILTIN; // -------------------------------------------------------------// // Layering closures // From 9eaeb431d150297ea6955d036f4115f2eab0654f Mon Sep 17 00:00:00 2001 From: Niklas Harrysson Date: Mon, 10 May 2021 22:00:14 +0200 Subject: [PATCH 15/15] Wrap the declarations in #ifdef MATERIALX_CLOSURES --- libraries/stdlib/osl/stdosl.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libraries/stdlib/osl/stdosl.h b/libraries/stdlib/osl/stdosl.h index cf7c1c2a36..39f61ea2c5 100644 --- a/libraries/stdlib/osl/stdosl.h +++ b/libraries/stdlib/osl/stdosl.h @@ -573,7 +573,7 @@ closure color volume_matte() BUILTIN; closure color subsurface(float eta, float g, color mfp, color albedo) BUILTIN; #endif -// ******************* MATERIALX PBS LIBRARY CLOSURES - DRAFT BEGIN ******************* // +#ifdef MATERIALX_CLOSURES // -------------------------------------------------------------// // BSDF closures // @@ -800,9 +800,7 @@ closure color layer(closure color top, closure color base) BUILTIN; // void artistic_ior(color reflectivity, color edge_tint, output color ior, output color extinction); ​ - -// ******************* MATERIALX PBS LIBRARY CLOSURES - DRAFT END ******************* // - +#endif // MATERIALX_CLOSURES // Renderer state int backfacing () BUILTIN;