Tag Archives: Mesh

Some tries with LÖVE game engine in Lua

* Ce billet est également disponible en français.

Drawn with Pencil2D and MyPaint, animated using meshes in LÖVE (Lua language), I also made some tests in C with libSDL, but it is probably faster to prototype in Lua with LÖVE, and then add FFI libs for compute intensive part (in these cases light computations, GL is used for rendering), or port it to c+SDL at second time, when algorithms are validated. All used software are 100% FOSS used on a GNU/Linux system.

This one use simply a mesh on a picture, and deform them using circular motions, as I done in TIC-80 in July 2021.

The picture used for the mesh:

A modified version, with fixed hard skull, I keep both version, this one is interesting for anthropomorphic head, the other for more realistic invertebrate.

This test gather different tests with shaders. I apply a threeshold, above is one colour under, is another, this allow to have interesting clean 2 colours effects Source code of these shaders for LÖVE is available on Framagit (demo01.love file on this site).

This other one also use a mesh on a picture with 2 steps, swapping from one to each other moving the drawing shape, but instead, of deforming it by sin(), it curve the mesh, by adding curvature at each step, and a little sinus wave to simulate something that goes through the body.

the liquid the the monster reject, is a texture, that is copied to a Canvas, to wrap it and loop it, This part was inspired by the game “Conan Chop Chop”. But I fine tuned a bit: A shader is then applied on the canvas when drawing on screen surface, it scale the pixels along the path of the liquid, and add a light waving motion. the splash at the end is a cycle between 3 pictures.

The quickly drawn 2 steps monster, it could be optimized on disk by creating the duplication of the body after loading, LÖVE is not convenient as libSDL for textures mesh:
bidule spritesheet

The picture used as texture for for the shader:
flux de vomit intense

The splash at the end, each part are displayed sequentially in loop, this was animated with Pencil2D (MyPaint branch):
Eclaboussure de vomit

The animation is first made with Pencil2D, then saved with one picture (PNG with transparency) by frame, and then ImageMagick package, “montage” is used to build the spritesheet the following wy:

montage sprite0001.png sprite0006.png sprite0010.png -tile 3x1 -geometry 64x128 spritesheet.png

Using about the same methods, I then improved my code to manage a more generic way, hand drawn animation made with Pencil2d as mesh. Here is an animated sketch of flower opening, as proof of concept.

Blooming flower

Update of march 19:

It uses 8 frames, with various framerates, managed in a table, is here the frame number table:

table = {1,1,2,2,2,3,3,4,4,4,5,5,6,6,7,8,8,8,8,8}

I can then cycle easily in the table using math.floor( (time()*fps) % #table), or just parse it one time for exemple here for a flower that just open one time.

I then used it as decoration element. Now it work, I can refine animation, still make it more generic to have only to add minimum information, and be able to add quickly new animations.

After the good result of the first test of the animation with program, I cleaned a little the flower and added some colours. I then noticed than the last frame, where the flower move is stabilized missed. The picture before the last was duplicated as 2 last frames in my spritesheet. Anyway, I need to remove some useless space around the flower, separate stem and flower itself to reduce memory usage; It already take, reduced in 128×128 pixels 180~200 Ko (150 Ko compressed better with zopflipng). This is too fat, if you multiply this by the number of objects/characters you can quickly reach tens of MB (png compressed) on disk, and far more on Graphics RAM, saturating ram, cache and bandwidth, and so slowing down rendering. I believe that separate flower and keeping in a something like 64×64 pixels animation could be fine the stem could be a flat texture, blended by procedural means.

Fleur qui s'ouvre améliorée

”’Update may 2022 ”’
* You can test all of this, from the sources available at https://framagit.org/popolon/reforest.
* Ready last version LÖVE files and archives are available at the address https://framagit.org/popolon/reforest/-/releases (version 0.2 from this site).

Reforest 0.2 Screenshot