Adobe 对 OpenPBR BSDF 的参考实现
A self-contained, portable implementation of the OpenPBR 1.1.1 BSDF, extracted from Adobe's proprietary renderer, Eclair. Written in a GLSL-style language with macros that target C++, GLSL, CUDA, MSL (Metal Shading Language), or Slang, it's designed to drop into any path tracer with minimal setup.
OpenPBR is an "uber-shader" specification that merges Adobe Standard Material and Autodesk Standard Surface into a single, physically plausible framework. We implement it as a fixed set of nested lobes (e.g., fuzz, coat), all sharing the same interface:
In addition to those three core functions, the prepared BSDF exposes two additional outputs for direct use by the integrator: a homogeneous volume that consolidates all volumetric contributions from the full OpenPBR parameter set, and surface emission attenuated by the coat and fuzz layers. Volume integration is left to the host renderer, though openpbr_homogeneous_volume.h provides production-tested helpers for distance sampling, transmittance, and phase functions.
OpenPBR is a powerful but complex material model — implementing it well from scratch requires deep rendering knowledge and a lot of time. We're open-sourcing this to lower that barrier: even a simple path tracer can integrate this production-grade implementation of the full OpenPBR 1.1.1 parameter set. This is the same code that ships in Eclair today, not a prototype or sample, and we hope it helps teams across the ecosystem adopt OpenPBR faster and validate their own integrations against a real-world reference. The code is released under Apache 2.0.
Note: This is shared as a reference implementation, not run as a community-driven open-source project. Because this code lives in a shipping product, we can't commit to a formal external review process. Pull requests, bug reports, and feature requests are all welcome, and we'll address them on a best-effort basis as our priorities allow. We can't promise to address every item, and large or invasive changes are unlikely to be accepted.
#include "openpbr.h" brings in the complete public API — all types, settings, and the full BSDF.openpbr_settings.h — LUT storage mode, language target, specialization constants, custom overrides, and more.…Resolved Inputs
OpenPBR_ResolvedInputs — A struct containing the full OpenPBR 1.1.1 parameter set after texture evaluation (base_color, specular_roughness, etc.), plus two required non-spec additions (geometry_basis and geometry_coat_basis, which replace the spec's geometry_normal/geometry_tangent/geometry_coat_normal/geometry_coat_tangent raw vectors) and two optional extensions (specular_anisotropy_rotation_cos_sin and coat_anisotropy_rotation_cos_sin). See Departures from the OpenPBR Specification for details.openpbr_make_default_resolved_inputs() — Creates an OpenPBR_ResolvedInputs with default parameter values from the OpenPBR specification.Initialization
openpbr_prepare() → Main entry point. Returns OpenPBR_PreparedBsdf containing the volume, emission, and all BSDF state ready for evaluation.For renderers that need finer-grained control (e.g., shadow rays that need only the volume), the prepare functions can be called individually in stages — see step 9 in Getting Started.
Prepared Outputs
openpbr_prepare() populates an OpenPBR_PreparedBsdf with two public outputs:
prepared.volume (OpenPBR_HomogeneousVolume) — The interior volume of the material: the homogeneous medium that fills the closed surface, derived from the full OpenPBR parameter set. The subsurface scattering and transmission parameters are blended into a single unified volume. Apply it only to ray segments traveling inside a non-thin-walled object. Recompute it at each surface interaction: after either transmission or internal reflection, if the scattered ray is inside the object, use the newly prepared volume for that next interior segment. Contains extinction, single-scattering albedo, and phase-function anisotropy for use by your renderer's volumetric light transport system (see item 5 in the High-Level Architecture section for production-tested integration helpers).prepared.emission (vec3) — Surface emission in nits (cd/m²), attenuated by coat and fuzz layers. Zero when hitting non-thin-walled geometry from the inside.BSDF Evaluation
openpbr_eval() → Returns BSDF value multiplied by the cosine of the angle between the light direction and the shading normal (i.e., f(ωᵢ, ωₒ) × |cos θᵢ|).openpbr_sample() → Importance-samples a light direction; returns weight, PDF, and sampled lobe type.openpbr_pdf() → Returns sampling PDF for a given light direction.Volume Integration Helpers (in openpbr_homogeneous_volume.h)
openpbr_homogeneous_volume.h provides a complete, production-tested set of helpers for integrators that act on prepared.volume:
openpbr_sample_event_distance() → Samples a scattering-event distance with spectrally-aware MIS across color channels.openpbr_calculate_weight_for_event_at_distance() / openpbr_calculate_weight_for_surface_at_distance() → Unbiased path weights for volume and surface interactions, respectively.openpbr_sample_isotropic_phase_function() / openpbr_sample_anisotropic_phase_function() → Importance-sample the isotropic or Henyey-Greenstein phase function.openpbr_calculate_isotropic_phase_function_value() / openpbr_calculate_isotropic_phase_function_pdf() and openpbr_calculate_anisotropic_phase_function_value() / openpbr_calculate_anisotropic_phase_function_pdf() → Evaluate phase function values and PDFs for the isotropic and Henyey-Greenstein models.openpbr_calculate_transmittance_at_distance() / openpbr_calculate_transmittance_at_infinity() → Beer–Lambert transmittance.OpenPBR_HomogeneousVolume from extinction+albedo, absorption+scattering, or extinction alone.Advanced Shading API (in impl/openpbr_bsdf.h; not yet part of the stable public API — signatures may evolve; see comments above each function for full preconditions)
openpbr_translucent_shadow_weight_and_prob() → Returns a straight-through shadow weight and probability for transmissive/SSS materials, enabling a practical biased shadow shortcut.Lobe Interface Pattern
GLSL has no class system, so each lobe is implemented as a plain struct paired with free functions that take the struct as their first argument. Every lobe exposes the same three function signatures:
openpbr_eval(lobe, light_direction)
openpbr_sample(lobe, rand, light_direction, weight, pdf, sampled_type)
openpbr_pdf(lobe, light_direction)The correct implementation is selected by the struct type via function overloading — compile-time polymorphism with no virtual dispatch overhead. The outermost lobe composes inward, calling the same interface on each inner lobe, so adding or replacing a lobe means implementing the same three functions for its struct type.
The BSDF uses precomputed lookup tables (LUTs) for physically accurate energy compensation and fuzz/sheen lobe evaluation:
These tables support two modes via the OPENPBR_USE_TEXTURE_LUTS compile-time switch:
OPENPBR_USE_TEXTURE_LUTS = 0)OPENPBR_USE_TEXTURE_LUTS = 1)Array Mode is the default because it eliminates external dependencies on texture assets and binding infrastructure.
Source data format:
impl/data/ directoryarray[x][y][z] with rightmost index contiguous)Implementation details:
unsigned short) for C++/MSL/CUDA/Slang; 32-bit (uint) for GLSL — no user action requiredClone this repository.
Include openpbr.h in your renderer (this provides the complete public API).
Select a shading language backend. Three backends are auto-detected from built-in compiler macros:
__CUDACC__), MSL (__METAL_VERSION__), and C++ (__cplusplus) are detected automatically.OPENPBR_LANGUAGE_TARGET_SLANG=1 to be defined before including openpbr.h. Without it, the GLSL backend will be selected, which will likely fail to compile under the Slang compiler. (For HLSL-style pipelines, use this Slang path.)Any backend can also be forced explicitly by setting the corresponding OPENPBR_LANGUAGE_TARGET_CPP, _GLSL, _MSL, _CUDA, or _SLANG flag, which overrides auto-detection.
C++ users must also pre-include GLM (``) before openpbr.h; the interop header will emit a clear error if it is missing. See minimal_cpp_example.cpp for a complete working example.
Choose lookup table mode: Set OPENPBR_USE_TEXTURE_LUTS to 0 for self-contained array mode (default) or 1 for texture mode. In texture mode, define OPENPBR_SAMPLE_2D_TEXTURE(lut_id, uv) and OPENPBR_SAMPLE_3D_TEXTURE(lut_id, uvw) before openpbr.h; the headers emit clear errors if either macro is missing. The available texture IDs are documented in openpbr_data_constants.h.
Optional — Pre-include hooks: Define any of the following before openpbr.h to customize behavior:
OPENPBR_FAST_RCP_SQRT(x), OPENPBR_FAST_SQRT(x), OPENPBR_FAST_NORMALIZE(v) — supply faster platform-specific implementations (GPU hardware intrinsics, CPU approximations, etc.). Any undefined hook falls back to the standard library.OPENPBR_USE_CUSTOM_SATURATE = 1 if your host already defines saturate(); set `OPENPBR_USE_CUSTOM_VEC_TYP暂无开放 Issues,或尚未同步最近议题。