Skip to content

Commit

Permalink
Fix the subsurface_bssrdf parameters (#1823)
Browse files Browse the repository at this point in the history
Fix the subsurface_bssrdf parameters to use effective color and radius instead of single scattering parameters

Signed-off-by: Chris Kulla <ckulla@gmail.com>
  • Loading branch information
fpsunflower authored Jun 11, 2024
1 parent b284a8b commit 02e2bc3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 33 deletions.
22 changes: 7 additions & 15 deletions src/doc/languagespec.tex
Original file line number Diff line number Diff line change
Expand Up @@ -5049,27 +5049,19 @@ \subsection{Surface BSDF closures}

\apiitem{albedo}
\vspace{12pt}
Single-scattering albedo of the medium.
\apiend
\vspace{-16pt}

\apiitem{transmission_depth}
\vspace{12pt}
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.
Effective albedo of the medium (after multiple scattering). The renderer is expected to
invert this color to derive the appropriate single-scattering albedo that will produce
this color for the average random walk.
\apiend
\vspace{-16pt}

\apiitem{transmission_color}
\apiitem{radius}
\vspace{12pt}
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.
Average distance travelled inside the medium per color channel. This is typically taken
to be the mean-free path of the volume.
\apiend
\vspace{-16pt}

\apiitem{anisotropy}
\vspace{12pt}
Scattering anisotropy [-1,1]. Negative values give backwards scattering,
Expand Down
11 changes: 4 additions & 7 deletions src/doc/stdlib.md
Original file line number Diff line number Diff line change
Expand Up @@ -1506,14 +1506,11 @@ properties of the physically-based shading nodes of MaterialX v1.38
: Normal vector of the surface point being shaded.

`albedo`
: Single-scattering albedo of the medium.

`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.

`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.
: Effective albedo of the medium (after multiple scattering). The renderer is expected to invert this color to derive the appropriate single-scattering albedo that will produce this color for the average random walk.

`radius`
: Average distance travelled inside the medium per color channel. This is typically taken to be the mean-free path of the volume.

`anisotropy`
: Scattering anisotropy [-1,1]. Negative values give backwards scattering, positive values give forward scattering, and 0.0 gives uniform scattering.

Expand Down
10 changes: 3 additions & 7 deletions src/shaders/stdosl.h
Original file line number Diff line number Diff line change
Expand Up @@ -587,17 +587,13 @@ closure color transparent_bsdf() BUILTIN;
// Constructs a BSSRDF for subsurface scattering within a homogeneous medium.
//
// \param N Normal vector of the surface point being 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.
// 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 albedo Effective albedo of the medium (after multiple scattering). The renderer is expected to invert this color to derive the appropriate single-scattering albedo that will produce this color for the average random walk.
// \param radius Average distance travelled inside the medium per color channel. This is typically taken to be the mean-free path of the volume.
// \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 transmission_depth, color transmission_color, float anisotropy) BUILTIN;
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
Expand Down
6 changes: 2 additions & 4 deletions src/testrender/shading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ struct MxTranslucentParams {
struct MxSubsurfaceParams {
Vec3 N;
Color3 albedo;
float transmission_depth;
Color3 transmission_color;
Color3 radius;
float anisotropy;
// optional
ustringhash label;
Expand Down Expand Up @@ -389,8 +388,7 @@ register_closures(OSL::ShadingSystem* shadingsys)
MX_SUBSURFACE_ID,
{ CLOSURE_VECTOR_PARAM(MxSubsurfaceParams, N),
CLOSURE_COLOR_PARAM(MxSubsurfaceParams, albedo),
CLOSURE_FLOAT_PARAM(MxSubsurfaceParams, transmission_depth),
CLOSURE_COLOR_PARAM(MxSubsurfaceParams, transmission_color),
CLOSURE_COLOR_PARAM(MxSubsurfaceParams, radius),
CLOSURE_FLOAT_PARAM(MxSubsurfaceParams, anisotropy),
CLOSURE_STRING_KEYPARAM(MxSubsurfaceParams, label, "label"),
CLOSURE_FINISH_PARAM(MxSubsurfaceParams) } },
Expand Down

0 comments on commit 02e2bc3

Please sign in to comment.