Support vertical layering of opaque BSDFs - #3022
Conversation
This changelist extends vertical layering to opaque BSDFs, adopting the convention that every BSDF in the PBS library defines a vertical-layering transmittance: the fraction of incident light that passes through the BSDF to the layers beneath it. Interface BSDFs such as `dielectric_bsdf` and `sheen_bsdf` transmit all of the energy they do not reflect, while opaque BSDFs such as `oren_nayar_diffuse_bsdf` and `conductor_bsdf` treat their weight input as a statistical coverage of the surface, transmitting light only through the uncovered fraction. Previously, an opaque BSDF used as the top input of a `layer` node fully occluded its base regardless of weight, so even a zero-weight lobe occluded the layers beneath it. With this change, layering an opaque BSDF over a base is equivalent to mixing the two BSDFs by the coverage, making a zero-weight lobe transparent to its base and preserving energy conservation throughout. Specific changes: - Update the throughput of the opaque BSDF closures in hardware shading languages from full occlusion to the uncovered fraction `1 - weight`. - Extend MDL shader generation to support vertical layering of opaque BSDFs, passing the layer base into their existing `weighted_layer` composition. - Add a Vertical-Layering Transmittance section to the PBR specification, defining the transmittance of each BSDF in the PBS library, its composition by the `mix`, `layer`, `add`, and `multiply` nodes, and the energy conservation invariant relating transmittance to directional albedo. - Add test graphs validating that layering an opaque BSDF over a base matches the equivalent mix (pixel-identical in GLSL), and that a zero-weight opaque top leaves its base unoccluded. Notes for reviewers: - No shading models in the standard libraries change appearance: all `layer` tops in `libraries/bxdf` are interface BSDFs or unit-weight opaque BSDFs. User materials that layer a partial-weight opaque BSDF will brighten, as the base now correctly receives the uncovered fraction of light. - Shader-semantic `multiply` nodes intentionally preserve transmittance (attenuating only the scattered response), so `multiply`-scaled opaque top layers (e.g. the `topMix` of `LamaLayer`) still fully occlude their base, while `mix`-scaled top layers interpolate transmittance instead. - OSL `layer` closure semantics are implemented by host renderers; the new specification section defines the expected behavior for those implementations.
|
In addition to the list of reviewers above, I'm CC'ing @krohmerNV and @jreichel-nvidia for their thoughts from the MDL perspective. |
This changelist integrates the layer pass-through semantics proposed by @tdavidovicNV in AcademySoftwareFoundation#3017 into the vertical-layering transmittance framework, preserving the distinctions drawn there between reflection, absorption, and pass-through. The following specific changes are included: - Evaluate the transmittance of an interface BSDF with its physical Fresnel reflectance alone, classifying the energy removed by non-physical color inputs such as the `tint` of `dielectric_bsdf` as absorption within the interface, matching the behavior of existing implementations. - Present the bidirectional pass-through factor of Weidlich and Wilkie as the ideal quantity underlying vertical layering, with the fixed-exitant-direction transmittance serving as its reference approximation. - Restructure the `layer` node section into parallel "Layering over a BSDF" and "Layering over a VDF" subsections, clarifying that a VDF base represents a surface boundary bound to an interior medium, with medium entry governed by the Fresnel transmittance of the surface interface.
tdavidovicNV
left a comment
There was a problem hiding this comment.
I really like this, definitely good direction.
I have two concerns about the MDL, which just reinforce the call for my more MDL capable colleagues to take a look. I tried to point out the code that looks worrying, but I don't know enough about MDL to propose actually working fixes.
| tint: mxp_color, | ||
| roughness: mxp_roughness | ||
| ), | ||
| base: mxp_base.surface.scattering, |
There was a problem hiding this comment.
The new SSS layering path forwards mxp_base.surface.scattering, but the returned volume is still constructed exclusively from the top SSS node.
Shouldn’t this be something along the lines of:
coverage = saturate(mxp_weight * mxp_top_weight)
result.surface =
weighted_layer(coverage, top.surface, base.surface)
result.volume =
volume_mix(coverage, top.volume,
1 - coverage, base.volume)
result.ior = base.ior
In particular, layer(subsurface(weight=0), baseSubsurface) should preserve the base volume exactly. I will leave the exact code to more MDL-capable people.
| ), | ||
| ior: mxp_ior, | ||
| // we need to carry volume properties along for SSS | ||
| volume: mxp_base.volume |
There was a problem hiding this comment.
The conductor now forwards mxp_base.volume, but the returned material still uses the conductor’s IOR unconditionally no matter the top weight:
ior: mxp_ior
The important point is that layer(conductor(weight=0), base) should preserve the base IOR, I think.
I don't think the conductor's IOR should affect the volume's IOR (at least that's my reading of this code), unless we go full IOR accumulation route.
|
After looking into this more, I need to walk back my earlier agreement with this PR. I agree with most of the change, but not with the proposed behavior of The proposed spec currently says two things:
This gives these two graphs different meanings: The first one covers half of the surface and lets half of the base show through. The second one still covers the whole surface. It only makes the Oren–Nayar response darker, with the removed light treated as absorption. At zero, the difference is even clearer: means no top layer, while: means a completely black layer which still hides the base. I don’t think these should be different. This is also not what I intended in #2971, where There is also a practical cross-target problem. Current OSL could probably be extended to support the distinction proposed here, but this would require a change to the closure contract and corresponding changes in OSL renderers. It is not just a MaterialX codegen change. MDL can represent the distinction because it has separate operations for layer weight and BSDF tinting. However, MaterialX’s MDL layer codegen does not currently handle a I would prefer that For an opaque BSDF, this means reducing its coverage. Multiplying by 0.5 leaves half the surface uncovered, while multiplying by zero removes the layer completely. Since the spec defines throughput as (T=1-w) for opaque BSDFs, scaling the effective weight by (s) gives: Given GLSL and OSL are our reference renders, and this proposal introduces something OSL currently cannot easily express, I am worried. |
|
(I am gonna walk back the recommendation, because LamaLayer and LamaConductor utilize the |
|
After looking into this much more, I need to walk back both my earlier agreement with the The underlying problem is that scaling a BSDF response and scaling its coverage are different operations. At zero, this is the difference between an absent BSDF, which reveals the layer below, and a black absorbing BSDF, which still hides it. #3022 currently makes that distinction by saying that an elemental BSDF's own I tested the same material with a neutral, reflection-only dielectric top in several backends: The results are not consistent (the base is green, the top is dielectric):
This behavior is not inferred from the renders alone. GLSL includes the dielectric OSL has no way to scale only the response of an arbitrary closure while leaving its layering weight unchanged. Closure multiplication changes the closure weight, which is also used for coverage. Pushing the multiplier into the BSDF's color or tint parameters is not an option either: the input may be an arbitrary composition, and the language has no operation that can inspect that composition and modify its parameters. Mixing with opaque black does not solve this. Consider: Response-only scaling would produce a half-covered grey BSDF. OSL closure multiplication produces a quarter-covered white BSDF. Mixing the half-covered white BSDF with opaque black produces half black, one quarter white, and one quarter uncovered: 75% coverage. All three look the same over black, but behave differently when layered. So the proposed response-only meaning of a generic BSDF MDL can represent response scaling with My #3017 proposal did not settle There are also two separate questions involving An ordinary mixed top: needs a pass-through value of its own. glTF and OpenPBR already use this form, and the linear rule proposed in #3022 is the natural one: I think this should remain part of the 1.39.6 definition. The separate question is how to reduce the coverage of an arbitrary compound top. Under the proposed rules this can be written as: Here GLSL and OSL give the expected coverage behavior for this graph. In my tests Karma produces black at Lama also shows why this is not merely theoretical. Other material systems generally give these operations separate names. MDL has So, for 1.39.6, I would suggest the following scope:
The effect of I think those questions should become focused follow-up issues. One should cover the relationship between response, coverage, That would still give #3022 a useful result for 1.39.6: opaque BSDFs become usable as top layers, while the unresolved |

This changelist extends vertical layering to opaque BSDFs, adopting the convention that every BSDF in the PBS library defines a vertical-layering transmittance: the fraction of incident light that passes through the BSDF to the layers beneath it. Interface BSDFs such as
dielectric_bsdfandsheen_bsdftransmit all of the energy they do not reflect, while opaque BSDFs such asoren_nayar_diffuse_bsdfandconductor_bsdftreat their weight input as a statistical coverage of the surface, transmitting light only through the uncovered fraction.Previously, an opaque BSDF used as the top input of a
layernode fully occluded its base regardless of weight, so even a zero-weight lobe occluded the layers beneath it. With this change, layering an opaque BSDF over a base is equivalent to mixing the two BSDFs by the coverage, making a zero-weight lobe transparent to its base and preserving energy conservation throughout.Specific changes:
1 - weight.weighted_layercomposition.mix,layer,add, andmultiplynodes, and the energy conservation invariant relating transmittance to directional albedo.Notes for reviewers:
layertops inlibraries/bxdfare interface BSDFs or unit-weight opaque BSDFs. User materials that layer a partial-weight opaque BSDF will brighten, as the base now correctly receives the uncovered fraction of light.multiplynodes intentionally preserve transmittance (attenuating only the scattered response), somultiply-scaled opaque top layers (e.g. thetopMixofLamaLayer) still fully occlude their base, whilemix-scaled top layers interpolate transmittance instead.layerclosure semantics are implemented by host renderers; the new specification section defines the expected behavior for those implementations.