Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
O

openpbr-bsdf

> 编程语言
Open source

Adobe's reference implementation of the OpenPBR BSDF

399 stars0 likes1 views
WebsiteGitHub

About

Adobe's reference implementation of the OpenPBR BSDF

Adobe's 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.


Overview

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:

  • Evaluate the BSDF
  • Sample the BSDF
  • Compute the PDF

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.


Why Open Source?

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.


Key Features

  • Single-include API: #include "openpbr.h" brings in the complete public API — all types, settings, and the full BSDF.
  • Multi-language support: C++, GLSL, CUDA, MSL, or Slang from the same source via a thin interop layer.
  • Self-contained: No globals, no hidden dependencies — everything lives alongside the BSDF.
  • Configurable: Compile-time settings in openpbr_settings.h — LUT storage mode, language target, specialization constants, custom overrides, and more.
  • Fixed-lobe architecture: One struct per material component.
  • Energy-conserving: The BSDF is designed to be energy-conserving for most common configurations, using precomputed LUTs for multiple-scattering compensation.
  • Reciprocal: The BSDF is reciprocal for most configurations. See Path Tracing Direction for the transmission, coat, and fuzz exceptions.

High-Level Architecture

…
  1. 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.
  2. 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.

  3. 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.
  4. 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.
  5. 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.
    • Multiple constructors for OpenPBR_HomogeneousVolume from extinction+albedo, absorption+scattering, or extinction alone.
  6. 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.
  7. 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:

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


Lookup Tables: Dual-Mode Architecture

The BSDF uses precomputed lookup tables (LUTs) for physically accurate energy compensation and fuzz/sheen lobe evaluation:

  • Energy compensation tables: 7 tables for microfacet multiple scattering (ideal/opaque dielectrics, ideal metals)
  • LTC table: Linearly Transformed Cosines for the fuzz/sheen lobe

These tables support two modes via the OPENPBR_USE_TEXTURE_LUTS compile-time switch:

Array Mode (OPENPBR_USE_TEXTURE_LUTS = 0)

  • Tables embedded as constant arrays in shader code
  • No texture bindings needed
  • Software linear/bilinear/trilinear interpolation
  • Larger shader binary size
  • Slower on GPU

Texture Mode (OPENPBR_USE_TEXTURE_LUTS = 1)

  • Tables stored as 1D/2D/3D textures
  • Requires texture binding infrastructure
  • Hardware-accelerated filtering and interpolation
  • Smaller shader binary size
  • Faster on GPU

Array Mode is the default because it eliminates external dependencies on texture assets and binding infrastructure.

Source data format:

  • All LUT data is stored in separate header files in the impl/data/ directory
  • Data is formatted as flattened C arrays matching the original multi-dimensional layout (e.g., array[x][y][z] with rightmost index contiguous)
  • Users can read these files directly to populate GPU textures if needed

Implementation details:

  • Energy tables: 32×32 or 32×32×32 normalized integer values [0, 65535] → [0.0, 1.0]
    • Storage type is auto-selected per language by the interop layer: 16-bit (unsigned short) for C++/MSL/CUDA/Slang; 32-bit (uint) for GLSL — no user action required
  • LTC table: 32×32 vec3 values
  • Both modes use identical indexing and coordinate mappings for exact equivalence

Getting Started

  1. Clone this repository.

  2. Include openpbr.h in your renderer (this provides the complete public API).

  3. Select a shading language backend. Three backends are auto-detected from built-in compiler macros:

    • CUDA (__CUDACC__), MSL (__METAL_VERSION__), and C++ (__cplusplus) are detected automatically.
    • GLSL is the default fallback when none of the above macros are defined — no explicit setting needed.
    • Slang has no standard built-in detection macro, so it requires 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.

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

  5. Optional — Pre-include hooks: Define any of the following before openpbr.h to customize behavior:

    • Fast math: 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.
    • Conflict suppression: Set OPENPBR_USE_CUSTOM_SATURATE = 1 if your host already defines saturate(); set `OPENPBR_USE_CUSTOM_VEC_TYP

Issues· 2 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言