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

MeshPhysicalMaterial: Added .ior property #20322

Merged
merged 4 commits into from
Sep 17, 2020
Merged

Conversation

WestLangley
Copy link
Collaborator

@WestLangley WestLangley commented Sep 11, 2020

This is appears to be compatible with where the glTF spec is heading, and it allows MeshPhysicalMaterial to retain its [0, 1] reflectivity property.

/ping @donmccurdy

todo: update docs, ts

@mrdoob mrdoob added this to the r121 milestone Sep 11, 2020
@donmccurdy
Copy link
Collaborator

Thanks, I like this addition!

Is our .reflectivity similar to .specular in KHR_materials_specular? If so, could/should the interaction be multiplying derived F0, rather than one property overwriting the other? See KHR_materials_ior#interaction-with-other-extensions and KHR_materials_specular#interaction-with-other-extensions).

@WestLangley
Copy link
Collaborator Author

@donmccurdy Using glTF terminology, and ignoring the optional texture,

dielectricSpecularF0 = 0.04 * specularFactor * specularColorFactor;
dielectricSpecularF90 = 1.0 * specularFactor;

In three.js, .reflectivity, which is normalized to [0, 1], can be varied to effectively change the 0.04 constant to a value in [0, 0.16]. Setting .ior is an alternate way of doing the same thing.

specularFactor, in [0, 1], is for artistic control, and is used to dampen the specular contribution -- or remove it completely.

Is there anything here that does not seem right to you?

@WestLangley
Copy link
Collaborator Author

/ping @donmccurdy Friendly reminder. :-)

@donmccurdy
Copy link
Collaborator

donmccurdy commented Sep 16, 2020

Ok, thanks! I'd like to support both KHR_materials_ior and KHR_materials_specular in MeshPhysicalMaterial. But I actually don't have much of a preference whether we adopt their naming. The term IOR is also used in Blender and Houdini's principled shaders, and in Autodesk's Standard Surface, so I think it's likely to be more familiar to artists. Whether it's familiar to most three.js users is another question.

Given that GLTFLoader could easily read the KHR_materials_ior value and set .reflectivity without this, do you think it is worthwhile to support both? Should our long-term goal be to remove .reflectivity?

@WestLangley
Copy link
Collaborator Author

WestLangley commented Sep 16, 2020

My intention was to support KHR_materials_ior via this PR. It allows both the loader and the user to set the IOR. It also allows the user to retrieve the IOR via the getter.

MeshPhysicalMaterial was designed to have [0, 1] properties. Consequently, dielectric specular reflectance was remapped and named reflectivity.

Personally, I think it is beneficial to retain both. Certainly for now.

//

My plan is to add support for KHR_materials_specular soon.

@donmccurdy
Copy link
Collaborator

Ok, sounds good!

@mrdoob mrdoob merged commit 538533d into mrdoob:dev Sep 17, 2020
@mrdoob
Copy link
Owner

mrdoob commented Sep 17, 2020

Thanks!

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.

None yet

3 participants