[Bf-extensions-cvs] [c1784de1] blender2.8: OBJ: Cleanup: remove 'use_cycles' option.
Bastien Montagne
noreply at git.blender.org
Wed Sep 26 10:34:43 CEST 2018
Commit: c1784de17c70135a05f3212652fef98d5c2055b2
Author: Bastien Montagne
Date: Wed Sep 26 10:18:29 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBAc1784de17c70135a05f3212652fef98d5c2055b2
OBJ: Cleanup: remove 'use_cycles' option.
We are always using nodes now, whether we want it or not...
Also fixed various access to removed 'fixed shader' old 2.7x materials
in import, and some other minor bugs.
===================================================================
M io_scene_obj/__init__.py
M io_scene_obj/import_obj.py
===================================================================
diff --git a/io_scene_obj/__init__.py b/io_scene_obj/__init__.py
index c542b2d9..54b55a50 100644
--- a/io_scene_obj/__init__.py
+++ b/io_scene_obj/__init__.py
@@ -21,7 +21,7 @@
bl_info = {
"name": "Wavefront OBJ format",
"author": "Campbell Barton, Bastien Montagne",
- "version": (3, 3, 6),
+ "version": (3, 3, 7),
"blender": (2, 80, 0),
"location": "File > Import-Export",
"description": "Import-Export OBJ, Import OBJ mesh, UV's, materials and textures",
@@ -137,7 +137,6 @@ class ImportOBJ(bpy.types.Operator, ImportHelper):
from_up=self.axis_up,
).to_4x4()
keywords["global_matrix"] = global_matrix
- keywords["use_cycles"] = True # (context.scene.view_render.engine == 'CYCLES')
if bpy.data.is_saved and context.user_preferences.filepaths.use_relative_paths:
import os
diff --git a/io_scene_obj/import_obj.py b/io_scene_obj/import_obj.py
index c2998c2c..2925ec82 100644
--- a/io_scene_obj/import_obj.py
+++ b/io_scene_obj/import_obj.py
@@ -88,7 +88,7 @@ def obj_image_load(context_imagepath_map, line, DIR, recursive, relpath):
def create_materials(filepath, relpath,
material_libs, unique_materials,
- use_image_search, use_cycles, float_func):
+ use_image_search, float_func):
"""
Create all the used materials in this obj,
assign colors and images to the materials from all referenced material libs
@@ -99,9 +99,9 @@ def create_materials(filepath, relpath,
# Don't load the same image multiple times
context_imagepath_map = {}
- cycles_material_wrap_map = {}
+ nodal_material_wrap_map = {}
- def load_material_image(blender_material, mat_wrap, use_cycles, context_material_name, img_data, line, type):
+ def load_material_image(blender_material, mat_wrap, context_material_name, img_data, line, type):
"""
Set textures defined in .mtl file.
"""
@@ -129,44 +129,37 @@ def create_materials(filepath, relpath,
# Adds textures for materials (rendering)
if type == 'Kd':
- if use_cycles:
- mat_wrap.diffuse_image_set(image)
- mat_wrap.diffuse_mapping_set(coords='UV', translation=map_offset, scale=map_scale)
+ mat_wrap.diffuse_image_set(image)
+ mat_wrap.diffuse_mapping_set(coords='UV', translation=map_offset, scale=map_scale)
elif type == 'Ka':
- if use_cycles:
- # XXX Not supported?
- print("WARNING, currently unsupported ambient texture, skipped.")
+ # XXX Not supported?
+ print("WARNING, currently unsupported ambient texture, skipped.")
elif type == 'Ks':
- if use_cycles:
- mat_wrap.specular_image_set(image)
- mat_wrap.specular_mapping_set(coords='UV', translation=map_offset, scale=map_scale)
+ mat_wrap.specular_image_set(image)
+ mat_wrap.specular_mapping_set(coords='UV', translation=map_offset, scale=map_scale)
elif type == 'Ke':
- if use_cycles:
- # XXX Not supported?
- print("WARNING, currently unsupported emit texture, skipped.")
+ # XXX Not supported?
+ print("WARNING, currently unsupported emit texture, skipped.")
elif type == 'Bump':
bump_mult = map_options.get(b'-bm')
bump_mult = float(bump_mult[0]) if (bump_mult is not None and len(bump_mult) > 1) else 1.0
- if use_cycles:
- mat_wrap.normal_image_set(image)
- mat_wrap.normal_mapping_set(coords='UV', translation=map_offset, scale=map_scale)
- if bump_mult:
- mat_wrap.normal_factor_set(bump_mult)
+ mat_wrap.normal_image_set(image)
+ mat_wrap.normal_mapping_set(coords='UV', translation=map_offset, scale=map_scale)
+ if bump_mult:
+ mat_wrap.normal_factor_set(bump_mult)
elif type == 'D':
- if use_cycles:
- mat_wrap.alpha_image_set(image)
- mat_wrap.alpha_mapping_set(coords='UV', translation=map_offset, scale=map_scale)
+ mat_wrap.alpha_image_set(image)
+ mat_wrap.alpha_mapping_set(coords='UV', translation=map_offset, scale=map_scale)
elif type == 'disp':
- if use_cycles:
- mat_wrap.bump_image_set(image)
- mat_wrap.bump_mapping_set(coords='UV', translation=map_offset, scale=map_scale)
+ mat_wrap.bump_image_set(image)
+ mat_wrap.bump_mapping_set(coords='UV', translation=map_offset, scale=map_scale)
elif type == 'refl':
map_type = map_options.get(b'-type')
@@ -174,9 +167,8 @@ def create_materials(filepath, relpath,
print("WARNING, unsupported reflection type '%s', defaulting to 'sphere'"
"" % ' '.join(i.decode() for i in map_type))
- if use_cycles:
- mat_wrap.diffuse_image_set(image, projection='SPHERE')
- mat_wrap.diffuse_mapping_set(coords='Reflection', translation=map_offset, scale=map_scale)
+ mat_wrap.diffuse_image_set(image, projection='SPHERE')
+ mat_wrap.diffuse_mapping_set(coords='Reflection', translation=map_offset, scale=map_scale)
else:
raise Exception("invalid type %r" % type)
@@ -205,10 +197,9 @@ def create_materials(filepath, relpath,
for name in unique_materials: # .keys()
if name is not None:
ma = unique_materials[name] = bpy.data.materials.new(name.decode('utf-8', "replace"))
- if use_cycles:
- from modules import cycles_shader_compat
- ma_wrap = cycles_shader_compat.CyclesShaderWrapper(ma)
- cycles_material_wrap_map[ma] = ma_wrap
+ from modules import cycles_shader_compat
+ ma_wrap = cycles_shader_compat.CyclesShaderWrapper(ma)
+ nodal_material_wrap_map[ma] = ma_wrap
for libname in sorted(material_libs):
# print(libname)
@@ -242,63 +233,44 @@ def create_materials(filepath, relpath,
if context_material:
emit_value = sum(emit_colors) / 3.0
if emit_value > 1e-6:
- if use_cycles:
- print("WARNING, currently unsupported emit value, skipped.")
+ print("WARNING, currently unsupported emit value, skipped.")
# We have to adapt it to diffuse color too...
emit_value /= sum(context_material.diffuse_color) / 3.0
- context_material.emit = emit_value
+ # ~ context_material.emit = emit_value
if not do_ambient:
context_material.ambient = 0.0
if do_highlight:
- if use_cycles:
- context_mat_wrap.hardness_value_set(1.0)
+ context_mat_wrap.hardness_value_set(1.0)
# FIXME, how else to use this?
context_material.specular_intensity = 1.0
else:
- if use_cycles:
- context_mat_wrap.hardness_value_set(0.0)
+ context_mat_wrap.hardness_value_set(0.0)
if do_reflection:
- if use_cycles:
- context_mat_wrap.reflect_factor_set(1.0)
- context_material.raytrace_mirror.use = True
- context_material.raytrace_mirror.reflect_factor = 1.0
+ context_mat_wrap.reflect_factor_set(1.0)
+ context_material.metallic = 1.0
if do_transparency:
- context_material.use_transparency = True
- context_material.transparency_method = 'RAYTRACE' if do_raytrace else 'Z_TRANSPARENCY'
if "alpha" not in context_material_vars:
- if use_cycles:
- context_mat_wrap.alpha_value_set(0.0)
- context_material.alpha = 0.0
+ context_mat_wrap.alpha_value_set(0.0)
+ # EEVEE only
+ context_material.blend_method = 'BLEND'
if do_glass:
- if use_cycles:
- print("WARNING, currently unsupported glass material, skipped.")
- if "ior" not in context_material_vars:
- context_material.raytrace_transparency.ior = 1.5
+ print("WARNING, currently unsupported glass material, skipped.")
+ # ~ if "ior" not in context_material_vars:
+ # ~ context_material.raytrace_transparency.ior = 1.5
if do_fresnel:
- if use_cycles:
- print("WARNING, currently unsupported fresnel option, skipped.")
- context_material.raytrace_mirror.fresnel = 1.0 # could be any value for 'ON'
-
- """
- if do_raytrace:
- context_material.use_raytrace = True
- else:
- context_material.use_raytrace = False
- """
- # XXX, this is not following the OBJ spec, but this was
- # written when raytracing wasnt default, annoying to disable for blender users.
- context_material.use_raytrace = True
+ print("WARNING, currently unsupported fres
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list