Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2018-10-11 17:52:14 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-10-11 17:53:02 +0300
commit305781bd5d04e49249aaaa2f9ae52a2d75f97eb0 (patch)
tree71c8fc69674d2580d6d741898fd104020624da37
parent227fafdfcf4fb441ba1b8477331d543d2cf087af (diff)
FBX import: cleanup: remove 'use_cycles' parameter.
That's now useless in 2.8, we always 'use cycles' materials. :p
-rw-r--r--io_scene_fbx/__init__.py2
-rw-r--r--io_scene_fbx/fbx_utils.py2
-rw-r--r--io_scene_fbx/import_fbx.py300
3 files changed, 97 insertions, 207 deletions
diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py
index 680f1f5c..d1d0389f 100644
--- a/io_scene_fbx/__init__.py
+++ b/io_scene_fbx/__init__.py
@@ -226,8 +226,6 @@ class ImportFBX(bpy.types.Operator, ImportHelper):
def execute(self, context):
keywords = self.as_keywords(ignore=("filter_glob", "directory", "ui_tab"))
- # XXX TODO get rid of this, EEVEE/Cycles use same nodal system...
- keywords["use_cycles"] = True #(context.scene.render.engine == 'CYCLES')
from . import import_fbx
return import_fbx.load(self, context, **keywords)
diff --git a/io_scene_fbx/fbx_utils.py b/io_scene_fbx/fbx_utils.py
index bbf4ac74..ecb6ee28 100644
--- a/io_scene_fbx/fbx_utils.py
+++ b/io_scene_fbx/fbx_utils.py
@@ -1241,7 +1241,7 @@ FBXExportData = namedtuple("FBXExportData", (
FBXImportSettings = namedtuple("FBXImportSettings", (
"report", "to_axes", "global_matrix", "global_scale",
"bake_space_transform", "global_matrix_inv", "global_matrix_inv_transposed",
- "use_custom_normals", "use_cycles", "use_image_search",
+ "use_custom_normals", "use_image_search",
"use_alpha_decals", "decal_offset",
"use_anim", "anim_offset",
"use_custom_props", "use_custom_props_enum_as_string",
diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py
index e092ee3e..8236abb0 100644
--- a/io_scene_fbx/import_fbx.py
+++ b/io_scene_fbx/import_fbx.py
@@ -1334,35 +1334,19 @@ def blen_read_material(fbx_tmpl, fbx_obj, settings):
ma_refl_factor = elem_props_get_number(fbx_props, b'ReflectionFactor', 0.0)
ma_refl_color = elem_props_get_color_rgb(fbx_props, b'ReflectionColor', const_color_white)
- if settings.use_cycles:
- from modules import cycles_shader_compat
- # viewport color
- ma.diffuse_color = ma_diff
-
- ma_wrap = cycles_shader_compat.CyclesShaderWrapper(ma)
- ma_wrap.diffuse_color_set(ma_diff)
- ma_wrap.specular_color_set([c * ma_spec_intensity for c in ma_spec])
- ma_wrap.hardness_value_set(((ma_spec_hardness + 3.0) / 5.0) - 0.65)
- ma_wrap.alpha_value_set(ma_alpha)
- ma_wrap.reflect_factor_set(ma_refl_factor)
- ma_wrap.reflect_color_set(ma_refl_color)
-
- cycles_material_wrap_map[ma] = ma_wrap
- else:
- # TODO, number BumpFactor isnt used yet
- ma.diffuse_color = ma_diff
- ma.specular_color = ma_spec
- ma.alpha = ma_alpha
- if ma_alpha < 1.0:
- ma.use_transparency = True
- ma.transparency_method = 'RAYTRACE'
- ma.specular_intensity = ma_spec_intensity
- ma.specular_hardness = ma_spec_hardness * 5.10 + 1.0
-
- if ma_refl_factor != 0.0:
- ma.raytrace_mirror.use = True
- ma.raytrace_mirror.reflect_factor = ma_refl_factor
- ma.mirror_color = ma_refl_color
+ from modules import cycles_shader_compat
+ # viewport color
+ ma.diffuse_color = ma_diff
+
+ ma_wrap = cycles_shader_compat.CyclesShaderWrapper(ma)
+ ma_wrap.diffuse_color_set(ma_diff)
+ ma_wrap.specular_color_set([c * ma_spec_intensity for c in ma_spec])
+ ma_wrap.hardness_value_set(((ma_spec_hardness + 3.0) / 5.0) - 0.65)
+ ma_wrap.alpha_value_set(ma_alpha)
+ ma_wrap.reflect_factor_set(ma_refl_factor)
+ ma_wrap.reflect_color_set(ma_refl_color)
+
+ cycles_material_wrap_map[ma] = ma_wrap
if settings.use_custom_props:
blen_read_custom_properties(fbx_obj, ma, settings)
@@ -2246,7 +2230,6 @@ def load(operator, context, filepath="",
global_scale=1.0,
bake_space_transform=False,
use_custom_normals=True,
- use_cycles=True,
use_image_search=False,
use_alpha_decals=False,
decal_offset=0.0,
@@ -2310,8 +2293,6 @@ def load(operator, context, filepath="",
cycles_material_wrap_map = {}
image_cache = {}
- if not use_cycles:
- texture_cache = {}
# Tables: (FBX_byte_id -> [FBX_data, None or Blender_datablock])
fbx_table_nodes = {}
@@ -2379,7 +2360,7 @@ def load(operator, context, filepath="",
settings = FBXImportSettings(
operator.report, (axis_up, axis_forward), global_matrix, global_scale,
bake_space_transform, global_matrix_inv, global_matrix_inv_transposed,
- use_custom_normals, use_cycles, use_image_search,
+ use_custom_normals, use_image_search,
use_alpha_decals, decal_offset,
use_anim, anim_offset,
use_custom_props, use_custom_props_enum_as_string,
@@ -2855,8 +2836,7 @@ def load(operator, context, filepath="",
continue
mat = fbx_item[1]
items.append((mat, lnk_prop))
- if settings.use_cycles:
- print("WARNING! Importing material's animation is not supported for Cycles materials...")
+ print("WARNING! Importing material's animation is not supported for Nodal materials...")
for al_uuid, al_ctype in fbx_connection_map.get(acn_uuid, ()):
if al_ctype.props[0] != b'OO':
continue
@@ -2960,33 +2940,6 @@ def load(operator, context, filepath="",
(bool(elem_props_get_enum(fbx_props, b'WrapModeU', 0)),
bool(elem_props_get_enum(fbx_props, b'WrapModeV', 0))))
- if not use_cycles:
- # Simple function to make a new mtex and set defaults
- def material_mtex_new(material, image, tex_map):
- tex = texture_cache.get(image)
- if tex is None:
- tex = bpy.data.textures.new(name=image.name, type='IMAGE')
- tex.image = image
- texture_cache[image] = tex
-
- # copy custom properties from image object to texture
- for key, value in image.items():
- tex[key] = value
-
- # delete custom properties on the image object
- for key in image.keys():
- del image[key]
-
- mtex = material.texture_slots.add()
- mtex.texture = tex
- mtex.texture_coords = 'UV'
- mtex.use_map_color_diffuse = False
-
- # No rotation here...
- mtex.offset[:] = tex_map[0]
- mtex.scale[:] = tex_map[2]
- return mtex
-
for fbx_uuid, fbx_item in fbx_table_nodes.items():
fbx_obj, blen_data = fbx_item
if fbx_obj.id != b'Material':
@@ -2997,127 +2950,83 @@ def load(operator, context, filepath="",
image,
fbx_lnk_type) in connection_filter_reverse(fbx_uuid, b'Texture'):
- if use_cycles:
- if fbx_lnk_type.props[0] == b'OP':
- lnk_type = fbx_lnk_type.props[3]
-
- ma_wrap = cycles_material_wrap_map[material]
+ if fbx_lnk_type.props[0] == b'OP':
+ lnk_type = fbx_lnk_type.props[3]
- # tx/rot/scale
- tex_map = texture_mapping_get(fbx_lnk)
- if (tex_map[0] == (0.0, 0.0, 0.0) and
- tex_map[1] == (0.0, 0.0, 0.0) and
- tex_map[2] == (1.0, 1.0, 1.0) and
- tex_map[3] == (False, False)):
- use_mapping = False
- else:
- use_mapping = True
- tex_map_kw = {
- "translation": tex_map[0],
- "rotation": [-i for i in tex_map[1]],
- "scale": [((1.0 / i) if i != 0.0 else 1.0) for i in tex_map[2]],
- "clamp": tex_map[3],
- }
-
- """
- TODO for clamp:
- # awkward conversion UV clamping to minmax
- node_map.min = (0.0, 0.0, 0.0)
- node_map.max = (1.0, 1.0, 1.0)
-
- if clamp in {(False, False), (True, True)}:
- node_map.use_min = node_map.use_max = clamp[0]
- else:
- node_map.use_min = node_map.use_max = True
- # use bool as index
- node_map.min[not clamp[0]] = -1000000000.0
- node_map.max[not clamp[0]] = 1000000000.0
- """
-
- if lnk_type in {b'DiffuseColor', b'3dsMax|maps|texmap_diffuse'}:
- ma_wrap.diffuse_image_set(image)
- if use_mapping:
- ma_wrap.diffuse_mapping_set(**tex_map_kw)
- elif lnk_type == b'SpecularColor':
- ma_wrap.specular_image_set(image)
- if use_mapping:
- ma_wrap.specular_mapping_set(**tex_map_kw)
- elif lnk_type in {b'ReflectionColor', b'3dsMax|maps|texmap_reflection'}:
- ma_wrap.reflect_image_set(image)
- if use_mapping:
- ma_wrap.reflect_mapping_set(**tex_map_kw)
- elif lnk_type == b'TransparentColor': # alpha
- ma_wrap.alpha_image_set(image)
- if use_mapping:
- ma_wrap.alpha_mapping_set(**tex_map_kw)
- if use_alpha_decals:
- material_decals.add(material)
- elif lnk_type == b'DiffuseFactor':
- pass # TODO
- elif lnk_type == b'ShininessExponent':
- ma_wrap.hardness_image_set(image)
- if use_mapping:
- ma_wrap.hardness_mapping_set(**tex_map_kw)
- # XXX, applications abuse bump!
- elif lnk_type in {b'NormalMap', b'Bump', b'3dsMax|maps|texmap_bump'}:
- ma_wrap.normal_image_set(image)
- ma_wrap.normal_factor_set(texture_bumpfac_get(fbx_obj))
- if use_mapping:
- ma_wrap.normal_mapping_set(**tex_map_kw)
- """
- elif lnk_type == b'Bump':
- ma_wrap.bump_image_set(image)
- ma_wrap.bump_factor_set(texture_bumpfac_get(fbx_obj))
- if use_mapping:
- ma_wrap.bump_mapping_set(**tex_map_kw)
- """
- else:
- print("WARNING: material link %r ignored" % lnk_type)
+ ma_wrap = cycles_material_wrap_map[material]
- material_images.setdefault(material, {})[lnk_type] = (image, tex_map)
- else:
- if fbx_lnk_type.props[0] == b'OP':
- lnk_type = fbx_lnk_type.props[3]
-
- # tx/rot/scale (rot is ignored here!).
- tex_map = texture_mapping_get(fbx_lnk)
-
- mtex = material_mtex_new(material, image, tex_map)
-
- if lnk_type in {b'DiffuseColor', b'3dsMax|maps|texmap_diffuse'}:
- mtex.use_map_color_diffuse = True
- mtex.blend_type = 'MULTIPLY'
- elif lnk_type == b'SpecularColor':
- mtex.use_map_color_spec = True
- mtex.blend_type = 'MULTIPLY'
- elif lnk_type in {b'ReflectionColor', b'3dsMax|maps|texmap_reflection'}:
- mtex.use_map_raymir = True
- elif lnk_type == b'TransparentColor': # alpha
- material.use_transparency = True
- material.transparency_method = 'RAYTRACE'
- material.alpha = 0.0
- mtex.use_map_alpha = True
- mtex.alpha_factor = 1.0
- if use_alpha_decals:
- material_decals.add(material)
- elif lnk_type == b'DiffuseFactor':
- mtex.use_map_diffuse = True
- elif lnk_type == b'ShininessExponent':
- mtex.use_map_hardness = True
- # XXX, applications abuse bump!
- elif lnk_type in {b'NormalMap', b'Bump', b'3dsMax|maps|texmap_bump'}:
- mtex.texture.use_normal_map = True # not ideal!
- mtex.use_map_normal = True
- mtex.normal_factor = texture_bumpfac_get(fbx_obj)
- """
- elif lnk_type == b'Bump':
- mtex.use_map_normal = True
- mtex.normal_factor = texture_bumpfac_get(fbx_obj)
- """
- else:
- print("WARNING: material link %r ignored" % lnk_type)
+ # tx/rot/scale
+ tex_map = texture_mapping_get(fbx_lnk)
+ if (tex_map[0] == (0.0, 0.0, 0.0) and
+ tex_map[1] == (0.0, 0.0, 0.0) and
+ tex_map[2] == (1.0, 1.0, 1.0) and
+ tex_map[3] == (False, False)):
+ use_mapping = False
+ else:
+ use_mapping = True
+ tex_map_kw = {
+ "translation": tex_map[0],
+ "rotation": [-i for i in tex_map[1]],
+ "scale": [((1.0 / i) if i != 0.0 else 1.0) for i in tex_map[2]],
+ "clamp": tex_map[3],
+ }
+
+ """
+ TODO for clamp:
+ # awkward conversion UV clamping to minmax
+ node_map.min = (0.0, 0.0, 0.0)
+ node_map.max = (1.0, 1.0, 1.0)
+
+ if clamp in {(False, False), (True, True)}:
+ node_map.use_min = node_map.use_max = clamp[0]
+ else:
+ node_map.use_min = node_map.use_max = True
+ # use bool as index
+ node_map.min[not clamp[0]] = -1000000000.0
+ node_map.max[not clamp[0]] = 1000000000.0
+ """
+
+ if lnk_type in {b'DiffuseColor', b'3dsMax|maps|texmap_diffuse'}:
+ ma_wrap.diffuse_image_set(image)
+ if use_mapping:
+ ma_wrap.diffuse_mapping_set(**tex_map_kw)
+ elif lnk_type == b'SpecularColor':
+ ma_wrap.specular_image_set(image)
+ if use_mapping:
+ ma_wrap.specular_mapping_set(**tex_map_kw)
+ elif lnk_type in {b'ReflectionColor', b'3dsMax|maps|texmap_reflection'}:
+ ma_wrap.reflect_image_set(image)
+ if use_mapping:
+ ma_wrap.reflect_mapping_set(**tex_map_kw)
+ elif lnk_type == b'TransparentColor': # alpha
+ ma_wrap.alpha_image_set(image)
+ if use_mapping:
+ ma_wrap.alpha_mapping_set(**tex_map_kw)
+ if use_alpha_decals:
+ material_decals.add(material)
+ elif lnk_type == b'DiffuseFactor':
+ pass # TODO
+ elif lnk_type == b'ShininessExponent':
+ ma_wrap.hardness_image_set(image)
+ if use_mapping:
+ ma_wrap.hardness_mapping_set(**tex_map_kw)
+ # XXX, applications abuse bump!
+ elif lnk_type in {b'NormalMap', b'Bump', b'3dsMax|maps|texmap_bump'}:
+ ma_wrap.normal_image_set(image)
+ ma_wrap.normal_factor_set(texture_bumpfac_get(fbx_obj))
+ if use_mapping:
+ ma_wrap.normal_mapping_set(**tex_map_kw)
+ """
+ elif lnk_type == b'Bump':
+ ma_wrap.bump_image_set(image)
+ ma_wrap.bump_factor_set(texture_bumpfac_get(fbx_obj))
+ if use_mapping:
+ ma_wrap.bump_mapping_set(**tex_map_kw)
+ """
+ else:
+ print("WARNING: material link %r ignored" % lnk_type)
- material_images.setdefault(material, {})[lnk_type] = (image, tex_map)
+ material_images.setdefault(material, {})[lnk_type] = (image, tex_map)
# Check if the diffuse image has an alpha channel,
# if so, use the alpha channel.
@@ -3134,24 +3043,13 @@ def load(operator, context, filepath="",
if use_alpha_decals:
material_decals.add(material)
- if use_cycles:
- ma_wrap = cycles_material_wrap_map[material]
- if ma_wrap.node_bsdf_alpha.mute:
- ma_wrap.alpha_image_set_from_diffuse()
- else:
- if not any((True for mtex in material.texture_slots if mtex and mtex.use_map_alpha)):
- mtex = material_mtex_new(material, image, tex_map)
-
- material.use_transparency = True
- material.transparency_method = 'RAYTRACE'
- material.alpha = 0.0
- mtex.use_map_alpha = True
- mtex.alpha_factor = 1.0
+ ma_wrap = cycles_material_wrap_map[material]
+ if ma_wrap.node_bsdf_alpha.mute:
+ ma_wrap.alpha_image_set_from_diffuse()
# propagate mapping from diffuse to all other channels which have none defined.
- if use_cycles:
- ma_wrap = cycles_material_wrap_map[material]
- ma_wrap.mapping_set_from_diffuse()
+ ma_wrap = cycles_material_wrap_map[material]
+ ma_wrap.mapping_set_from_diffuse()
_(); del _
@@ -3174,14 +3072,8 @@ def load(operator, context, filepath="",
v.co += v.normal * decal_offset
break
- if use_cycles:
- for obj in (obj for obj in bpy.data.objects if obj.data == mesh):
- obj.cycles_visibility.shadow = False
- else:
- for material in mesh.materials:
- if material in material_decals:
- # recieve but dont cast shadows
- material.use_raytrace = False
+ for obj in (obj for obj in bpy.data.objects if obj.data == mesh):
+ obj.cycles_visibility.shadow = False
_(); del _
perfmon.level_down()