You are browsing as a guest. Sign up (or log in) to start making projects!

11h 15m 22s logged

Dev Log #1 - FaceFall

I started FaceFall because I kept seeing those short videos where a cloth drops over the same object at different mesh resolutions, but I don’t know how to use things like Blender to make them myself. The difference between a 2x2 sheet and a dense mesh is surprisingly satisfying, and I wanted to build my own version from scratch instead of relying on an existing physics engine.

The goal isn’t just to make another cloth simulator. The mesh density is the whole point. At really low resolutions the cloth behaves more like a stiff piece of cardboard, while higher resolutions start producing proper folds, ripples, and believable draping.

Reference: https://www.youtube.com/shorts/s_G2gBbWYF0

What’s working

So far I’ve built a complete cloth simulator in a single C99 source file using raylib.

Current features include:

  • Mass-spring cloth simulation
  • Structural, shear, and bending springs
  • Hooke’s law with damping
  • Semi-implicit Euler integration
  • Runtime cloth resolutions from 2x2 up to 64x64
  • Sphere, cube, and arbitrary OBJ mesh colliders
  • Three application modes:
    • Settings
    • Live preview
    • Deterministic render/export
  • Direct ffmpeg export to MP4

At this point it’s less of a physics experiment and more of a small content creation pipeline. I can recreate the exact same simulation with different resolutions and export identical camera angles for comparison videos.

Challenges

The biggest challenge early on was stability. Increasing spring stiffness quickly caused the simulation to explode, so I ended up basing the number of simulation substeps on the spring frequency instead of using a fixed timestep.

The cloth also stretched far too much at first and looked more like rubber than fabric. Adding strain limiting made a huge difference and stopped the structural springs from over-extending.

Collision was easily the hardest part. Spheres and cubes weren’t too bad, but arbitrary OBJ meshes became a rabbit hole of closest-point tests, broad-phase checks, collision response, and trying to stop particles tunnelling straight through thin geometry.

I also spent longer than I’d like fighting Windows. Exporting raw frames through ffmpeg would randomly corrupt the output until I realised _popen needed to be opened in binary mode.

Current bug

The biggest thing I’m still working through is sphere collision.

Most of the time it behaves exactly how I’d expect, but every now and then parts of the cloth clip into the sphere instead of settling over the surface. Once a few particles end up inside the collider the cloth starts rendering incorrectly, so it’s pretty obvious when it happens.

I’m fairly confident the issue isn’t the spring solver anymore. The collision detection itself is finding the contacts, but the positional correction isn’t always pushing particles completely back outside the sphere. That’s the main thing I want to fix before moving on.

What’s next

Once the collision is reliable I want to polish the visuals and start generating comparison clips at different mesh densities.

That’s really the whole reason I started this project. Seeing the exact same cloth drop change from a rigid, blocky sheet into something that actually looks like fabric is surprisingly satisfying, and now I finally have a tool that lets me create those videos however I want.

0
7

Comments 0

No comments yet. Be the first!