[Bf-extensions-cvs] [c7cd39e] master: Minor tweaks to material.

Bastien Montagne noreply at git.blender.org
Sun Mar 16 17:02:45 CET 2014


Commit: c7cd39eb6b305fbe640e4a1b855b066ddcea445d
Author: Bastien Montagne
Date:   Sun Mar 16 17:00:19 2014 +0100
https://developer.blender.org/rBAc7cd39eb6b305fbe640e4a1b855b066ddcea445d

Minor tweaks to material.

* Use 100% white transparency color when no transparency at all (seems to be needed by some importers).
* Always export some kind of Lambert shader, even when using e.g. Blender's toon one (better to get something, even inacurate, than nothing).

Patch by Jens Restemeier, many thanks!

Differential Revision: https://developer.blender.org/D405

===================================================================

M	io_scene_fbx/export_fbx_bin.py

===================================================================

diff --git a/io_scene_fbx/export_fbx_bin.py b/io_scene_fbx/export_fbx_bin.py
index ec6beb5..7fb4246 100644
--- a/io_scene_fbx/export_fbx_bin.py
+++ b/io_scene_fbx/export_fbx_bin.py
@@ -1242,7 +1242,8 @@ def fbx_data_material_elements(root, mat, scene_data):
     elem_props_template_set(tmpl, props, "p_number", b"AmbientFactor", mat.ambient)
     elem_props_template_set(tmpl, props, "p_color_rgb", b"DiffuseColor", mat.diffuse_color)
     elem_props_template_set(tmpl, props, "p_number", b"DiffuseFactor", mat.diffuse_intensity)
-    elem_props_template_set(tmpl, props, "p_color_rgb", b"TransparentColor", mat.diffuse_color)
+    elem_props_template_set(tmpl, props, "p_color_rgb", b"TransparentColor",
+                            mat.diffuse_color if mat.use_transparency else (1.0, 1.0, 1.0))
     elem_props_template_set(tmpl, props, "p_number", b"TransparencyFactor",
                             1.0 - mat.alpha if mat.use_transparency else 0.0)
     elem_props_template_set(tmpl, props, "p_number", b"Opacity", mat.alpha if mat.use_transparency else 1.0)
@@ -1684,8 +1685,9 @@ def fbx_data_from_scene(scene, settings):
             mat = mat_s.material
             # Note theoretically, FBX supports any kind of materials, even GLSL shaders etc.
             # However, I doubt anything else than Lambert/Phong is really portable!
+            # We support any kind of 'surface' shader though, better to have some kind of default Lambert than nothing.
             # TODO: Support nodes (*BIG* todo!).
-            if mat.type in {'SURFACE'} and mat.diffuse_shader in {'LAMBERT'} and not mat.use_nodes:
+            if mat.type in {'SURFACE'} and not mat.use_nodes:
                 if mat in data_materials:
                     data_materials[mat][1].append(obj)
                 else:



More information about the Bf-extensions-cvs mailing list