Soft2D
A 2D multi-material continuum physics engine designed for real-time applications.
Loading...
Searching...
No Matches
Overview

Soft2D is a 2D multi-material continuum physics engine designed for real-time applications. With soft2d, users can simulate various deformable objects, such as fluids, sand, snow, and elastic bodies within their applications.

Soft2D runs on GPU, leveraging the Taichi AOT (Ahead-of-Time) system for enhanced portability. The host logic of soft2d is written in C++, and for user convenience, we offer a comprehensive suite of easy-to-use interfaces in C language.

Download link: soft2d-release.

Quick Start

A minimal example of soft2d is shown as the following C++ code:

#include <taichi/cpp/taichi.hpp>
#include <soft2d/soft2d.h>
int main() {
// Create a runtime.
TiArch arch = TiArch::TI_ARCH_VULKAN;
ti::Runtime runtime(arch);
S2WorldConfig config;
// Specify a proper world configuration.
// ...
// Create an empty world.
S2World world = s2_create_world(arch, runtime, &config);
// Add bodies, colliders or triggers to the world.
// ...
// Simulate the world forward 100 times by a specified time step.
float time_step = 2e-3f;
for (int i = 0; i < 100; ++i) {
s2_step(world, time_step);
}
return 0;
}
S2_API void S2_API_CALL s2_step(S2World world, float delta_time)
struct S2World_t * S2World
Definition soft2d_core.h:61
S2_API S2World S2_API_CALL s2_create_world(TiArch arch, TiRuntime runtime, const S2WorldConfig *config)
Structure S2WorldConfig
Definition soft2d_core.h:340

‍Note: The above snippet can not be executed directly as the WorldConfig is not fully specified. A minimal runnable example can be found here.

More user examples can be found in the github repository soft2d-release.

Availability

Soft2D currently supports Vulkan and Metal backends. The table below illustrates the engine's compatibility across various platforms. For any specific requests regarding platform compatibility, feel free to contact us.

Backend Linux Windows MacOS iOS Android
CPU
Vulkan Y Y Y
Metal Y Y
CUDA P P
OpenGL
DirectX
  • 'Y': Soft2D is fully supported.
  • 'P': Soft2D support is under active development.
  • Blank cells: These platforms are not currently planned for support.

Unity Plugin

For the convenience of game developers, we also provide a free-to-access unity plugin - Soft2D for Unity, which allows users to build simulation scenes in a low-code way.