THIS GAME IS CURRENTLY BROKEN

Issue: https://github.com/Facepunch/sbox-issues/issues/7548

I'm only keeping it public right now so that Facepunch has an easy repro.

Instructions

Press ESC to exit any scene.
Use WASD to move freecam, and hold RMB to look around.
All windows with a blue title bar are draggable.

Features

  • High performance Verlet rope physics
    • Runs entirely on the GPU
    • Simulate hundreds of ropes at once
      • Fresh AABBs for each rope are available on the CPU every frame
      • Updates to specific rope points may be sent to GPU every frame
  • Collision resolution
    • Supports SphereCollider, CapsuleCollider, and BoxCollider with no extra effort
    • Supports mesh collisions by baking a mesh distance field
      • In scenes where this occurs, you may notice hitching
  • Cloth Simulation
    • Also runs on GPU, sharing much the same code as the rope
      • Every collider type that rope supports is also supported by cloth
    • Each point is constrained with its eight (four cardinal, four shear) neighbors
    • Supports 32x32 (max thread group size) resolution
      • Higher resolutions produce artifacts, for now
    • Updates a vertex and index buffer every frame, keeping the cloth mesh up to date

Test Scenes

Pachinko
  • Move your mouse to wrap the rope around pins.
Cloth
  • Freely modify the position and simulation parameters of cloth.
  • Watch cloth collide with various shapes.
Performance Benchmark
  • No actual benchmark yet - just spawn a bunch of GPU simulated ropes.
  • To see collisions, click the < and > arrows to change from "None" to "Sphere" or "Terry"
Mesh Distance Fields
  • This is very buggy and slow right now - I need to do a few fixes and some cleanup.
  • Generate mesh distance fields from a curated selection of models, and see how they collide with ropes.
  • Click on a voxel to open a window that will allow you to view each slice and texel of its volume texture.
    • Each octree leaf contains a volume texture that includes a gradient to the nearest triangle in the RGB channels, and a signed distance (after conversion) in the A channel.

Known Issues

  • There is a crash to desktop bug that seems somewhat random.
    • It's difficult to reproduce, and might not actually be happening anymore.
  • Collision resolution performance vs. meshes is poor
    • Too many unlikely colliders are being tested.
  • Mesh distance field build issues:
    • Performance tanks with high vertex counts
    • Build jobs are blocking the main thread more than is necessary
    • There are still large seams and cavities in many models

Post-Contest Plans

  • Library
    • Easy to use VerletRope and VerletCloth components
    • Allow different segments of rope to connect with each other
    • Run rope simulation in the editor window
      • Bake initial rope positions
  • Rope Physics
    • Rope points may have mass
    • Allow some points to be flagged as accessible on CPU
  • Mesh Distance Fields
    • Allow volume textures to represent an arbitrary size in worldspace.
      • Currently each volume texture is just 16^3 world units.
    • Optimize in-game bake process
      • The current solution scales very poorly with triangle count.
    • Cache large mesh distance fields to disk
    • Allow baking in editor, shipping prebaked mesh distance fields
    • Raymarched debug visualization