Animation_nodes: Alembic export not working in 2.8 on defroming mesh

Created on 24 Jan 2019  Â·  43Comments  Â·  Source: JacquesLucke/animation_nodes

Alembic exports static mesh even after 'Ensure Animation Data' is checked.
Seems like something changed in alembic workflow in 2.8. couldn't find any reference on internet yet.

Most helpful comment

I pushed a fix for the Ensure Mesh Data option. But this is not enough to fix the issue.

For now, as a workaround, downloaded the latest build and before exporting:

  • Turn off auto execution.
  • Execute the following in the terminal:
    bpy.app.handlers.frame_change_pre.append(lambda scene : bpy.data.node_groups['NodeTree'].execute())
    Where NodeTree is the name of your Animation Nodes node tree.

All 43 comments

Can you tell me what was the working old workflow? Do I just export alembic?

for example, if you create a mesh object from Animation nodes with moving vertices, you could export this mesh with animation as alembic file if "Ensure Animation Data" checked in 'Mesh Object Output' node's advanced settings.
it works until blender version 2.79.6 py37.

https://github.com/JacquesLucke/animation_nodes/search?q=alembic&unscoped_q=alembic

Do they get imported as shape keys then? Like MDD files?

alembic stores all mesh vertices animation in .abc file, I don't know if it can be imported as shape key.

Mdd file has a lot of limitations like vertices count has to be the same.
alembic doesn't have this limitation plus has a lot of extra powerful features like you can export particles, curves etc.
If you import an Alembic file it imports the object plus applies a "Mesh Sequence Cache" modifier which points to .abc file which contains animation data.

As far as I know, it has changed in blender 2.8. like if you have verticles level animation it applies as "Modifier" but if it has normal transformation animation then it applies as "Constraint".

Sybren A. Stüvel (sybren) is module owner of Alembic
https://developer.blender.org/T51351
He might give some information about this.

I see, thanks !

you are welcome!

It seems this is still a problem in b2.8, really frustrating.

Any update on this? Seems to still be broken :/

Unfortunately, I am not really familiar with the Alembic workflow, and I am not sure what the origin of the problem is. I guess the best thing we can do now is to try to replicate it outside of Animation Nodes and report it as a bug.

The thing is it works perfectly fine outside of Animation Nodes though. So it must be somehow related to Animation Nodes i'm guessing? In my case im trying to export geo generated in a curve/spline object, however the problem exists even if i use mesh geo as well.
I would post a more detailed bug report on exporting from scripted geo (similar to @JacquesLucke original bug report a while back).
However i cant access blender.org...(no idea why :( ) entire campus im on cant access. It's not blocked.

It seems this may be getting resolved https://developer.blender.org/T51351

waiting on the frame handling/update to get fixed. Highlighted in these two bug reports:
https://developer.blender.org/T65816
https://developer.blender.org/T60094

I guess its just wait now... :( good news is its likely not an issue for AN to fix.

@AbhaySharma-tp Can you please test this again with the latest build?

I did try a few days ago, it wasn't working. I will try it again when I get
home.
Thanks.

On Sat, Oct 5, 2019, 4:41 PM Omar Emara notifications@github.com wrote:

@AbhaySharma-tp https://github.com/AbhaySharma-tp Can you please test
this again with the latest build?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/JacquesLucke/animation_nodes/issues/1018?email_source=notifications&email_token=AJYITVXMEYN2J3YMIDK2YPDQNBY5TA5CNFSM4GSEGF2KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEANQA4A#issuecomment-538640496,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AJYITVWPSPXTVZCH6GE7AKDQNBY5TANCNFSM4GSEGF2A
.

Using the latest build of Blender 2.81 (f61a8a2abd07) and a build I compiled of the branch (blender2.8) updated 2 days ago (Latest commit d139750), an alembic export of a mesh being deformed by AN isn't animated when imported into a scene. The Mesh Sequence Cache modifier has to be added manually, but with even when this modifier is using the correct .abc file and Object Path the mesh still doesn't deform.

I just tried this, the deformed mesh is not exported at all, I cannot get an animated mesh to be exported to Alembic

It seems related to animation nodes not being "played" when Alembic is exporting, can that be the case?
What do you think @OmarEmaraDev ?

@juangea I will take a look right now. Does Alembic export work with other addons or methods?

@OmarEmaraDev
Yes, in fact I used also a modifier to change a small thing in the geometry generated by AN and that animation works, what does not work is the AN changes.
It feels like the timeline is not updating the changes from AN.

I created this script to try to export manually a sequence of ABC's, if I do it manually I have no trouble, but if I use the script the result is the same, I even tried to do a depsgraph update (even when I'm not sure what it does hehehe ):

import bpy

sframe = 1
eframe = 100
epath = "X:/TEST/Blender/Export/Alembic/"
efilename = "test"
currentf = sframe

def abc_batch_export(start_frame, end_frame, path, filename):

    ex_range = end_frame - start_frame

    global currentf

    for i in range(ex_range):

        pad = "0000"

        if currentf >= 10 and currentf <= 99:
            pad = "000"
        elif currentf >= 100 and currentf <= 999:
            pad = "00"
        elif currentf >= 1000 and currentf <= 9999:
            pad = "0"            


        full_path = epath + efilename + pad + str(currentf) + ".abc"
        print(full_path)
        bpy.ops.wm.alembic_export(filepath=full_path, selected=True, start=currentf, end=currentf)
        currentf += 1
        bpy.context.scene.frame_set(currentf)
        dg = bpy.context.evaluated_depsgraph_get()
        dg.update()        


abc_batch_export(sframe, eframe, epath, efilename)

@juangea Ok, I can confirm. You are right. It seems the export operator blocks application timers, so Animation Nodes don't execute. But application handlers seem to execute properly, so maybe we can implement a workaround here.

Oh, that would be awesome please!

@juangea Ok, I can confirm. You are right. It seems the export operator blocks application timers

The exporter doesn't _block_ anything. It tries to be as efficient as possible, and to only export static meshes once. It's about _detecting_ the fact that something is animated, and exporting on every frame if that is the case.

You can find the detection code in AbcGenericMeshWriter::isAnimated(), for example, see abc_mesh.cc:

bool AbcGenericMeshWriter::isAnimated() const
{
  if (BKE_animdata_id_is_animated(static_cast<ID *>(m_object->data))) {
    return true;
  }
  if (BKE_key_from_object(m_object) != NULL) {
    return true;
  }

  /* Test modifiers. */
  ModifierData *md = static_cast<ModifierData *>(m_object->modifiers.first);
  while (md) {

    if (md->type != eModifierType_Subsurf) {
      return true;
    }

    md = md->next;
  }

  return false;
}

Similar logic can be found in the USD exporter. I'm thinking of adding some custom properties that you can use to influence the exporters, such as a flag "Export on Every Frame", which would cause it to show animation. This has to wait until I've restructured the Alembic exporter to use the new code I created for USD, though.

For now, just add any animated property to the mesh, or any non-subsurf modifier, and it will be exported on each frame.

This problem was solved before in AN. It looks like the is-animated-detection changed slightly.

Previously, it was enough to ensure that the mesh has animation data (it did not have to have an animated property). See https://github.com/JacquesLucke/animation_nodes/blob/master/animation_nodes/nodes/mesh/mesh_object_output.py#L162.

Just adding some animated property should be easy to do.

Yes, it uses BKE_animdata_id_is_animated() now, which checks for there-but-empty animdata.

Thanks @sybrenstuvel for the information! But this is not the only issue at play here. The node tree does not execute at all even if we have an animated property. I suspected that this is because we use an infinite timer to perform the automatic execution. Using a frame_change_pre application handler to manually execute the node tree fixes the problem.

I pushed a fix for the Ensure Mesh Data option. But this is not enough to fix the issue.

For now, as a workaround, downloaded the latest build and before exporting:

  • Turn off auto execution.
  • Execute the following in the terminal:
    bpy.app.handlers.frame_change_pre.append(lambda scene : bpy.data.node_groups['NodeTree'].execute())
    Where NodeTree is the name of your Animation Nodes node tree.

Hello @OmarEmaraDev ,
I downloaded the latest build and tried your workaround with the attached .blend file (tubes mesh produced by particles), but I can't export an animated alembic file...
(Maybe it is worth mentioning i tried on a Mac, could this make any difference?)
Thanks
alembicTest.blend.zip

I'm afraid it's not working yet.
I'm not getting animation exported at all :S not even with that script line executed

@LSka There are two reasons why your example doesn't work. The first reason is that your Node Tree Global Scene is set to Scene.001, not Scene. You can change that in the Animation Node Tree panel. The second reason is probably related to #1175. So just avoid using particles or cache the result first for now.

@juangea Can you provide a minimal file that reproduces the issue?

@juangea This seem to be the same issue as #1175. I hate myself. :disappointed:

don't hate yourself! :)

And do you know what's the culptrip?

@juangea Still trying to figure this out. Bur here is what I think is going on.

  • The active dependency graph we get through view layers will always be of Evaluation Mode DAG_EVAL_VIEWPORT.
  • During exporting and rendering (as can be seen in #1175), we actually want a dependency graph with Evaluation Mode DAG_EVAL_RENDER.
  • The only way to get such graph is through the optional dependency graph passed to the frame_change_post or depsgraph_update_post application handlers.

In conclusion, I think the best thing to do here is to completely rewrite the event handling and auto execution system in Animation Nodes. With careful consideration of all the limitations introduced by Blender. I will talk to Jacques about this and discuss possible course of actions.

@juangea If you want a workaround on top of the workaround for now, you can just cache the result before exporting. See Once Per Frame Caching mechanism.

Interesting, also BlendSushi recommended to use a displacement modifier at 0, it seems it triggers the export, I'll try both things, maybe the Once Per Frame Caching is enough :)

I'll tell you the outcome.

I tried both things, the displace trick it's not working.

The Once Per Frame Caching seems not work either I'm afraid :S

Once I allow the timeline to play once than the playback is fully stopped, no matter if I use that script line or not, nothing plays, so nothing exports either :S

Seems to be working fine here. Is this how you setup your node tree?

20200125-142937

This is my node tree:

image

Also I'm getting a weird error trying to install the latest AN in a different computer (no matter the blender build), I'll investigate that and tell you the problem in a different report in case I cannot locate the problem.

Also I can't find the group output node... weird :P

@juangea The Group Input node have a button to add a corresponding Group Output node. Your Mesh Output node shouldn't be inside the group, if it is cached as well, the scene won't update. Note that Bmesh is not storable and can't be cached, so you should convert to Mesh first. For installation issues, see #1240.

ok, awesome, I'll try that, thanks for all the help :)

YES! It works!

Both, the install problem was due to Visual Studio install, and it installed without trouble.

And the bake works perfectly!

Could be great to have a button to bake in a way that can be exported, with that I mean... something that automates all this haha.

A good idea would be to have a button that does the scriptline, and another good idea would be a button that automatically enscansuplate a bunch of nodes inside a group instead of having to do it manually.

Or... don't waste time on this and just focus on the proper fix :)

Thanks a lot!

@OmarEmaraDev thanks for your input.
I can confirm using Once Per Frame Caching and the script you provided I was able to export a working alembic also building a mesh from particles.

alembicParticlesTest.blend.zip

Thank you very much!

Fixed in #1294 and b1ac938.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

benthillerkus picture benthillerkus  Â·  7Comments

meikasahara picture meikasahara  Â·  10Comments

Montaire picture Montaire  Â·  3Comments

3DSinghVFX picture 3DSinghVFX  Â·  5Comments

enzyme69 picture enzyme69  Â·  9Comments