Skip to content

Conversation

@Popov72
Copy link
Contributor

@Popov72 Popov72 commented Dec 16, 2025

Note that unlike Inspector v1, we don't have a special page for PBRMetallicRoughnessMaterial and PBRSpecularGlossinessMaterial. They now both use the same editing page as PBRMaterial.

This PR is created in draft mode, as #17557 needs to be merged so that I can update my PR accordingly.

@Popov72 Popov72 marked this pull request as draft December 16, 2025 13:43
@bjsplat
Copy link
Collaborator

bjsplat commented Dec 16, 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 Dec 16, 2025

Snapshot stored with reference name:
refs/pull/17562/merge

Test environment:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/17562/merge/index.html

To test a playground add it to the URL, for example:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/17562/merge/index.html#WGZLGJ#4600

Links to test your changes to core in the published versions of the Babylon tools (does not contain changes you made to the tools themselves):

https://playground.babylonjs.com/?snapshot=refs/pull/17562/merge
https://sandbox.babylonjs.com/?snapshot=refs/pull/17562/merge
https://gui.babylonjs.com/?snapshot=refs/pull/17562/merge
https://nme.babylonjs.com/?snapshot=refs/pull/17562/merge

To test the snapshot in the playground with a playground ID add it after the snapshot query string:

https://playground.babylonjs.com/?snapshot=refs/pull/17562/merge#BCU1XR#0

If you made changes to the sandbox or playground in this PR, additional comments will be generated soon containing links to the dev versions of those tools.

@bjsplat
Copy link
Collaborator

bjsplat commented Dec 16, 2025

You have made possible changes to the playground.
You can test the snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/17562/merge/

The snapshot playground with the CDN snapshot (only when available):

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/17562/merge/?snapshot=refs/pull/17562/merge

Note that neither Babylon scenes nor textures are uploaded to the snapshot directory, so some playgrounds won't work correctly.

@bjsplat
Copy link
Collaborator

bjsplat commented Dec 16, 2025

Building or testing the sandbox has failed.

If the tests failed, results can be found here:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/SANDBOX/refs/pull/17562/merge/testResults/

@bjsplat
Copy link
Collaborator

bjsplat commented Dec 16, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Dec 16, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Dec 16, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Dec 16, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Dec 16, 2025

You have changed file(s) that made possible changes to the sandbox.
You can test the sandbox snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/SANDBOX/refs/pull/17562/merge/

@serialize()
public translucencyIntensity: number = 1;

private _useAlbedoToTintRefraction = false;
Copy link
Member

Choose a reason for hiding this comment

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

I don't quite understand this change, but maybe there is a pattern that I just haven't been exposed to... how do the _useAlbedoToTintRefraction and useAlbedoToTintRefaction properties relate? It looks like they can be set independently.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one was a bug, changing the value of useAlbedoToTintRefraction wouldn't trigger a rebuild of the effect. That's why it's now a getter/setter like the other properties.

}
return valueString;
export type HexPropertyLineProps = NumberInputPropertyLineProps & {
numBits?: number;
Copy link
Member

Choose a reason for hiding this comment

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

Should this be further constrained? I assume we don't expect 27 bits for example. Should it be something like numBits?: 32 | 24 | 16 | 8?

setHexVal(GetHexValFromNumber(props.value));
}, [props.value]);
setHexVal(GetHexValFromNumber(props.value, props.numBits));
}); // we don't set [props.value] as dependency because several string representations can map to the same number (e.g., 0x0, 0x00, 0x0000, etc.)
Copy link
Member

Choose a reason for hiding this comment

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

But the hex string should only change if either the value or numBits props change, right? So shouldn't this be:

Suggested change
}); // we don't set [props.value] as dependency because several string representations can map to the same number (e.g., 0x0, 0x00, 0x0000, etc.)
}, [props.value, props.numBits]);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, because if you have 0x00000001 in the edit box, and update it to be 0x001 for eg, this won't trigger an update on blur and the field won't be update to 0x00000001.


export type TextInputProps = PrimitiveProps<string> & {
validator?: (value: string) => boolean;
validateOnBlur?: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

The idea here is to validate either every time the value changes (e.g. a keystroke) or defer validation until the text input loses focus?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly. If validateOnBlur is set, validation will only occur during the onBlur event, not with every keystroke.

Comment on lines 56 to 60
event.stopPropagation();
event.preventDefault();
if (props.validateOnBlur) {
tryCommitValue(event.currentTarget.value);
}
Copy link
Member

Choose a reason for hiding this comment

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

We could still call HandleOnBlur. It's only two lines of code duplicated, but maybe it would be more in the future?

Suggested change
event.stopPropagation();
event.preventDefault();
if (props.validateOnBlur) {
tryCommitValue(event.currentTarget.value);
}
HandleOnBlur(event);
if (props.validateOnBlur) {
tryCommitValue(event.currentTarget.value);
}


function CheckNormalMapPropertyNames(mat: MaterialWithNormalMaps): mat is { invertNormalMapX: boolean; invertNormalMapY: boolean } {
return (mat as any).invertNormalMapX !== undefined;
}
Copy link
Member

Choose a reason for hiding this comment

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

We can avoid the any cast:

Suggested change
}
type MaterialWithPublicNormalMaps = {
invertNormalMapX: boolean;
invertNormalMapY: boolean;
};
type MaterialWithInternalNormalMaps = {
_invertNormalMapX: boolean;
_invertNormalMapY: boolean;
};
export type MaterialWithNormalMaps = MaterialWithPublicNormalMaps | MaterialWithInternalNormalMaps;
function IsMaterialWithPublicNormalMaps(mat: MaterialWithNormalMaps): mat is MaterialWithPublicNormalMaps {
return (mat as MaterialWithPublicNormalMaps).invertNormalMapX !== undefined;
}

Comment on lines 30 to 41
{CheckNormalMapPropertyNames(material) && (
<>
<BoundProperty component={SwitchPropertyLine} label="Invert X Axis" target={material} propertyKey="invertNormalMapX" />
<BoundProperty component={SwitchPropertyLine} label="Invert Y Axis" target={material} propertyKey="invertNormalMapY" />
</>
)}
{!CheckNormalMapPropertyNames(material) && (
<>
<BoundProperty component={SwitchPropertyLine} label="Invert X Axis" target={material} propertyKey="_invertNormalMapX" />
<BoundProperty component={SwitchPropertyLine} label="Invert Y Axis" target={material} propertyKey="_invertNormalMapY" />
</>
)}
Copy link
Member

Choose a reason for hiding this comment

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

You can just call the check function once:

Suggested change
{CheckNormalMapPropertyNames(material) && (
<>
<BoundProperty component={SwitchPropertyLine} label="Invert X Axis" target={material} propertyKey="invertNormalMapX" />
<BoundProperty component={SwitchPropertyLine} label="Invert Y Axis" target={material} propertyKey="invertNormalMapY" />
</>
)}
{!CheckNormalMapPropertyNames(material) && (
<>
<BoundProperty component={SwitchPropertyLine} label="Invert X Axis" target={material} propertyKey="_invertNormalMapX" />
<BoundProperty component={SwitchPropertyLine} label="Invert Y Axis" target={material} propertyKey="_invertNormalMapY" />
</>
)}
{CheckNormalMapPropertyNames(material) ? (
<>
<BoundProperty component={SwitchPropertyLine} label="Invert X Axis" target={material} propertyKey="invertNormalMapX" />
<BoundProperty component={SwitchPropertyLine} label="Invert Y Axis" target={material} propertyKey="invertNormalMapY" />
</>
) : (
<>
<BoundProperty component={SwitchPropertyLine} label="Invert X Axis" target={material} propertyKey="_invertNormalMapX" />
<BoundProperty component={SwitchPropertyLine} label="Invert Y Axis" target={material} propertyKey="_invertNormalMapY" />
</>
)}

<BoundProperty component={Color3PropertyLine} label="Reflectance Color" target={material} propertyKey="_metallicReflectanceColor" isLinearMode />
<BoundProperty
component={SwitchPropertyLine}
label="Use only metallic from MetallicReflectance texture"
Copy link
Member

Choose a reason for hiding this comment

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

This is a really long label. Could we change the label to something shorter like "Metallic Only", and then set the long string in the description prop?

],
});

propertiesService.onPropertyChanged.add((changeInfo) => {
Copy link
Member

Choose a reason for hiding this comment

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

Store the observer, and then call pbrMaterialPropertyChangedObserver.remove() from the dispose function down around line 242.

Suggested change
propertiesService.onPropertyChanged.add((changeInfo) => {
const pbrMaterialPropertyChangedObserver = propertiesService.onPropertyChanged.add((changeInfo) => {

<SyncedSliderPropertyLine label="G" value={color.g * 255} min={0} max={255} onChange={(value) => onSliderChange(value, "g")} />
<SyncedSliderPropertyLine label="B" value={color.b * 255} min={0} max={255} onChange={(value) => onSliderChange(value, "b")} />
{color instanceof Color4 && <SyncedSliderPropertyLine label="A" value={color.a} min={0} max={1} step={0.01} onChange={(value) => onSliderChange(value, "a")} />}
<SyncedSliderPropertyLine label="R" value={(color?.r ?? 0) * 255} min={0} max={255} onChange={(value) => onSliderChange(value, "r")} />
Copy link
Member

Choose a reason for hiding this comment

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

How are you ending up in a situation where the color us null or undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

translucencyColor in material.subSurface can be null, so I had to add nullable to the corresponding BoundProperty. When I did that, I got errors like "accessing .r field for a null object", that's why I had to update these lines of code.

@ryantrem
Copy link
Member

@Popov72 #17557 got merged but @georginahalpern is working on a new way in #17568.

@bjsplat
Copy link
Collaborator

bjsplat commented Dec 17, 2025

Graph tools CI has failed you can find the test results at:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/TOOLS/refs/pull/17562/merge/testResults/

@bjsplat
Copy link
Collaborator

bjsplat commented Dec 17, 2025

Building or testing the sandbox has failed.

If the tests failed, results can be found here:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/SANDBOX/refs/pull/17562/merge/testResults/

@bjsplat
Copy link
Collaborator

bjsplat commented Dec 17, 2025

Building or testing the playground has failed.

If the tests failed, results can be found here:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/17562/merge/testResults/

@bjsplat
Copy link
Collaborator

bjsplat commented Dec 17, 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 Dec 17, 2025

Snapshot stored with reference name:
refs/pull/17562/merge

Test environment:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/17562/merge/index.html

To test a playground add it to the URL, for example:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/17562/merge/index.html#WGZLGJ#4600

Links to test your changes to core in the published versions of the Babylon tools (does not contain changes you made to the tools themselves):

https://playground.babylonjs.com/?snapshot=refs/pull/17562/merge
https://sandbox.babylonjs.com/?snapshot=refs/pull/17562/merge
https://gui.babylonjs.com/?snapshot=refs/pull/17562/merge
https://nme.babylonjs.com/?snapshot=refs/pull/17562/merge

To test the snapshot in the playground with a playground ID add it after the snapshot query string:

https://playground.babylonjs.com/?snapshot=refs/pull/17562/merge#BCU1XR#0

If you made changes to the sandbox or playground in this PR, additional comments will be generated soon containing links to the dev versions of those tools.

@bjsplat
Copy link
Collaborator

bjsplat commented Dec 17, 2025

You have changed file(s) that made possible changes to the sandbox.
You can test the sandbox snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/SANDBOX/refs/pull/17562/merge/

@bjsplat
Copy link
Collaborator

bjsplat commented Dec 17, 2025

You have made possible changes to the playground.
You can test the snapshot here:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/17562/merge/

The snapshot playground with the CDN snapshot (only when available):

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/17562/merge/?snapshot=refs/pull/17562/merge

Note that neither Babylon scenes nor textures are uploaded to the snapshot directory, so some playgrounds won't work correctly.

@bjsplat
Copy link
Collaborator

bjsplat commented Dec 17, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Dec 17, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Dec 17, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Dec 17, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants