Skip to content
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

Editor: Make IOR configurable. #28028

Merged
merged 1 commit into from
Mar 30, 2024
Merged

Editor: Make IOR configurable. #28028

merged 1 commit into from
Mar 30, 2024

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Mar 29, 2024

Related issue: -

Description

This PR makes sure the ior property of MeshPhysicalMaterial can directly be configured and not just indirectly via reflectivity.

@Mugen87 Mugen87 added this to the r164 milestone Mar 29, 2024
@@ -111,6 +111,11 @@ function SidebarMaterial( editor ) {
const materialReflectivity = new SidebarMaterialNumberProperty( editor, 'reflectivity', strings.getKey( 'sidebar/material/reflectivity' ) );
container.add( materialReflectivity );

// ior

const materialIOR = new SidebarMaterialNumberProperty( editor, 'ior', strings.getKey( 'sidebar/material/ior' ), [ 1, 2.333 ], 3 );
Copy link
Collaborator Author

@Mugen87 Mugen87 Mar 29, 2024

Choose a reason for hiding this comment

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

The documentation states that MeshPhysicalMaterial.ior has a range of [1, 2.333]. However, there are glTF assets with a higher IOR value. E.g. https://github.com/KhronosGroup/glTF-Sample-Assets/tree/main/Models/DispersionTest uses 2.42. Should we allow a higher range in the editor e.g. [ 1, 3 ]?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we know where that range come from? The glTF docs don't seem to specify an upper bound:

Valid values for ior are numbers greater than or equal to 1. In addition, a value of 0 is allowed.

But I agree that a max of something like 3 is good enough.

Copy link
Collaborator

@donmccurdy donmccurdy Mar 29, 2024

Choose a reason for hiding this comment

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

glTF allows IOR values of 0, disallows values between 0 and 1 (exclusive), and allows 1 to infinity (inclusive).

https://github.com/KhronosGroup/glTF/blob/ae1a90baf009203760304f06ed5645402de9dc09/extensions/2.0/Khronos/KHR_materials_ior/schema/material.KHR_materials_ior.schema.json#L12-L20

2.42 is a typical value for diamonds according the KHR_materials_ior spec, but values >2 are otherwise physically unusual. Occasionally I see glTF files containing ior=0 or ior=1000+, these are not physically-plausible but are occasionally useful to give ...

"...full weight to layer, i.e., the Fresnel term evaluates to 1 independent of the view or light direction. It is useful in combination with KHR_materials_specular to seamlessly support the specular-glossiness workflow."

In other words, it's a trick that is very useful when converting materials from the spec/gloss PBR workflow to the metal/rough workflow.

Copy link
Collaborator Author

@Mugen87 Mugen87 Mar 30, 2024

Choose a reason for hiding this comment

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

Thanks for the feedback. I'll merge the PR with the current settings so it aligns to the documentation. But it seems we should reconsider the current IOR range and think about adapting the glTF policy.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If we need an example with higher IOR, a good way to test is to start with this model:

https://github.com/KhronosGroup/glTF-Sample-Assets/blob/main/Models/SpecGlossVsMetalRough/glTF-Binary/SpecGlossVsMetalRough.glb

It shows two bottles, one metal/rough and one spec/gloss. We don't support spec/gloss, so the latter will appear white in the editor:

Screenshot 2024-03-30 at 3 14 51 PM

If you convert the second bottle to metal/rough...

gltf-transform metalrough input.glb output.glb

... then the second bottle will include a material with ior=1000, and both bottles should appear identical:

Screenshot 2024-03-30 at 3 15 40 PM

@Mugen87 Mugen87 merged commit 7624487 into mrdoob:dev Mar 30, 2024
11 checks passed
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