-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
[glTF] How to support Specular-Glossiness in Three.js #10985
Comments
/cc @donmccurdy |
/cc @WestLangley |
The short answers is yes, this is doable. One thing about the metalness-roughness nomenclature is it is absolutely clear what these terms mean. Also, the two concepts are separable; you can have a non-rough metal and a rough non-metal. This is one reason we selected the metalness-roughness API for The specular-glossiness nomenclature is not so clear for novice users. Although I understand that specular is the specular reflectance of the material, I have no idea what glossiness is. According to the glTF spec, glossiness = 1 - roughness, so we can go with that. // Given glTF aims to be a de-facto standard, however, and given there is a proposal to support specular-glossiness workflow as an extension, it seems reasonable that three.js should support it, too. Note that So, if we want the option to input vec3 specularColor = specular;
specularColor *= texture2D( specularMap, vUv ).rgb;
float glossinessFactor = glossiness;
glossinessFactor *= texture2D( glossinessMap, vUv ).a;
PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularRoughness = clamp( 1.0 - glossinessFactor, 0.04, 1.0 );
material.specularColor = specularColor.rgb; Notice, there is no reason to "convert" from one API to the other. // As far as the API is concerned, I would prefer to leave material.specular (THREE.Color)
material.specularMap (RGB channesl of RGBA texture)
material.glossiness (float, in [0,1])
material.glossinessMap (Alpha channel of RGBA texture) I can implement this if there is agreement. |
Thanks for the comment. BTW wouldn't material.diffuseColor be
? |
Feel free! I see no reason why the artist-specified diffuse reflectance of the material ( We are not converting between workflows here. |
Description of the problem
In glTF 2.0 specification, there're two pbr workflows.
Roughness/Metallic and Specular/Glossiness
Roughness/Metallic
https://github.com/sbtron/glTF/blob/30de0b365d1566b1bbd8b9c140f9e995d3203226/specification/2.0/README.md#metallic-roughness-material
Specular/Glossiness (extension)
https://github.com/sbtron/glTF/tree/KHRpbrSpecGloss/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
Currently
MeshStandardMaterial
fits to Roughness/Metalic, but no material for Specular/Glossiness.I'm considering how to support
Spacular/Glossiness
.They use the following properties respectively.
Roughness/Metallic
Fragment shader
Specular/Glossiness
Fragment shader
Reference https://github.com/sbtron/glTF/blob/KHRpbrSpecGloss/extensions/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows/index.html
So, Specular-Glossiness can be implemented by partially replacing properties and fragment shader of
MeshStandardMaterial
.To achieve this, I have three options in my mind.
MeshStandardMaterial
(add a property to switch shader code, like material.specularGlossiness = boolean?). PROS: relatively small change in Three.js core, CONS: dirty design?MeshStandardMaterial
and two materials, one for Roughness/Metallic and another one for Specular/Glossiness, inherit it?). PROS clear design, CONS: relatively big change in Three.js coreGLTF2Loader
uses(Raw)ShaderMaterial
. PROS: no change in Three.js core, CONS: onlyGLTF2Loader
can use Specular/GlossinessI prefer 2.
Any thoughts?
BTW if there's existing threads where you folks discussed it, let me know.
Three.js version
Browser
OS
Hardware Requirements (graphics card, VR Device, ...)
The text was updated successfully, but these errors were encountered: