Hi, guys!
I am recently using blender to export fbx files to 3Ds Max and I have encountered a problem: I cannot export the Specular Color of objects. (Blender Render Engine)
Looking into the code I have no idea why / what is broken.
Can someone with a basic knowledge of Python can help me out here. Thanks in advance!
With the code below, which is from Blender official release all the objects exports with Black Specularity, no matter if from Blender Material Panel I choos green, for example.
Here is the (original) not working code: (excerpt from export_fbx.py inside blender folder)
def write_material(matname, mat):
fw('
Material: "Material::%s", "" {' % matname)
# Todo, add more material Properties.
if mat:
mat_cold = tuple(mat.diffuse_color)
mat_cols = tuple(mat.specular_color)
#mat_colm = tuple(mat.mirCol) # we wont use the mirror color
mat_colamb = 1.0, 1.0, 1.0
mat_dif = mat.diffuse_intensity
mat_amb = mat.ambient
mat_hard = ((float(mat.specular_hardness) - 1.0) / 510.0) * 128.0
mat_spec = mat.specular_intensity
mat_alpha = mat.alpha
mat_emit = mat.emit
mat_shadeless = mat.use_shadeless
if mat_shadeless:
mat_shader = 'Lambert'
else:
if mat.diffuse_shader == 'LAMBERT':
mat_shader = 'Lambert'
else:
mat_shader = 'Phong'
else:
mat_cold = 0.8, 0.8, 0.8
mat_cols = 1.0, 1.0, 1.0
mat_colamb = 1.0, 1.0, 1.0
# mat_colm
mat_dif = 0.8
mat_amb = 1.0
mat_hard = 12.3
mat_spec = 0.5
mat_alpha = 1.0
mat_emit = 0.0
mat_shadeless = False
mat_shader = 'Phong'
fw('
Version: 102')
fw('
ShadingModel: "%s"' % mat_shader.lower())
fw('
MultiLayer: 0')
fw('
Properties60: {')
fw('
Property: "ShadingModel", "KString", "", "%s"' % mat_shader)
fw('
Property: "MultiLayer", "bool", "",0')
fw('
Property: "EmissiveColor", "ColorRGB", "",%.4f,%.4f,%.4f' % mat_cold) # emit and diffuse color are he same in blender
fw('
Property: "EmissiveFactor", "double", "",%.4f' % mat_emit)
fw('
Property: "AmbientColor", "ColorRGB", "",%.4f,%.4f,%.4f' % mat_colamb)
fw('
Property: "AmbientFactor", "double", "",%.4f' % mat_amb)
fw('
Property: "DiffuseColor", "ColorRGB", "",%.4f,%.4f,%.4f' % mat_cold)
fw('
Property: "DiffuseFactor", "double", "",%.4f' % mat_dif)
fw('
Property: "Bump", "Vector3D", "",0,0,0')
fw('
Property: "TransparentColor", "ColorRGB", "",1,1,1')
fw('
Property: "TransparencyFactor", "double", "",%.4f' % (1.0 - mat_alpha))
if not mat_shadeless:
fw('
Property: "SpecularColor", "ColorRGB", "",%.4f,%.4f,%.4f' % mat_cols)
fw('
Property: "SpecularFactor", "double", "",%.4f' % mat_spec)
fw('
Property: "ShininessExponent", "double", "",%.1f' % mat_hard)
fw('
Property: "ReflectionColor", "ColorRGB", "",0,0,0')
fw('
Property: "ReflectionFactor", "double", "",1')
fw('
Property: "Emissive", "ColorRGB", "",0,0,0')
fw('
Property: "Ambient", "ColorRGB", "",%.1f,%.1f,%.1f' % mat_colamb)
fw('
Property: "Diffuse", "ColorRGB", "",%.1f,%.1f,%.1f' % mat_cold)
if not mat_shadeless:
fw('
Property: "Specular", "ColorRGB", "",%.1f,%.1f,%.1f' % mat_cols)
fw('
Property: "Shininess", "double", "",%.1f' % mat_hard)
fw('
Property: "Opacity", "double", "",%.1f' % mat_alpha)
if not mat_shadeless:
fw('
Property: "Reflectivity", "double", "",0')
fw('
}')
fw('
}')