io_scene_fbx: hacking on Blender FBX export scripts


#1

In case anybody else is curious about low-level Blender stuff I’ll be posting some experiments here.

For now these Python snippets are only meant for the very brave – and require hacking directly on the FBX addon code (so if attempting please make a backup of your originals first).

~blender/2.7x/scripts/addons/io_scene_fbx/fbx_export_bin.py

** Specular/Shininess Hack** (tested with 2.7.4)
– enables two extreme Specular Hardness values to trigger workarounds during the FBX export process. In particular this seems to mitigate HiFi’s issue where transparent objects are imported to have “blinding” levels of shininess, but the workarounds can also be used on solid materials. Once the hack is in place the special values are set as usual in the UI:

  • Hardness == 511: will attempt to export a reasonable “matte” finish – ie: something with some light responsiveness, but nothing describable as shiny
  • Hardness == 510: attempts to defeat specular highlighting entirely (using invalid FBX values that violate even the de facto FBX standards being used, but that do seem to achieve the desired result when imported into HiFi)
  • Code Snippet: _export_fbx_bin.py – which is meant to replace the entire if mat_type == b"Phong": code block starting at line 1242, within the def fbx_data_material_elements(root, mat, scene_data): method.

//tim


#2

I change the specular colour ^whites full shiney blacks full matte


#3

Cool will have to check this out,
but

As a side note,
I don’t think the Hifi’s issue of having extremely blinding level of shininess on transparent objects is reserved for Blender:

It seems to happen on the other suites as well and in other formats, especially on new avatars exported straight away from Mixamo Fuse.

Specular Intensity to low results in a quite matte finish for transparent objects in the first place: This also works quite fine on objects that actually have a specular texture (you can see an example of it in my domain, Centre)

One hack (for testing) I tried to do earlier was related to the exportation of the Avatar skeletons to export using Maya (or well, modern standard) FBX standards. Unfortunately I got stuck with it as I have no idea how the PreRotation, Rotation and PostRotation are gotten in the first place…


#4

@Judas – cool, and that seems much easier for regulating shininess on solid objects. For transparent objects, these export hacks were the only way I could get single-texture meshes working acceptably (ie: using just one PNG w/alpha).

@Menithal – I haven’t looked into the PreRotation stuff, but in theory all that jazz is available by the same names within fbx_export_bin.py. What to chat/collaborate sometime to see if we can’t figure it out?

Note that comparing two FBX files is something of a wild goose chase.

So using HiFi’s C++ FBX code I recently made a command-line tool for dumping loaded FBX’s into a JSON representation. If anybody has interesting “pairs” of FBX files I could try to compare them systematically that way.

In theory this kind of comparison will work better, since only the “relevant” data ever makes it into the JSON dump (all extraneous FBX cruft will have been organically filtered by the import process itself).