A single image layer to "play" an image sequence!

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

A single image layer to "play" an image sequence!

Post by heyvern »

HOLY FREAKING CRAP IT WORKS!!!!
-----------------------------------------------------------------
UPDATED
-----------------------------------------------------------------
Image Sequencer
Use a single image layer to display an image sequnence with variable frame rates.

http://www.lowrestv.com/images/files/im ... uencer.zip

The zip file includes the script, an AS sample file and a folder of sample images.

You may have to reload the image file in the sample AS file.

This is a layer script. It doesn't have any error checking yet so make sure you use it only on an image layer and have a proper set of image sequence files. It should work with png, jpg etc.

Instructions

You first need a set of image sequences with trailing numbers. They need to be formated like this (png or jpg etc):

imagename0001.png
imagename0002.png
....
imagename0010.png

In an AS file create an image layer BEFORE adding the script. It won't matter which image you use from the sequence since the script is based on the frame number.

After you have the image layer add this layer script by opening the layer properties and checking the Emedded script file box and selecting this script file.

The script will automatically change the image source based on the frame number. When there are no more images in the sequence the last image will be used past that point in the time line.

Variable Frame Rates

Open the script in a "simple" text editor (note pad, text edit, etc) and change the frame rate variable. It's set for 1 right now. Setting that number higher increses the number of frames each image "holds". Pretty straight forward.

Look for this code and change the frameRate variable:

Code: Select all

    if (moho.frame == 0) then
        frameRate = 1 -- set the frame rate
        initFrameRate = 0
    end
-vern


------------------------------------------------------------------
Original Post
------------------------------------------------------------------

Preliminary testing proves a SINGLE IMAGE LAYER can display a different image in a sequence for each frame. THIS IS WICKED COOL!

This idea came about from Mikdog's post of an ad he did using Toonboom in the share your work forum. We started a discussion about "painting" directly into Anime Studio for animation or stills. My idea is to create a script based drawing tool that saves out image sequences to a folder.

In my simple test I created a simple layer script that changes the source of the image layer based on the name and the frame number. This is SO COOL. It actually works in real time so rendering is no problem.

----------------

The goal is to have raster draw tools in AS. However that is going to take some time to develop. In the meantime I want to create a WAY BETTER EASIER script to display an image sequence that doesn't require switch layers and bunches of image layers IN the AS file. This script can do it.

-vern
Last edited by heyvern on Fri Jul 30, 2010 11:25 pm, edited 2 times in total.
sbtamu
Posts: 1915
Joined: Tue Dec 15, 2009 5:05 am
Location: Texas
Contact:

Post by sbtamu »

Sounds terrific; can't wait to see what you come up with. :D
Sorry for bad animation

http://www.youtube.com/user/sbtamu
User avatar
ulrik
Posts: 1087
Joined: Thu Aug 11, 2005 10:32 pm
Location: Stockholm Sweden
Contact:

Re: A single image layer to "play" an image sequen

Post by ulrik »

heyvern wrote:
The goal is to have raster draw tools in AS. However that is going to take some time to develop. In the meantime I want to create a WAY BETTER EASIER script to display an image sequence that doesn't require switch layers and bunches of image layers IN the AS file. This script can do it.

-vern
That would be awesome Vern, would it be possible to adjust for how many frames each picture will last as well?

Great done! :D
User avatar
Víctor Paredes
Site Admin
Posts: 5646
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Post by Víctor Paredes »

Absolutely awesome, vern!
sign me in if you need some beta testing :roll:

PD: I think it's exactly the type of frame by frame tool AS needs. A png sequence creator, with no need to add much info to the anme file.
It would be awesome to have some kind of new frame by frame layer type in which the normal tools would act as raster painting tools.
In current version it is excessively hard to make simple frame by frame.
Image Image Image Image
Moho Product Manager

www.mohoanimation.com
Rigged animation supervisor in My father's dragon - Lead Moho artist in Wolfwalkers - Cartoon Saloon - My personal Youtube Channel
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

My next test will be trying to "paint" and "save" images using scripting. Lua offers the ability to create and edit files. My thought at this stage is to start simple with a "blank" image "template" and draw on that and save it... I'm talking out my arse because I have no clue how this will work to be perfectly honest.

First off I know that "drawing" on screen is possible. When you use the "lasso" mode for selecting points and similar tools, it shows the path drawn as you select points. This uses the UI draw script interface. I've used this before to draw on screen but never tried to "save" the results. The trick then will be to somehow figure out how to apply that to a preexisting or new image. I don't want to get too negative this early but it could be that it isn't possible... hmm.... I hope so.

Basically my test script works perfectly. It loads the images for each frame. Yes, I believe setting "frame rates" or the number of frames each image plays is very easy. It will probably require editing the script since it is a layer script, or possibly an additional tool script that works with the layer script. The tool script could have settings. I haven't done that before so it's hard to say.

Basically to do the variable frame rates is just math, adding a number to the frame value. If the frame is within a defined range the same image is displayed. Piece of cake.

I think I will look into the lua side of things. It could be that lua itself has "bitmap" editing features "built in". Not sure though.

-vern
User avatar
Onionskin
Posts: 253
Joined: Wed Mar 04, 2009 2:01 pm

Post by Onionskin »

Great news!
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

I find it highly amusing and ironic I am working on this when I don't really want it or plan to use it much if at all. I guess though if I can pull this off it will quiet the screaming mob with torches at the gates.

;)

-vern
User avatar
Imago
Posts: 698
Joined: Wed Dec 10, 2008 9:48 am
Location: Sardinia

Post by Imago »

Raster design tool on AS? GREAT! I can't wait for it! :D
Sorry for my bad english... Q_Q
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Here's the first script from my experimenting:

http://www.lowrestv.com/images/files/im ... uencer.zip

The zip file includes the script, an AS sample file and a folder of sample images.

You may have to reload the image file in the sample AS file.

This is a layer script. It doesn't have any error checking yet so make sure you use it only on an image layer and have a proper set of image sequence files. It should work with png, jpg etc.

Instructions

You first need a set of image sequences with trailing numbers. They need to be formated like this (png or jpg etc):

imagename0001.png
imagename0002.png
....
imagename0010.png

In an AS file create an image layer BEFORE adding the script. It won't matter which image you use from the sequence since the script is based on the frame number.

After you have the image layer add this layer script by opening the layer properties and checking the Emedded script file box and selecting this script file.

The script will automatically change the image source based on the frame number. When there are no more images in the sequence the last image will be used past that point in the time line.

I haven't figured out yet how to adjust the "frame rate". Will update the script when I get it working. For now it's one image per frame.

-vern
User avatar
Víctor Paredes
Site Admin
Posts: 5646
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Post by Víctor Paredes »

Great to see it working, vern!
Right now it's very nice and more powerful than switches for image sequences. Please keep us informed if you have any new
Image Image Image Image
Moho Product Manager

www.mohoanimation.com
Rigged animation supervisor in My father's dragon - Lead Moho artist in Wolfwalkers - Cartoon Saloon - My personal Youtube Channel
User avatar
ulrik
Posts: 1087
Joined: Thu Aug 11, 2005 10:32 pm
Location: Stockholm Sweden
Contact:

Post by ulrik »

Great work Vern!
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

I just updated it for variable "frame rates". It's the same link above.

You must open the script in a text editor and change the frame rate variable. It's set for 1 right now. Setting that number higher increses the number of frames each image "holds". Pretty straight forward.

Look for this code and change the frameRate variable:

Code: Select all

    if (moho.frame == 0) then
        frameRate = 1 -- set the frame rate
        initFrameRate = 0
    end
-vern
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

I just had another cool idea.

For those with AS pro you could export image sequences from AS, load those into an image layer with this script to change the "frame rate" and rerender.

Because of what I've done so far, I may be able to jury rig a script to change the "frame rate" at render time for traditional animation in AS, for example changing all the keys to only render every 2 or 4 frames. Not sure but I will give it a shot.

-------------------------

I am still working on the "paint" tools. It looks possible. Lua can handle byte code and load bmp raster format for processing. The trick will be finding some code from other people that can translate mouse tracking to pixel positions to paint on the image files for each frame.

This will probably not have "real time" updating as you draw. For example I can "fake" the draw strokes using the AS built in draw display, then that stroke information would be saved to the image file. This would be very similar to how the vector draw tools work.

I found some resources on a gaming forum for people using lua that has some example source code to read in a bmp file, edit and save it. I have to incorporate this into a script to see how it works.

-vern
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

AHHHHGGGGGG!

Okay, painting support is going to take a while. Even if I can eventually pull it off figuring out all the freaking math to store pixel data will make my ears bleed. Not giving up. Still doing research. I was able to open, read and partially parse a PNG file using a simple menu script, retrieving basic file information. That was exciting but pretty useless to me right now.

At this point my main research is focused on bitmap support in the core lua inside Anime Studio. If AS lua doesn't have "extra" image support libraries it could make the job either very much harder or impossible. Core lua doesn't have image support by default, so people who use lua in their applications can add additional libraries to add that functionality.

-vern
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Some feedback please on my thoughts for image editing in AS script.

This script works so well because edits to the images are updated automatically since they are loaded through the script. The image is never stored in AS memory like a "normal" image layer. Each time you move through the timeline in AS the image for that frame is reloaded from the source. If you use an external editor to change an image in the sequence it will be reloaded when you go to that frame in AS.

My thought is that creating bitmap editing in AS with scripting will be a major time consuming undertaking. Is it needed? By using this script with ANY cheap, free, open source, commercial etc, image editing tool there doesn't seem to be a dieing need for an "in application" editor.

People can use the application they like the best for painting and drawing bitmap images and see the results IMMEDIATELY, instantly in AS.

I am thinking it would be easier/better to somehow "link" image editing to a user definable editing application. For example a tool or preference in a script for AS that saves the path to Photoshop, or Gimp. You click "edit image" in some kind of custom tool button and then the tool script will launch that application and open the image for that frame for editing externally to AS.

Any thoughts? Does this sound like a good option?

My main concern is I don't think lua in AS has the resources to actually edit and save bitmap files and if it does the programming required seems to be a bit over my head. I'm not as smart as many of you might think. ;)
Post Reply