-
Notifications
You must be signed in to change notification settings - Fork 372
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
Implement basic support for MaterialX closures in testrender #1533
Implement basic support for MaterialX closures in testrender #1533
Conversation
f459abb
to
d27d521
Compare
float /*rz*/, OSL::Dual2<OSL::Vec3>& wi, | ||
float& pdf) const | ||
float& pdf) const override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This patch looks good to me, thanks! But I'm going to abuse it to open a discussion on the BSDF API:
- Should we return a struct like { weight, pdf } to avoid output args?
- Can we drop the full sg as argument and instead pass a Vec3 wo (meaning I) so you can evaluate them in an SG-less context?
- Does anybody need accurate derivs from wi? If not, can we stop pretending we can compute them?
- Should we add roughness to the output? I believe most renders track it. You can guess it from pdf following a convention (like reversing an isotropic GGX), but wanted to get opinions. A normalized [0-1] roughness can be used as a measure of specularity for AOVs. If we sign off on BSDFs being single lobe the roughness can be just a BSDF property and not an output from sample()/eval().
I volunteer to making any of these changes after you merge this, of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Yes - good idea. I can do that refactor in another PR. Would you have a { weight, pdf, dir } struct for sample() then?
- Yes - good idea.
- Yes - definitely. Only the reflection() and refraction() cases do anything sensible. Do you want to submit a patch that switches to ray cones? That would be a nice simplification for the bsdf API.
- I wouldn't bother with this for now. I prefer keeping testrender minimal for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes { color, wi, pdf } in any order you like works for me. I will do the cone tracing.
} | ||
case MX_SHEEN_ID: | ||
case MX_LAYER_ID: { | ||
OSL_ASSERT(false && "MaterialX closure not yet implemented"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a suggestion on how to implement this. Add a
virtual Color3 filter_base(Vec3 wo);
You call it here, scale the weight of base and just add_bsdf() both. Recurse where needed. Works for us by making assumptions on wi. Eliminates the need of recursion at eval/sample time. De-virtualize and you are ready for GPU.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats what I was thinking too. Maybe it can even just use the existing "get_albedo()" method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, although the coating may want to add absorption according to some thickness. So maybe a different method that by default does 1 - get_albedo().
d27d521
to
ee1d955
Compare
* Extend the bsdf interface in testrender to use Color3 instead of float in preparation for MaterialX closures which are almost all tinted * Add stub parameters and IDs for all MaterialX closures * Register all MaterialX closure types * Implement most MaterialX closures, reusing the existing implementations for now This commit is mainly intended to do the busy work of adding the new closures, no new BSDFs are actually implemented yet. This means that some of the closures are handled in a very rudimentary way, ignoring some key parameters. The intent is to improve support for these over time. Signed-off-by: Chris Kulla <[email protected]>
ee1d955
to
35a2364
Compare
I haven't found any workaround yet ... I'll keep updating |
Any further comments on this PR? |
LGTM! |
…SoftwareFoundation#1533) * Extend the bsdf interface in testrender to use Color3 instead of float in preparation for MaterialX closures which are almost all tinted * Add stub parameters and IDs for all MaterialX closures * Register all MaterialX closure types * Implement most MaterialX closures, reusing the existing implementations for now This commit is mainly intended to do the busy work of adding the new closures, no new BSDFs are actually implemented yet. This means that some of the closures are handled in a very rudimentary way, ignoring some key parameters. The intent is to improve support for these over time. Signed-off-by: Chris Kulla <[email protected]>
Relevant changes: * GPU string fix -- needed missing cast (AcademySoftwareFoundation#1553) * Fix typo error that prevented correct typecheck of ternary (AcademySoftwareFoundation#1552) * testrender now supports the standard MaterialX closure: * testrender improvements: modernize sampler (AcademySoftwareFoundation#1534), switch to cone tracing (AcademySoftwareFoundation#1543), support MaterialX closures (AcademySoftwareFoundation#1533, AcademySoftwareFoundation#1536, AcademySoftwareFoundation#1537, AcademySoftwareFoundation#1538, AcademySoftwareFoundation#1541, AcademySoftwareFoundation#1542, AcademySoftwareFoundation#1547) * Bump LLVM to 14.0 * Help reduce PTX nondeterminism (AcademySoftwareFoundation#1570) See merge request spi/dev/3rd-party/osl-feedstock!30
Extend the bsdf interface in testrender to use Color3 instead of float in preparation for MaterialX closures which are almost all tinted
Add stub parameters and IDs for all MaterialX closures
Register all MaterialX closure types
Implement most MaterialX closures, reusing the existing implementations for now
This commit is mainly intended to do the busy work of adding the new closures, no new BSDFs are actually implemented yet. This means that some of the closures are handled in a very rudimentary way, ignoring some key parameters. The intent is to improve support for these over time.