KeyShot Forum

Technical discussions => Extending KeyShot => Scripting => Topic started by: hstokholm on December 10, 2015, 04:47:19 AM

Title: Script for rendering deformable meshes
Post by: hstokholm on December 10, 2015, 04:47:19 AM
Attached is a script that supports rendering deformable meshes for Alembic and Maya files.

The workflow is as follows:

- Import first frame of the file. This is done through animation -> specific frame in the import dialog.

- Set up the scene with materials, environment, and camera.

- Run the script that continuously updates the geometry with the next frame and adds a image render to the queue.
If "Increase Keyshot frames" is checked the timeline in keyshot will also move each frame to allow for camera and material animations.

I tested it with the alembic octopus example file, and the result is attached.

- Heine
Title: Re: Script for rendering deformable meshes
Post by: Esben Oxholm on December 10, 2015, 06:21:02 AM
Thanks for sharing Heine, and well described. Got it to work in one shot :)
Animation as alembic from modo 901:
(https://dl.dropboxusercontent.com/u/2388699/DeformTest.gif)

Is it possible to activate motion blur on these?
Title: Re: Script for rendering deformable meshes
Post by: TpwUK on December 10, 2015, 06:36:55 AM
Quote from: Esben Oxholm on December 10, 2015, 06:21:02 AM
Is it possible to activate motion blur on these?

I don't think you can Esben because you only have one frame in memory at any one time, although with ABC being a cache in theory you could manipulate things via scripting and somehow merge and fade previous render results to create a pseudo motion blur effect. Personally i think it would be easier to batch process the frames individually via PS or AE etc

Martin
Title: Re: Script for rendering deformable meshes
Post by: hstokholm on December 10, 2015, 06:48:35 AM
Nice!

Quote from: Esben Oxholm on December 10, 2015, 06:21:02 AM
Is it possible to activate motion blur on these?

Unfortunately not. That can not be used for animations created through scripting.
Title: Re: Script for rendering deformable meshes
Post by: Esben Oxholm on December 10, 2015, 06:49:48 AM
Quote from: TpwUK on December 10, 2015, 06:36:55 AM
Quote from: Esben Oxholm on December 10, 2015, 06:21:02 AM
Is it possible to activate motion blur on these?
I don't think you can Esben because you only have one frame in memory at any one time, although with ABC being a cache in theory you could manipulate things via scripting and somehow merge and fade previous render results to create a pseudo motion blur effect. Personally i think it would be easier to batch process the frames individually via PS or AE etc
Oh, yeah, true... Makes sense. Thanks for explaining.
Yup, the best then, I guess,  will be to apply some pseudo motion blur in AE.
Title: Re: Script for rendering deformable meshes
Post by: evilmaul on December 10, 2015, 11:26:23 AM
thats sweet! thanks Heine!!
do you think this can be done differently in the future so that mblur can be applied to deformed objs as well?
As an alternative would make sense to output motion vectors as a map to then apply mbur in post?
Title: Re: Script for rendering deformable meshes
Post by: Artur on December 15, 2015, 12:42:30 AM
Could anyone redirect me to a video tut for this one?
I am a novice in scripting for KS and I am trying to export a animation from C4D r 15 to KS6.

Thanks in advance.
Title: Re: Script for rendering deformable meshes
Post by: hstokholm on December 15, 2015, 04:38:57 AM
Quote from: Artur on December 15, 2015, 12:42:30 AM
Could anyone redirect me to a video tut for this one?
I am a novice in scripting for KS and I am trying to export a animation from C4D r 15 to KS6.

Hi Artur.

I am afraid that a video tutorial isn't available currently.

If you have KeyShot 6 pro you are able to render the animation frames using scripting.
C4D r 15 should be able to export the animation to an alembic file (.abc) which can be used with this script.
To actually run the script you open the scripting console which are located in "Window -> Scripting Console" in the menu bar.
In the "Scripts" tab you have the option to import the script, and then it can be used by double clicking it.

If you have any specific questions feel free to ask.

Quote from: evilmaul on December 10, 2015, 11:26:23 AM
thats sweet! thanks Heine!!
do you think this can be done differently in the future so that mblur can be applied to deformed objs as well?
As an alternative would make sense to output motion vectors as a map to then apply mbur in post?

Good to hear it's useful. And yes it would make sense to support motion blur in the future. Maybe for now motion vectors can be output from maya and then combined in post?
Title: Re: Script for rendering deformable meshes
Post by: Artur on December 15, 2015, 06:18:42 AM
Sorry for the recurrent request but maybe a step by step guide:

1- ...
2-...
3-...
Title: Re: Script for rendering deformable meshes
Post by: hstokholm on December 15, 2015, 07:04:56 AM
No problem Artur.

1. Export from cinema 4d to an Alembic file.
2. Import first frame of the file. This is done through animation -> specific frame in the import dialog. 
3. Set up the scene as you want it with materials, environment, and camera.
4. Open the scripting console which are located in "Window -> Scripting Console" in the menu bar and choose the "scripts" tab.
5. Import the script "Add deformable mesh frames to queue.py", and then it can be used by double clicking it.
6. Fill out the options in the "Add deformable mesh frames to queue" dialog and press ok.
7. The geometry are now being updated for all frames, and a render is added to the queue for each frame.

Feel free to ask if anything is unclear.


Title: Re: Script for rendering deformable meshes
Post by: reidsl on January 08, 2016, 09:40:38 AM
From the sound of it this is just me but Im having issues.  I ran the script fine, its the output that killing me.  First even though it shows that it saved to the correct folder in the output window, the files end up in my Keyshot Resources folder.  Second and most important, for some reason all of my files are .ext files (DeformerTEST.mb.00000.tif.ext) which make them worthless.  What am I doing wrong here?
Title: Re: Script for rendering deformable meshes
Post by: redcode on March 06, 2016, 02:14:36 PM
Quote from: reidsl on January 08, 2016, 09:40:38 AM
From the sound of it this is just me but Im having issues.  I ran the script fine, its the output that killing me.  First even though it shows that it saved to the correct folder in the output window, the files end up in my Keyshot Resources folder.  Second and most important, for some reason all of my files are .ext files (DeformerTEST.mb.00000.tif.ext) which make them worthless.  What am I doing wrong here?

I'm having the same exact problem! The script runs fine (very fast) and then I get the files ending up in the KeyShot Resources folder and all the output files have the extension .ext and I can't open them. What is going on? Please let us know. I was very disappointed when I discovered KeyShot couldn't import deformation files from Maya or through FBX. This seemed like a passable workaround. Please help us.
Title: Re: Script for rendering deformable meshes
Post by: hstokholm on March 07, 2016, 02:14:21 AM
The .ext files are for keyshots render queue. The scripts add all the renders to the render queue, and you then have to manually process the queue. (Render -> Queue -> Process Queue)
Title: Re: Script for rendering deformable meshes
Post by: dennisvolkerts on June 23, 2016, 05:00:28 PM
Quote from: hstokholm on December 10, 2015, 04:47:19 AM
Attached is a script that supports rendering deformable meshes for Alembic and Maya files.

The workflow is as follows:

- Import first frame of the file. This is done through animation -> specific frame in the import dialog.

- Set up the scene with materials, environment, and camera.

- Run the script that continuously updates the geometry with the next frame and adds a image render to the queue.
If "Increase Keyshot frames" is checked the timeline in keyshot will also move each frame to allow for camera and material animations.

I tested it with the alembic octopus example file, and the result is attached.

- Heine
Thnx for the script but it keeps crashing... is there some option in the script to keep it going? after 8 frames it seams to crash... i7 - 24 RAM, Nvidia Quadro K2100M (4GB)
my mesh count isnt that high...
5 mil poligons..
One character is animating.
abc file is 1.46GB

Can you add a option for maximum ram?
Or do you know some online scripts that can handle it?
obj sequence I heart about, this is the first I tried and I preffer alembic
thnx
Title: Re: Script for rendering deformable meshes
Post by: guest84672 on June 23, 2016, 05:45:28 PM
what version of KeyShot are you using? Make sure that you are on the latest version 6.2.85. It was just released.
Title: Re: Script for rendering deformable meshes
Post by: dennisvolkerts on June 24, 2016, 05:01:47 AM
Quote from: thomasteger on June 23, 2016, 05:45:28 PM
what version of KeyShot are you using? Make sure that you are on the latest version 6.2.85. It was just released.

I tried the latest version after you said.
But now some materials I assinged at the first frame changes in other materials.
damn... already try to get my animation to render for 2 days.
And even now it stops at 6 frames or so.... ( no crash just an error that I need to reinstall keyshot and that it cant import abc files) after restart keyshot.. its fine again for some frames..

is there a shotcut for script console running script?


...ohh wait, after getting everything in the que i get another error... after hitting ''Process Que'' just after update. : Cannot load library luxrender.so

EDIT:
I finaly after alot of crashes made it.
(http://i.makeagif.com/media/6-30-2016/fx75P9.gif) (http://makeagif.com/fx75P9)
Title: Re: Script for rendering deformable meshes
Post by: LayC42 on June 30, 2016, 10:32:17 PM
This dancing granny is so good. It's amazing!
Title: Re: Script for rendering deformable meshes
Post by: dennisvolkerts on July 01, 2016, 02:56:26 AM
Quote from: LayC42 on June 30, 2016, 10:32:17 PM
This dancing granny is so good. It's amazing!
THNX :-)
Title: Re: Script for rendering deformable meshes
Post by: TpwUK on July 01, 2016, 06:29:41 AM
Excellent result Dennisvolkerts - May I ask how you got the materials to remain across frames as I have this issue with my script and i can't find another way round the problem ?

Martin
Title: Re: Script for rendering deformable meshes
Post by: dennisvolkerts on July 01, 2016, 08:00:23 AM
Quote from: TpwUK on July 01, 2016, 06:29:41 AM
Excellent result Dennisvolkerts - May I ask how you got the materials to remain across frames as I have this issue with my script and i can't find another way round the problem ?

Martin
I had the same problem. Had to rerender the eyes and composit it on top with a clowpass.

Sometimes its better to begin from scratch and save the materials you used in the library to apply it again in the new scene

First i imported the whole scene as abc file... but its also better to only import the deformable mesh in the abc and import the enviroment as a different obj.

Cheers
Title: Re: Script for rendering deformable meshes
Post by: philw on August 03, 2016, 11:27:52 AM
Hi all - chanced upon this whilst looking for a C4D export to Keyshot animation and working well - many thanks. However, I would like transparent PNGs like I can check in the standard render dialogue...am I missing something or is there something I can add to the script to enable it?

Cheers!
Title: Re: Script for rendering deformable meshes
Post by: bdesign on August 03, 2016, 11:42:40 AM
Superb animation! Love it!

Eric
Title: Re: Script for rendering deformable meshes
Post by: philw on August 03, 2016, 11:05:26 PM
Quote from: philw on August 03, 2016, 11:27:52 AM
Hi all - chanced upon this whilst looking for a C4D export to Keyshot animation and working well - many thanks. However, I would like transparent PNGs like I can check in the standard render dialogue...am I missing something or is there something I can add to the script to enable it?

Cheers!

After doing some tests I found that having the alpha transparency option ticked in the render dialogue actually works for the script, even though not seemingly part of the process. Result!
Title: Re: Script for rendering deformable meshes
Post by: DriesV on August 05, 2016, 10:35:13 AM
Here are two revisions of the script.
They provide the ability to update multiple Alembic models in one scene. They also have options for render passes/layers and you can specify an output folder.

The difference between the two scripts lies in how import is handled. One script allows browsing individual Alembic files (up to 4, but number can be changed inside the script), the other automatically loads all Alembic files that are contained in a folder.

Have fun!  :)

Dries
Title: Re: Script for rendering deformable meshes
Post by: philw on August 05, 2016, 11:51:59 AM
Thank you!
Title: Re: Script for rendering deformable meshes
Post by: JMAHIEDDINE on August 25, 2016, 05:20:32 AM
Thanks DriesV. Is it the same script as the obj sequence one you did ?
If no, what is the best option in your opinion, to import a clean animation with deformation in keyshot?

Thanks,
Cheers,
John
Title: Re: Script for rendering deformable meshes
Post by: dennisvolkerts on September 20, 2016, 07:24:06 AM
Quote from: DriesV on August 05, 2016, 10:35:13 AM
Here are two revisions of the script.

Im gonna try it. I have one question.
I mentioned on the first script, that while it is rendering my que it also was still rendering my first main frame. Is that solved in the NEW ones?
Or is it possible? thnx
Title: Re: Script for rendering deformable meshes
Post by: Niko Planke on September 20, 2016, 07:42:59 AM
Hey Dennis.

That issue should be resolved in the latest KeyShot 6 version (6.2.105)
Can you please Check for updates and try again?
Title: Re: Script for rendering deformable meshes
Post by: dennisvolkerts on September 21, 2016, 06:33:13 PM
Quote from: Niko Planke on September 20, 2016, 07:42:59 AM
Hey Dennis.

That issue should be resolved in the latest KeyShot 6 version (6.2.105)
Can you please Check for updates and try again?

Thnx!!! it worked. :)
Another two realy importend things,
-it doesnt always update the animations ( its still a bit buggy ) sometimes I render for hours and I only see the first frame with camera animations.
-Another and the most horrified thing: it doesnt save any files sometime..
Title: Re: Script for rendering deformable meshes
Post by: Artur on September 22, 2016, 12:04:20 AM
Hi Guys.

Do This scripts works in the OSX version of Keyshot?
Title: Re: Script for rendering deformable meshes
Post by: philw on September 22, 2016, 12:25:56 AM
Quote from: Artur on September 22, 2016, 12:04:20 AM
Hi Guys.

Do This scripts works in the OSX version of Keyshot?

Yes they do :-)
Title: Re: Script for rendering deformable meshes
Post by: Artur on September 23, 2016, 12:03:46 AM
Thank you for the quick reply.

The next step would be a complete tutorial on this.
Maybe the guys at Luxion would t matter to make a webinar on this.
Title: Re: Script for rendering deformable meshes
Post by: willchocks7 on October 27, 2016, 05:13:47 PM
When you mentioned maya file (in the original post) did you mean .mb or .fbx?
Title: Re: Script for rendering deformable meshes
Post by: Hawks89 on January 16, 2017, 11:07:32 AM
Hi everyone,

in need of some help. I created a Fluid Simulation in Blender. I exported the fluid running through the pipe out it as alembic file, and imported it into Keyshot along with a step file of the pipe. I ran the deformable mesh script and it renders out a bunch of .PNG files in the location of my choice. how do I get an animation out of this like the ones shown in previous messages?
Title: Re: Script for rendering deformable meshes
Post by: riddickuliss on February 09, 2017, 07:57:06 AM
I've already begun asking for help in this thread
https://www.keyshot.com/forum/index.php?topic=13433.0 (https://www.keyshot.com/forum/index.php?topic=13433.0)
But hoped some of you may be able to offer some guidance as well.
Exporting Alembic abc files out of Blender and following the directions on this thread with the Script provided, I am only getting renderings of one frame. I get as many duplicates as frames specified, but the timeline does not advance nor due the frames in the render. I have specified multiple frames in the Alembic export, but only one frame ever imports / renders.

I have a feeling I am missing something pretty basic as I am completely new to Blender and animations, any help or guidance would be much appreciated, you've all already been very helpful.

thanks
r* 
Title: Re: Script for rendering deformable meshes
Post by: riddickuliss on February 09, 2017, 10:20:55 AM
Not sure if it was the file, but after following a simple tutorial on creating a wave with a torus I was able to get this to work.
(https://static1.squarespace.com/static/55ddfecde4b073b82b6843c1/t/589cb165725e25b1e052586b/1486664041485/toruswave.gif?format=750w)

I'm still baffled as to what/why one worked and one did not. I have a lot to learn...

Title: Re: Script for rendering deformable meshes
Post by: riddickuliss on February 13, 2017, 07:21:24 AM
It seems when I export Alembic ABC files from Blender, the only files that work (show deformation) with the Rendering Deformable Meshes script with the waving torus gif above are those created by adding a "Wave" as a modifier. Everything else I try results in mesh that does not deform. Not sure if this is a Blender issues or a User issue.
Title: Re: Script for rendering deformable meshes
Post by: venkat on March 08, 2017, 07:32:30 PM
hi , script is working properly first time when i set up my file and import ABC seq and it gets added to Que... when i close my file and reopen same File and importing .ABC seq mesh deformation animation is not  getting  update, it hold on same frame as in the scene when it was opened ... and script show as it has imported with no error and all static image to render queue...
Title: Re: Script for rendering deformable meshes
Post by: KeyshotUser697 on April 29, 2017, 09:52:19 AM
Quote from: venkat on March 08, 2017, 07:32:30 PM
hi , script is working properly first time when i set up my file and import ABC seq and it gets added to Que... when i close my file and reopen same File and importing .ABC seq mesh deformation animation is not  getting  update, it hold on same frame as in the scene when it was opened ... and script show as it has imported with no error and all static image to render queue...

Yes, that's correct. I share the same issue.

Saving the imported .abc file with the environment,lighting and textures assigned.... out to a .bip file.. then re-opening that .bip file later will not allow the mesh to update with any animation when the script is initiated again.
Title: Re: Script for rendering deformable meshes
Post by: haf1bbc on September 07, 2017, 01:38:56 AM
Hi, thank you very much for this scripts. It is work very good. You are the master, big respect.
But I have problem when I wan to export Subdivision Surface animation from Cinema 4d R18 to alembic. When I do this and try to import at Keyshop 6, the mesh is looks like low poly, it is not with subdivision surface. Do you have some advice please on this?

It will be very helpfull for me
Title: Re: Script for rendering deformable meshes
Post by: mattjgerard on September 07, 2017, 07:28:07 AM
The plugin may not collapse the SDS transformations, you may have to bake the SDS animation before exporting.

What does the alembic look like if you import it back into C4D? If it looks correct, then its a KS import issue, if it looks incorrect then its a C4D export issue.