Skip to content

Added OpenPBR material and option to load using glTF #16773

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

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

MiiBond
Copy link
Contributor

@MiiBond MiiBond commented Jun 19, 2025

No description provided.

@bjsplat
Copy link
Collaborator

bjsplat commented Jun 19, 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 Jun 19, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Jun 19, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Jun 19, 2025

*
* This offers the main features of a standard PBR material.
* For more information, please refer to the documentation :
* https://doc.babylonjs.com/features/featuresDeepDive/materials/using/introToPBR
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to change that headline and mention that PBR2 is an optimized version of PBR that remains for backward compat

Copy link
Contributor

Choose a reason for hiding this comment

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

Also is PBR2Material better for a name? All the materials should end with "Material"

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 changed it to PBR2Material, as you suggest but I'm viewing that as a WIP name.
What we're interested in building is full OpenPBR support so it's been suggested here that we should just name it OpenPBRMaterial.

@deltakosh deltakosh requested review from Popov72 and sebavan June 20, 2025 15:33
@bjsplat
Copy link
Collaborator

bjsplat commented Jun 20, 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.

@MiiBond
Copy link
Contributor Author

MiiBond commented Jun 20, 2025

I've been playing with mixins to try to remove a lot of duplicate code from the materials. I figured, if we can do this, it'll make my life easier when working on PBR2. I started with using mixins for some defines like UV1, UV2, etc. and the image-processing defines. Then, I tried actually making the imageProcessing logic into a mixin. This removes a whole bunch of duplicated stuff.
See packages\dev\core\src\Materials\imageProcessing.ts
What do we think about this approach? It seems to work with typing but decorators don't work with anonymous class definitions so I had to apply them manually in the constructor.
If we're okay with this, I was thinking about trying to separate out some of the lighting logic (light map, reflection map, irradiance map, SH, etc.).
Ideally, it would be nice to have a bit more of a separation between the lighting and the material model.

@bjsplat
Copy link
Collaborator

bjsplat commented Jun 20, 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.

1 similar comment
@bjsplat
Copy link
Collaborator

bjsplat commented Jun 23, 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.

import type { ColorCurves } from "./colorCurves";

// Explicit re-export of types to help TypeScript resolve them in declaration files
export type { Observer } from "../Misc/observable";
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 was getting errors in the npm run build:es6 involving ../.. import paths in this mixin.
An AI tool came up with the solution of adding these explicit exports. I don't really understand it but it works. It should be checked by someone who understands issues like this.

@deltakosh deltakosh changed the title Added PBR2 material and option to load using glTF Added OpenPBR material and option to load using glTF Jun 24, 2025
@bjsplat
Copy link
Collaborator

bjsplat commented Jun 24, 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.

@MiiBond
Copy link
Contributor Author

MiiBond commented Jun 24, 2025

I've noticed another issue with my changes that I don't understand. When running a Playground in Typescript mode, I get an error about not being able to find the BABYLON namespace. Any ideas what I might have done to cause that?

@MiiBond MiiBond force-pushed the mbond/pbr2-test-wip branch from fe87eca to 3a5b609 Compare June 25, 2025 20:37
@bjsplat
Copy link
Collaborator

bjsplat commented Jun 25, 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.

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.

3 participants