Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alembic export not working in 2.8 on defroming mesh #1018

Closed
AbhaySharma-tp opened this issue Jan 24, 2019 · 43 comments
Closed

Alembic export not working in 2.8 on defroming mesh #1018

AbhaySharma-tp opened this issue Jan 24, 2019 · 43 comments

Comments

@AbhaySharma-tp
Copy link

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.

@OmarEmaraDev
Copy link
Collaborator

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

@AbhaySharma-tp
Copy link
Author

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

@OmarEmaraDev
Copy link
Collaborator

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

@AbhaySharma-tp
Copy link
Author

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".

@AbhaySharma-tp
Copy link
Author

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

@OmarEmaraDev
Copy link
Collaborator

I see, thanks !

@AbhaySharma-tp
Copy link
Author

you are welcome!

@karlisstigis
Copy link

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

@mafster
Copy link

mafster commented Aug 19, 2019

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

@OmarEmaraDev
Copy link
Collaborator

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.

@mafster
Copy link

mafster commented Aug 19, 2019

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.

@mafster
Copy link

mafster commented Aug 26, 2019

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.

@OmarEmaraDev
Copy link
Collaborator

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

@AbhaySharma-tp
Copy link
Author

AbhaySharma-tp commented Oct 6, 2019 via email

@nhedron
Copy link

nhedron commented Oct 10, 2019

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.

@juangea
Copy link

juangea commented Jan 21, 2020

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

@juangea
Copy link

juangea commented Jan 21, 2020

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

@OmarEmaraDev
Copy link
Collaborator

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

@juangea
Copy link

juangea commented Jan 21, 2020

@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)

@OmarEmaraDev
Copy link
Collaborator

@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.

@juangea
Copy link

juangea commented Jan 22, 2020

Oh, that would be awesome please!

@sybrenstuvel
Copy link

@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.

@JacquesLucke
Copy link
Owner

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.

@sybrenstuvel
Copy link

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

@OmarEmaraDev
Copy link
Collaborator

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.

@OmarEmaraDev
Copy link
Collaborator

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.

@LSka
Copy link

LSka commented Jan 23, 2020

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

@juangea
Copy link

juangea commented Jan 23, 2020

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

@OmarEmaraDev
Copy link
Collaborator

OmarEmaraDev commented Jan 24, 2020

@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
Copy link

juangea commented Jan 24, 2020

Yes :)

Here you go:

http://pasteall.org/blend/index.php?id=52814

@OmarEmaraDev
Copy link
Collaborator

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

@juangea
Copy link

juangea commented Jan 24, 2020

don't hate yourself! :)

And do you know what's the culptrip?

@OmarEmaraDev
Copy link
Collaborator

@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 Particle Data Node not updating while Render #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.

@OmarEmaraDev
Copy link
Collaborator

@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.

@juangea
Copy link

juangea commented Jan 25, 2020

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.

@juangea
Copy link

juangea commented Jan 25, 2020

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

@OmarEmaraDev
Copy link
Collaborator

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

20200125-142937

@juangea
Copy link

juangea commented Jan 25, 2020

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

@OmarEmaraDev
Copy link
Collaborator

@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.

@juangea
Copy link

juangea commented Jan 25, 2020

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

@juangea
Copy link

juangea commented Jan 25, 2020

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!

@LSka
Copy link

LSka commented Jan 26, 2020

@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!

@OmarEmaraDev
Copy link
Collaborator

Fixed in #1294 and b1ac938.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants