Fix T70666: FBX IO: Add support for new emission option of Principled BSDF.
This commit is contained in:
parent
3a0cc9946f
commit
c4f78f1493
Notes:
blender-bot
2023-02-14 19:06:40 +01:00
Referenced by issue #70666, Exporting to FBX ignores the emission socket on the Principled BSDF
|
@ -21,7 +21,7 @@
|
|||
bl_info = {
|
||||
"name": "FBX format",
|
||||
"author": "Campbell Barton, Bastien Montagne, Jens Restemeier",
|
||||
"version": (4, 19, 0),
|
||||
"version": (4, 20, 0),
|
||||
"blender": (2, 81, 6),
|
||||
"location": "File > Import-Export",
|
||||
"description": "FBX IO meshes, UV's, vertex colors, materials, textures, cameras, lamps and actions",
|
||||
|
|
|
@ -1307,9 +1307,9 @@ def fbx_data_material_elements(root, ma, scene_data):
|
|||
elem_props_template_set(tmpl, props, "p_color", b"DiffuseColor", ma_wrap.base_color)
|
||||
# Not in Principled BSDF, so assuming always 1
|
||||
elem_props_template_set(tmpl, props, "p_number", b"DiffuseFactor", 1.0)
|
||||
# Not in Principled BSDF, so assuming always 0
|
||||
elem_props_template_set(tmpl, props, "p_color", b"EmissiveColor", ma_wrap.base_color)
|
||||
elem_props_template_set(tmpl, props, "p_number", b"EmissiveFactor", 0.0)
|
||||
# Principled BSDF only has an emissive color, so we assume factor to be always 1.0.
|
||||
elem_props_template_set(tmpl, props, "p_color", b"EmissiveColor", ma_wrap.emission_color)
|
||||
elem_props_template_set(tmpl, props, "p_number", b"EmissiveFactor", 1.0)
|
||||
# Not in Principled BSDF, so assuming always 0
|
||||
elem_props_template_set(tmpl, props, "p_color", b"AmbientColor", ambient_color)
|
||||
elem_props_template_set(tmpl, props, "p_number", b"AmbientFactor", 0.0)
|
||||
|
@ -1809,7 +1809,7 @@ PRINCIPLED_TEXTURE_SOCKETS_TO_FBX = (
|
|||
("alpha_texture", b"TransparencyFactor"), # Will be inverted in fact, not much we can do really...
|
||||
# ("base_color_texture", b"TransparentColor"), # Uses diffuse color in Blender!
|
||||
# ("emit", "emit", b"EmissiveFactor"),
|
||||
# ("diffuse", "diffuse", b"EmissiveColor"), # Uses diffuse color in Blender!
|
||||
("emission_color_texture", b"EmissiveColor"),
|
||||
# ("ambient", "ambient", b"AmbientFactor"),
|
||||
# ("", "", b"AmbientColor"), # World stuff in Blender, for now ignore...
|
||||
("normalmap_texture", b"NormalMap"),
|
||||
|
|
|
@ -1427,6 +1427,10 @@ def blen_read_material(fbx_tmpl, fbx_obj, settings):
|
|||
# elem_props_get_color_rgb(fbx_props, b'ReflectionColor', const_color_white)
|
||||
# (x / 7.142) is only a guess, cycles usable range is (0.0 -> 0.5)
|
||||
ma_wrap.normalmap_strength = elem_props_get_number(fbx_props, b'BumpFactor', 2.5) / 7.142
|
||||
# For emission color we can take into account the factor, but only for default values, not in case of texture.
|
||||
emission_factor = elem_props_get_number(fbx_props, b'EmissiveFactor', 1.0)
|
||||
ma_wrap.emission_color = [c * emission_factor
|
||||
for c in elem_props_get_color_rgb(fbx_props, b'EmissiveColor', const_color_black)]
|
||||
|
||||
nodal_material_wrap_map[ma] = ma_wrap
|
||||
|
||||
|
@ -3111,6 +3115,9 @@ def load(operator, context, filepath="",
|
|||
elif lnk_type == b'Bump':
|
||||
# TODO displacement...
|
||||
"""
|
||||
elif lnk_type in {b'EmissiveColor'}:
|
||||
ma_wrap.emission_color_texture.image = image
|
||||
texture_mapping_set(fbx_lnk, ma_wrap.emission_color_texture)
|
||||
else:
|
||||
print("WARNING: material link %r ignored" % lnk_type)
|
||||
|
||||
|
|
Loading…
Reference in New Issue