Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - kabaiakh

#1
Game art & music / Re: Snow flakes
July 21, 2022, 05:25:28 PM
We want to animate falling snow flakes in the Solarus game engine framework.



The main screen size is 320x240 (QVGA for those from bygone days), traditionally animated using wrapping tiles.

Let's pick up a 32x24 one, because the dimensions (width && height) of one tile must be multiple of 8 under Solarus.
Put it into motion with 24 frames so the animation can loop at 40_ms delay per frame (slow snow, persistence of vision).
We get a 18.432_kpx animation (32*24*24), tiled 10x10 on the screen as shown hereafter.

One small tile

 
   
   
WxH   |   kpx   |   tiling
32x24   |   18.432   |   10x10

 
   
     

Preferring something with less -- if not without -- patterns ?
We could generate a more evenly randomized tile and ...
we would replace patterns with a grid or ...
we should try to make one single 320x240 tile.

One big tile

 
   
   
WxH   |   kpx   |   tiling
320x240   |   18432   |   1x1

 
   
     

This tile is 1000 times heavier (320*240*240=18432_kpx).
Too large / too tall for Solarus, which prefers the overall size of tiles sets
to be less than 2048 for compatibility reasons.

So, besides getting rid of patterns, we also need to limit pixels overweight in the process.
The good news is both those goals can be reasonably achieved by superimposing
two differently sized tiles so that they conceal each other's patterns.

Two differently sized tiles

 
   
   
WxH   |   kpx   |   tiling
32x40+40x24   |   74.24   |   2x2

 
   
     

Let's begin the off-putting underlying theory detailed explanations with a basic layout of two same size tiles.
Each one has its own patterns, we label them and .
When we overlay both, we obtain a new pattern, unrandomly labeled .


 
   
   
   
1 * tile #1   
1 * tile #2   
overlay   

Not that good once tiled on the screen. We still see patterns.


 
   
Tile #1
       
WxH   |   kpx   |   tiling
24x24   |   13.824   |   13.33x8

   
     Tile #2
       
WxH   |   kpx   |   tiling
24x24   |   13.824   |   13.33x8

   
     Overlay
       
WxH   |   kpx   |   tiling
24x24   |   13.824   |   13.33x8

   
If we do the same thing with differently sized tiles as aforementioned, we get something more interesting.
Let's just take a tile of 2 patterns and another one of 3 patterns :


 
   
   
   
1 * tile #3   
1 * tile #4   
overlay   

The overlay builds a 'meta-tile' comprised of 6 new patterns which then resume their cycling.
Those 6 patterns are built upon only 5: 2 from tile #3 ( and ) plus 3 from tile #4 (, and ).
Arithmetically, 6=lcm(2,3) and 5=2+3 (arrest this man, he talks in maths).
We do not 'see' 3 repeating or 2 repeating but only one larger .


 
   
Tile #3
       
WxH   |   kpx   |   tiling
16x24   |   9.216   |   20x10

   
     Tile #4
       
WxH   |   kpx   |   tiling
24x24   |   13.824   |   13.33x10

   
     Overlay
       
WxH   |   kpx   |   tiling
48x24   |   23.040   |   6.66x10

   
With this second tile example, the meta-tile is 48x24 (from a 16x24 tile and a 24x24 one).
Tiny compared to 320x240 but the bigger the meta-tile, the fewer patterns.
So what would be the best ratio for our screen (smallest tiles for biggest patterns-concealing) ?

That would be scann'd and dimensioj-kalkuli is here to enumerate all the possible combinations;
among which two in particular attract attention.


 
   
   
   
   |    meta-tile    |    tile set    |    W / H    |    H / W    |   
sizes A    |    160    |    1280    |    40    |    32    |   
sizes B    |    120    |    960    |    40    |    24    |   

Since 32 is 1/10 of the screen's width and 24, 1/10 of its height,
let 32 be the width for tile #5 and 24, the height for tile #6.
We get a 160x120 meta-tile. 1/4 of the screen. Shiny.

There is also another scheme: 40x32 + 24x40.
Unfortunately, 40*32*32+24*40*40 = 79.36_kpx when 32*40*40+40*24*24 = 74.24_kpx only !

Now is time for kahelo-animi to (slowly) generate images magically.


 
   
Tile #5
       
WxH   |   kpx   |   tiling
32x40   |   51.2   |   10x6

   
     Tile #6
       
WxH   |   kpx   |   tiling
40x24   |   23.04   |   8x10

   
     Overlay
       
WxH   |   kpx   |   tiling
32x40+40x24   |   74.24   |   2x2

   
Compared with the first two one-tile solutions, lightest * 4 but heaviest / 250.
Totally worth it, as it prevents eye bleeding. Judge yourself.


 
   
One small tile
       
WxH   |   kpx   |   tiling
32x24   |   18.432   |   10x10

   
     Two differently sized tiles
       
WxH   |   kpx   |   tiling
32x40+40x24   |   74.24   |   2x2

   
     One big tile
       
WxH   |   kpx   |   tiling
320x240   |   18432   |   1x1

   

 
   

Remains to be applied to Solarus:

           

My God !
It's full of stars.
And, voila ! solarus-vetero.tiles.png solarus-vetero.dat
Crystal bits of snowflakes all around my head and in the wind.

The scenery provides its own patterns hiding as shown below
(customary animated GIF everywhere for compatibility).


 
   


Foreground flakes
Are sparse, scattered and fast.
Could also be big and bright.
     

Background flakes
Are numerous, tight and slow.
Could also be tiny and dark.

Of course, the principle is not tied to two tiles top, it would work well with way more.
Needless to say, laziness can grasp even the most motivated ...

Similar to the context-free chaos theory, this method should be quite ecumenical
and could theologically theoretically be applied to animations other than snow: mist, rain, swell  ...
It might as well already exists, just like this ancient 'differential scrolling' was indeed a mere parallax.
#2
Game art & music / Re: Snow flakes
July 21, 2022, 12:36:06 AM
Be reassured, I ain't no ser spammer.
For demonstrating purpose, I made use of CSS to overlay images.

Thank you for your exlpainations, this thread won't rot unanswered.
I'm working on a conversion into something that can be displayed here.
#3
Game art & music / Snow flakes
July 19, 2022, 09:01:21 PM
Hi.

I've recently finished some work of mine and I thought some of you might be interested in.
AFAIC, I would appreciate feedbacks: understandability and/or prior existence of the technique, optimisations for weight at run time within the Solarus engine, incorrect spelling ...

Enjoy ! ;–)

https://kabaiakh.pagesperso-orange.fr/solarus-vetero/