Skip to content

Open-sourcing Imageworks BSDF library #1986

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aconty
Copy link
Contributor

@aconty aconty commented May 6, 2025

Description

Sony Pictures Imageworks BSDF library (working title BSDL) is here published and introduced to testrender. It is a header only library where everything is inlined and can be used on GPU. Although we haven't kept the BSDFs up to date with the latest research in the last couple of years, I hope you, at least, like the infrastructure. There are three main items in this PR

  1. Put BSDL as an INTERFACE cmake library in src/libbsdl.
  2. Introduce the switch/case automatic pseudo virtual methods in testrender to handle all the existing BSDFs.
  3. As an example integrate SPI's ThinLayer BSDF in testrender and add a test for it.

BSDL is a self-contained lib depending only on Imath. There is not even a need to link to OSL and it can be used as a build only dependency.

Inside libbsdl directory there is a README with further information, but documentation is the usual weak point with production code. We use this code as-is directly for making movies with our in-house render, and we welcome everybody to contribute theirs. The name "BSDL" is one of my half-broken name ideas and I'm very much open to suggestions.

I recommend to first look at my changes to testrender, integration was very easy. Then dive in the internals if you want. Credits for this code go mainly to Chris Kulla and me (Alejandro Conty), but there are also other smaller contributions from other Imageworks members, including alumni Laura Lediaev who wrote the LTC sheen implementation.

Tests

Added render-spi-thinlayer for the example BSDF

Checklist:

  • I have read the contribution guidelines.
  • I have updated the documentation, if applicable.
  • I have ensured that the change is tested somewhere in the testsuite (adding new test cases if necessary).
  • My code follows the prevailing code style of this project. If I haven't
    already run clang-format v17 before submitting, I definitely will look at
    the CI test that runs clang-format and fix anything that it highlights as
    being nonconforming.

Sony Pictures Imageworks BSDF library (working title BSDL) is here
published and introduced to testrender. It is a header only library
where everything is inlined and can be used on GPU. Although we haven't
kept the BSDFs up to date with the latest research in the last couple of
years, I hope you, at least, like the infrastructure. There are three
main items in this PR
  1. Put BSDL as an INTERFACE cmake library in src/libbsdl.
  2. Introduce the switch/case automatic pseudo virtual methods in
     testrender to handle all the existing BSDFs.
  3. As an example integrate SPI's ThinLayer BSDF in testrender and add
     a test for it.

BSDL is a self-contained lib depending only on Imath. There is not even
a need to link to OSL and it can be used as a build only dependency.

Inside libbsdl directory there is a README with further information, but
documentation is the usual weak point with production code. We use this
code as-is directly for making movies with our in-house render, and we
welcome everybody to contribute theirs. The name "BSDL" is one of my
half-broken name ideas and I'm very much open to suggestions.

I recommend to first look at my changes to testrender, integration was
very easy. Then dive in the internals if you want. Credits for this code
go mainly to Chris Kulla and me (Alejandro Conty), but there are also
other smaller contributions from other Imageworks members, including
alumni Laura Lediaev who wrote the LTC sheen implementation.

Signed-off-by: Alejandro Conty <[email protected]>
@tgrant-nv
Copy link
Contributor

Very cool, Alex! I haven't had a chance to go through the source yet, but I did run all of the render-* tests in OptiX mode and the output looks good.

@aconty
Copy link
Contributor Author

aconty commented May 6, 2025

Great, you will probably want to see the code removal in shading.cpp because of switch/case -> dispatch()

@lgritz
Copy link
Collaborator

lgritz commented May 13, 2025

Comments from anybody about this?

@Antonio-Bolt
Copy link

We are going to look at it and come back asap. In the previous testrender implementation I noticed a potential issue with the Oren nayar closure losing a factor of PI at every bounce, going through the closures one by one is painful so we are hoping that this update provides a more robust start.

@lgritz
Copy link
Collaborator

lgritz commented May 19, 2025

Hi, everybody. My plan is to merge this on Friday of this week if no significant revision is needed -- that allows the rest of the work week to comment, as well as Thursday's TSC meeting to discuss live.

This will only go in main, and so is subject to as much post-merge revision as we want, up to the point of the next major release, so there really is not any risk with getting something wrong and wanting to change the APIs organization. The APIs don't need to be locked down until late this year.

@aconty
Copy link
Contributor Author

aconty commented May 19, 2025

This change only affects testrender and it does not break it. The BSDL interface is new and we can change it as much as we want until some other render starts using it.

@jstone-lucasfilm
Copy link
Member

I'm very excited to try out this change, and the question in my mind is whether it brings OSL testrender into closer alignment with other open-source renderers, or whether perhaps it creates unintended divergences.

Here's the standard render comparison that we run for the MaterialX project, comparing reference renders between OSL testrender and MaterialX GLSL (with NVIDIA MDL coming soon), and I'd like to try running this same comparison with the latest updates to the OSL BSDFs:

MaterialXRenderTests_04_10_2025_GitHub.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants