Home | Rules and Guide | Sign In/Create Account | Write a Post | Reddit | #ludumdare on irc.afternet.org (Info)

Ludum Dare 26 — April 26th-29th Weekend — Theme: Minimalism

  • Judging Ends: in 1 day, 9 hours, 11 minutes, 45 seconds
  • Play and Rate Games | View All Games | Edit | View My Entry
    Twitter | #ludumdare on irc.afternet.org

    [ Warmup Weekend | Real World Gatherings | Tools | Ludum Deals (yep, we got it) ]


    About kalle_h

    Entries

     
    Ludum Dare 23
     
    Ludum Dare 22

    kalle_h's Trophies

    Archive for the ‘LD #22’ Category

    How to make water simulation in couple hours.

    Posted by
    Wednesday, December 28th, 2011 3:35 am

    For my Ludum Dare entry Lonely miner I implemented water simulation.

    You can see it in action here:

    My entry

    First you need to know how to use box2d or some other fast physic library that can handle circles. Particle simulator would be best but integrating that to game would take some precious time that I didn’t have. So I created a pool and obstacles and hefty amount of small slippery balls with pretty high density. You don’t want any friction, damping and only small amount of restitution.  Radius of one ball is about 0.25m when my full screen size is 48m x 32m.

    So this is how things look with debug renderer on this stage.

     

    Simulating lots of dynamic bodies that clamp often to one place is really heavy weight operation. This need to be taken consideration. For this reason I used really inaccurate physic settings. I stepped world with only one velocity and position substeps. Also I fixed physic steps to 30/s.(After competition I noticed 20 would be enough) Always when dealing with fixed time step you want to interpolate or extrapolate position when physic are not stepped but rendering is. I choosed extrapolationing. This is simple to pull of.

    RenderPos = PhysicalPos + Velocity * TimeAccumulator

    Rendering is the part that trick players to believe that water is not just a bunch of tiny balls. My method was to render water drops as metaballs with radius twice the physical size of the object. Fastest way to make metaball was just sprite that is opaque at middle and fully transparent at edges with smooth circular gradient. I mixed some noise and color there to get better look. Water rendering need two pass. First water is rendered to small off-screen buffer and after that it is rendered as full-screen quad to screen with alpha test discarding too transparent pixels. This will give water hard edges, continuous body and vivid look. To get water drips non circular look just never clear the off-screen buffer completely but leave 75% of alpha channel left but discard alpha if its small enough. Every water drip have unique rotation to give little variety for look. I just ignored body rotation because I don’t want to reveal the circular origin of the water drips.

    For final touches I added velocity based color change. This will give nice waves if something collides with water. Its’s also important to render water after ground to get best look. Because water was little too chunky I just colored it to green and called it slime. Lighting and shadow give nice feeling too because water is box2d based and I have implemented open source box2dlights library, integration just worked out of the box. http://code.google.com/p/box2dlights/

     

    Performance is a problem after 500 water drips on desktop and 250 on android but this amount is just as much I need.

    Going to sleep.

    Posted by
    Sunday, December 18th, 2011 5:43 pm

    Final entry:

    http://www.ludumdare.com/compo/ludum-dare-22/?action=preview&uid=8618

    Thanks for the event.

    Must go deeper.

    Posted by
    Sunday, December 18th, 2011 8:25 am

    Jump.

    Posted by
    Sunday, December 18th, 2011 4:44 am

    Least after everything else my hero  finally get THE jump. It work well with fluid sim. You can’t jump from the slime.

    Bombs, head lamp, animation.

    Posted by
    Saturday, December 17th, 2011 3:31 pm

    Still no jump :(

    Posted by
    Saturday, December 17th, 2011 12:16 pm

    Posted by
    Saturday, December 17th, 2011 11:07 am

    Particles

    19:50 < kalle_h> custom fluid simulation, box2d lights, destroyable world,
    physic particles
    19:51 < kalle_h> but i dont have a jump
    19:51 < kalle_h> or gameplay

    :/

    Screenshot!

    Posted by
    Saturday, December 17th, 2011 5:04 am

     

    I am going to use my own soundhandler that make stuff little easier.

    http://pastebin.com/FTGjeQit

    Theme rant.

    Posted by
    Saturday, December 17th, 2011 12:35 am

    Theme is not inspiring but I wanted to do fluid simulator and that I gonna do. Game name should be “alone with fluid simulator” but i dont give up yet maybe there is idea somewhere hiding under technical stuff.

     

    Idea for fluid simulator is use box2d circles and render them as metaballs with alpha test shader. I hope that is gonna work or I am in trouble.

     

    http://pastebin.com/7HAkjrfw

    Hardcoded alpha test shader that I use.

     

     

    http://pastebin.com/wzhierEa

    Fixed timestep stepper. That I gonna use.

     

    Pipelines pipelines.

    Posted by
    Friday, December 16th, 2011 10:34 am

    I have set the project. Empty window is launching. Gameloop just need the game.

    I am plannign to use:

    My own Light library http://code.google.com/p/box2dlights/

    Box2d debugrenderer for prototyping.

    Maybe I can use physic particles to do something pretty. There is my test to show about 20k particles rendering 60fps while capturing the video.   http://www.youtube.com/watch?v=4bNkTgMXXj4

    I hope that theme will allow me hack  some fluid simulation something like you can see Where is my water.

    I also planning to use purely gles2.0 but I have never used it before for anythign really. Maybe shaders aren’t that hard at all. ;)

     

     

    I am in.

    Posted by
    Thursday, December 15th, 2011 5:15 am

    My first Ludum dare. I will use libgdx and hopefully get something to work for all desktops platforms + android.


    All posts, images, and comments are owned by their creators.

    [cache: storing page]