ScriptSpot

Forum topic · General Scripting

glTF material - change values for all selected materials or default settings

By CrewmanInRed · 2024-02-27

Description

I have 877 materials in a very large file and I'm testing some software that uses glTF materials. According to the documentation, when there is no texture map in the roughness slot it's default value is 0 (mirror-like). If a texture is added it switches to a value of 1. The problem is that using the scene converter sets all the material's roughness to 0, so everything is shiny by default, which is stupid. Is there a way to switch that value to 1 for all selected materials at the same time? Or is there a way to change the default to 1 when converting to glTF instead of 0?

Comments (1)

SimonBourgeois · 2024-05-11

Hi Jeff,
select objects that needs to have their materials updated, then execute this:
(
local matArr = for o in selection where iskindof o.material glTFMaterial collect o.material
for m in matArr do m.roughness = 1
)
it will work for individual glTF material, let me know if you need it to work for Multi/Sub-Objects materials.