Skip to content

Add OpenPBR's base_diffuse_roughness material parameter #16183

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

Closed

Conversation

virtualzavie
Copy link
Contributor

@virtualzavie virtualzavie commented Feb 12, 2025

This PR implements the base_diffuse_roughness parameter from the OpenPBR specification.

As a first step, the PR plugs the new diffuse roughness parameter directly into the Disney diffuse model currently implemented.
A future task will be to implement the Energy Conserving Oren-Nayar model used by OpenPBR.

Test scene:
https://playground.babylonjs.com/?snapshot=refs/pull/16183/merge#MXACV7

A question for maintainers: this changes the behaviour of Babylon.js, as a different roughness is now used for the diffuse lobe. How do we want to handle the case where no diffuse roughness is passed? I assume we ma want to detect that case and assign the specular roughness to it?

@bjsplat
Copy link
Collaborator

bjsplat commented Feb 12, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Feb 13, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

Comment on lines +1021 to +1025
#endif
, 0.
#ifdef BASE_DIFFUSE_ROUGHNESS
, 0.
, vec2(0., 0.)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should be done here?

, in float baseDiffuseRoughness
#ifdef BASE_DIFFUSE_ROUGHNESS
, in float baseDiffuseRoughnessTexture
, in vec2 vBaseDiffuseRoughnessInfos
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've mimicked what I've seen done in other blocks, but it's not clear to me how those vXYZInfos are supposed to be used.

@bjsplat
Copy link
Collaborator

bjsplat commented Feb 13, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Feb 13, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Feb 13, 2025

@virtualzavie virtualzavie marked this pull request as ready for review February 13, 2025 19:30
@bjsplat
Copy link
Collaborator

bjsplat commented Feb 13, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Feb 13, 2025

@sebavan
Copy link
Member

sebavan commented Feb 17, 2025

Moving to draft until we discuss further about it tomorrow :-)

@sebavan sebavan marked this pull request as draft February 17, 2025 22:07
@@ -2319,6 +2359,11 @@ export abstract class PBRBaseMaterial extends PushMaterial {
}

ubo.updateFloat("baseWeight", this._baseWeight);
if (this._baseDiffuseRoughness !== null && this._baseDiffuseRoughness !== undefined) {
ubo.updateFloat("baseDiffuseRoughness", this._baseDiffuseRoughness);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ubo.updateFloat("baseDiffuseRoughness", this._baseDiffuseRoughness ?? this._roughness);

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.

4 participants