[Addon] Blembic - Mesh Cache that supports varying vertex count


(Lumpengnom) #1

Update 1st of May 2016

There appears to be bug in the Blembic importer and newer versions can not import Blembic files exported from 3ds Max. I will fix this as soon as possible but until then here is an older versoin of Blembic which is able to import cache files from 3ds Max:

BlembicImporter0_9_MAX.zip (4.31 KB)

Update 15th of March 2016

  • updated the Houdini Exporter and the Blender Importer
  • The Houdini Exporter now supports uv-Maps and Vertex Colors - please read the sticky note in the Houdini file
  • Updated the Importers UI. Note that the “Mat” checkbox is not functional at the moment
  • Updated Instructions below

Blembic.zip (165 KB)


Update 14th of March 2016

I started to write an exporter for Houdini and updated the importer.
The Houdini exporter so far supports.

  • Vertices and Faces
  • Split Normals

The importer has been updated and you can now:
- turn objects on and off in the viewport

  • turn Split Normals on and off
  • turn on y-up for objects that were imported from 3D programms that use Y as up Axis.
  • The importers code is now documented better

A big thank you to Tiaan, Gerbrand and Mandrake for the help


Update 7th of March 2016:

I created a documentation of the Blembic file format on my web site. If you are interested in writing an exporter for another program this site explains how to set it up.
http://polykraft.de/wordpress/category/scripts/


Original post
Hi,
Blembic is an Addon which allows Blender to stream mesh caches exported from other 3D programs. I wrote it to bridge the gap until Blender has Alembic support, hence the silly name.
It uses it�s own binary format (.BBC) so it is faster than streaming files like obj or fbx caches.
This Addon is still in development so you probably want to be careful when using it in production.

Here is a video of a Particlesystem I made in 3ds Max, exported to Blembic cache and streamed into Blender.
Note: What you see is one single object that changes its mesh each frame.

Blembic so far supports:

  • Geometry with varying vertex count
  • Split Normals
  • Material IDs for Multimaterial support (only from 3ds Max)
  • UVW maps (currently only 1 channel)
  • Vertex Colors (only from Houdini)
  • You can have more than one Blembic object in your scene

It is pretty fast and uses very little ram even for objects with a very large vertex count.

I also wrote an exporter for 3ds Max and Houdini.

Note that the 3ds Max exporter can be rather slow for more complex objects. I have some ideas to improve that in the future.

Instructions:

Exporting 3ds Max
The exporter doesn�t have many options and is easy to understand:

  • Start the exporter by going to: Scripting -> run script and Select the file "BlembicExport0_2.ms
  • The exporter pops up
  • Press the “Select Path and Filename” button (don�t input the folder manually. That is buggy at the moment)
  • Your Object needs at least one Material or else the file will cause errors later on in Blender
  • Set a frame range with the “start” and “end” spinners.
  • Select the object you want to export
  • If your object is a Particle System you have to apply a Mesher Object to it from the “Compound Objects” and select the Mesher object
  • Hit Export
  • If something doesn�t work you might have to close the exporter and start it again via Scripting -> run script

Exporting Houdini

- There is a Houdini file included in the download.- A sticky note in the file has some more information

  • In the file you can see geometry piped into a node marked in the following image. Pipe your geometry into that. Note that only polygon meshes work. Things like poly soup or surfaces have to be converted to polygons first
  • Set an output folder in the script. The folder has to exist and is not created automatically by the exporter
  • Play the animation

Importing

  • Install the addon by going to the User Preferences in Blender -> Add-ons -> Install from File and select the file BlembicExporter.py

  • In the search field of the Prefernces search for Blembic and turn the Blembic Importer on

  • Create a cube Object or any other kind of mesh object

  • Select the Object and go to the Object Panel

  • Here you see the Addon. With the object active hit the “Add Object” button.

  • The object is added to the list. In the list you can now choose the folder you previously exported the mesh cache to.

  • The mesh cache is now imported. If you scrub the time line within the range of the cache the mesh will be updated.

  • To remove an object select it in the Blembic list (not in the viewport) and hit the “Remove Object” button.

  • If you rename your object in the scene you will have to select the object in the viewport AND in the Blembic List and hit the “Update Object” button

Adding Materials
Due to the nature of how materials are saved in Blender materials require a short workaround.

  • Create a new cube. This cube is only there to store the materials so we�ll call it Material Cube
  • Create as many Materials on this Cube as your Object in 3ds Max has MatIDs. Or assign one Material if you have exported from Houdini.
  • With the Material Cube active hit the “Add Materials” button in the Blembic Addon
  • Scrub the time line to update the materials.
  • You probably want to turn the Material Cube to not renderable

There are several checkboxes in the importer. These checkboxes turn certain things on and off so you can increase the speed if you are currently not working with a certain Blembic object. Note that these changes are visible only after changin the timeline.

  • On/Off turns the whole object off. It is not turned invisible it just stops animating
  • Normals turns split normals on and off. This increases speed but turns the whole mesh facetted
  • Y-Up flips the face normals. This is usually necessary for objects from Houdini. Note that you still have to rotate the object by 90 degrees manually
  • Mat does not work at the moment and is there only for development purposes.

Future development:

  • Options to turn off materials, uv-maps and vertex colors for faster streaming
  • Vertex colors for 3ds Max
  • faster exporter
  • perhaps an option to import ngons. This would make it possible to stream low poly objects and apply a subdivision modifier in Blender. This would require a lot of code to be rewritten, though and seems to be rather complicated.
  • Check if it is possible to turn the whole exporter node setup into a single VEX node that pipes the information into the Python exporter directly.

Attachments




Houdini + Blender?
(Looch) #2

oh man this is great, can you write an exporter for maya, to improve the maya blender pipeline?

Cheers!!


(Pitiwazou) #3

+1, I would like to work with maya or directly with Guerilla.


(Lumpengnom) #4

I will try to look into a Maya exporter but I don´t have Maya so that might be difficult.
The further plan is to first complete the importer (Vertex colors are esspecailly important to me) and then document the .BBC format. It shouldn´t be very difficult to write a Maya exporter if you know what to write to the file, if you know some Maya scripting and know your way around May it should be pretty easy to write such an exporter.

However, I´ll be traveling for the next 4 weeks, so I´ll start the improvements then.


(juang3d) #5

Instead of that, why haven’t you tried to develop an Alembic importer? you clearly have the knowledge.

That way you don’t need to handle any exporter from any package.

Anyway I need it to be Alembic because we already have material and we use various sources (clients sending us files and such things) so we need something that is crosspackage, and Alembic is that tool right now, but thanks for the idea :slight_smile:

Thanks for the info to everyone, I hope this gets implemented as fast as possible, without it we cannot have proper interop and a proper pipeline to work with other packages from clients and ourselves.

Cheers!


(Lumpengnom) #6

I would love to but I am just a 3D artist with some Python knowledge and I am quite certain that implementing Alembic requires more than Python.


(Swespy) #7

Hello! Great work, this saved my day, the only problem I got is that I cant assign a material to my Blembic, I followed your guide, but it dont change :confused:


(Indy_logic) #8

This looks great! Any chance we can go the other way? Blender into Max?


(Lumpengnom) #9

Hmm… does your object in Max have the same amount of MatIDs as it has Materials? Sometimes in Max you assign a material to an object while the object has several matlDs and the material will be assigned to all of these IDs. Maybe this causes the problem.
So perhaps for testing purposes create a cube in max turn it into an editable poly, select all polygons and give them the matID 1. Then export it to Blembic.
You can also upload the file and I will take a look at it when I return from vacation in a week.


(Lumpengnom) #10

Perhaps in the long run but at the moment the features listed in the opening post have priority for me.
One of the first things I want to do is document the file so that other people might be able to create importers and exporters from and to other programs.


(Rockbard) #11

Any chance to see exporter for Cinema 4D?


(Lumpengnom) #12

I don´t have C4D so this would be rather difficult. But perhaps when the format is documented someone who has it can create such an exporter.


(Lumpengnom) #13

The documentation for the Blembic format is online:

http://polykraft.de/wordpress/category/scripts/

I have also started to script an exporter for Houdini.


(Lumpengnom) #14

Started writing a Houdini Exporter and updated the Importer. See the first post in this thread for the updates from the 14th of March 2016.


(Lumpengnom) #15

Started writing a Houdini


(Lumpengnom) #16

Update 15th of March 2016

please see first post for updates form the 15th of March 2016


(Rangiz) #17

Hi,

The mesh doesn’t show up. I make everything as in description. But it load something, but nothing is in scene. Because frames where objects are, for example from 0-50 frame, playback max 10FPS, but nothing show up, and nothing is there.

Newest Blender.


(Lumpengnom) #18

Hi,
it appears that I introduced some bug into the script for meshes exported from 3ds Max.
I will try to fix this as soon as possible.
I uploaded an older version that should be able to read Blembic files exported from Max.

BlembicImporter0_9_MAX.zip (4.31 KB)