我对戈多还比较陌生。我在 Krita 中创建了一个图集纹理,在 Blender 中制作了一些模型,导出为 gltf,并将它们导入到 Godot 中。
现在,在 Godot 中,如何调整模型每个单独实例的不透明度?
我正在尝试获得某种不透明度的动画。我可以用代码来完成它 - 它不需要通过编辑器。
我原本希望用动画在 Blender 中设置不透明度的动画,但似乎不会导入动画材质,因为只使用了基本的 Principled BSDF 着色器..(也许这不是真的?)但即使我可以只需在代码中调整“不透明度”变量,就足够了。
蒂亚!
我终于弄清楚了。这就是我所做的:
var material:StandardMaterial3D = null
func _ready() -> void:
# 1. get the material off of the mesh, COPY it, and assign it back
material = mesh.get_active_material(0).duplicate() as StandardMaterial3D
# we can use override material to write it back:
mesh.set_surface_override_material(0, material)
# 2. turn TRANSPARENCY mode on
material.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
# 3. now we can SET the opacity for this instance only via albedo_color.a
material.albedo_color.a = 0.5 # from 0.0 (invisible) to 1.0 (opaque)
注意,如果您能够在材质资源上启用resource_local_to_scene,则可以将其打开,然后跳过步骤1中的复制。因为我导入的是GLTF,所以这些设置均被禁用。