godot
godot copied to clipboard
Add gltf importer support for KHR_materials_specular extension
Please see the discussion/issue which prompted this patch here.
I think this is the closest we can get to supporting this extension in Godot. It provides the ability for a user to set the "IOR level" (Specular) for a material in Blender and have that translated to the Specular attribute when importing into Godot.
@frkntlr I am having some trouble understanding what your comment is saying. I see you are requesting changes but I do not understand what changes you would like madez
The specular value in the screenshot matches blender: doesn't that mean it is correct?
@lyuma I edited the comment again, made it clearer.
The problem here is there are 3 different systems Blender <> GLTF <> Godot None of these represent the specular values in the same way, so at the moment we have to do a best-effort. I think this is better than it being forced to 0.5 all the time.
I forgot to put in the original post that this will only work from Blender 4.0 onwards. On 3.x and below there is an issue with the GLTF exporter where the KHR_specular section is not generated if there is more than one material.
The specular value that appears in the godot material appears as 0.92. The value in Blender is 0.862205. It does not take the part other than 3 digits in the value and rounds the number. It seems to be valid not only for specular but also for other values. You can understand from the pictures I attached.
Maybe the Specular Tint is not quite RGB (1,1,1)?
When I try to open the glb file via blender again. It converts the Specular value to 0.5.
This is probably an issue with the GLTF Blender plugin. Here, when I import a GLTF back into Blender it seems to set the Specular Tint instead of setting IOR level.
Maybe the Specular Tint is not quite RGB (1,1,1)?
Yes, I used RGB(0.8,0.8,0.8,0.8,0.8,0.8) instead of RGB(1,1,1). This value is the value we create in the default Blender. Isn't this a problem? In a game that will be created using many materials instead of textures, there will be a slight difference in this value.
Maybe the Specular Tint is not quite RGB (1,1,1)?
Yes, I used RGB(0.8,0.8,0.8,0.8,0.8,0.8) instead of RGB(1,1,1). This value is the value we create in the default Blender. Isn't this a problem? In a game that will be created using many materials instead of textures, there will be a slight difference in this value.
In Blender 4.0 the default is RGB(1.0, 1.0, 1.0). Sadly I cannot see any way to correctly detect the IOR Level if Specular Tint is not this default value. Until the Godot shader is changed to support Specular Tint, or the GLTF format changes to include the "raw" IOR level
Is there anything stopping this being merged? I think this offers a good interim solution whilst the GLTF format does not provide for a "perfect" solution
We're still trying to complete the Godot Engine 4.3 blockers.
For this pr, there's still some failing cicd actions.
Sorry I didn't see that come up before, hopefully I've addressed it now.
@lorddevereux Can you take a look at the review comments above? This should be good to merge afterwards.