• Stars
    star
    101
  • Rank 326,269 (Top 7 %)
  • Language
    Python
  • Created over 2 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Houdini To Taichi(htoti) Element (Experimental)

This repository is for embedding the existing taichi-element, a High-Performance Multi-Material Continuum Physics Engine, as a Houdini extension. So that you can benefit from both flexibility for preprocessing via Houdini and the high performance via the ti engine.

Installing this plug-in

This plug-in only supports the Python3 versioned Houdini >=17.5. First, make sure to init the submodule to keep the same track of the (possible) customized edition of ti-element.

git clone [email protected]:taichi-dev/taichi_houdini.git --recursive

Houdini "plug-in" method

Houdini will automatically create a preference folder upon your 1st launch. On Linux, this folder is $Home/houdini_version_number. On windows, this folder is $USER/Documents/houdini_version_number. We will dive into this folder and install a JSON configuration file.

  • Create a folder named packages (if not existed) in your Houdini preferences folder.
  • Copy the htoti.json file in this directory into the packages folder.
  • Modifiy DIR_THIS_REPO to the path of this repo.

Installing packages under the Houdini directory

If you would like to manage the packages in the Python shipped with Houdini (i.e. python37), follow the steps below.

  • Linux
cd path_install_houdini/python/bin
./python3.7 -m pip install --user --upgrade taichi

On Linux, you may encounter problems when importing packages in Houdini's Python because your the system Python's version is different, consider creating a virtual environment.

  • Windows Navigate to the installation directory of Houdini, and dive into the Python folder (i.e. python37). In the case pip.py doesn't exist, you need to download pip first, then open the windows terminal in this folder and type
python3.7.exe get-pip.py
python3.7.exe -m pip install --upgrade taichi

Use Taichi in the Houdini Python shell

You can use Taichi in Houdini just like in any other normal Python shell. Try the following in any Python shell in your Houdini.

import taichi as ti
ti.init()
from fractal import fractalClass
f = fractalClass(512)
f.draw()

If you open the fractal.py, you will find that the only thing we did is to pack an existing taichi demo solver into a ti_data_oriented class, but leaving a parameter for the front-end, in this case, the Houdini, to set. You will find that the whole project is behind the idea that we combine the flexibility of Houdini and the performance of Taichi, merely with more parameters to set, and optimizations for the sake of performance.

You can see how to replicate this in Houdini by Examples/fractal.hipnc, although it's super slow and you might have noticed that taichi inits every frame. This is because Houdini losses the handler of the fractalClass every frame it re-executes the solver SOP, and we have to re-import or init() the taichi to avoid stack overflow. We discuss the solution in the later section.

Introduction to the MPM plug-in

MPM 88 and the ideas behind the plug-in

The fractal solver doesn't need the information of the previous frame to push forward the simulation, meaning it's a perfect demo for SOP cooking only. But to let the solver remember the previous frame information (and all finished frames), we also need help from the Built-in SOP Solver of Houdini.

Navigate to the mpm88, click into the geometry node you will see below.

Magic, the previous frames are remembered and used to push the simulation correctly. Don't panic, we will break down gradually. The above overall network says we are showing a constant colored background, and many small spheres to visualize the particles yield by the solver, easy.

Click into the solver, you find out that we create some physical properties, then merge the incoming, newly emitted particles into the existing particles, and somehow re-obtain the handler and let the ti-end knows the current state and advance. The emitors are merely points on 2 rotating ellipses which we believe you have 1,000 ways to create. The physical properties, for the mpm88 solver, are just 2 point attributes: Jp and C, hence can be created simply by the Python SOP or point wranglers.

All combined, it's working. Nonetheless, it is worthy of mentioning that this implementation is neither efficient nor compatible. 1. Just like the fractal example, to let the ti-solver knows the current state, it ti.init() every frame, creating a new solver class, the re-fill all the data from the NumPy array, which is super slow. 2. The emitor and the material-maker are inside the solver and can't be edited easily. We solve these in our HToTi-MPM solver.

Overall, the above procedure defines the simplest form of any htoti solvers: 1. a solver is written in taichi, packed as a ti.data_oriented class with proper parameter settings and APIs; 2. an SOP Solver node containing the proper python scripts to use the ti solver, re-obtain the data, and advance the simulation; 3. handling the input of emitors or other geometry SOP nodes to define the scene change before the solving, and 4. the external material-makers the solver to create necessary attributes for the simulation.

HToTi-MPM asset

In our HToTi-MPM asset, we solve the ti.init() problem by making MPM_solver_shell objects inside the module. When Python imports this module for the 1st time, these objects are materialized and kept in cache while Houdini is running. Hence, for every frame, we only need to re-fill the particle information, saving time for compiling and allocating memory.

We also move the emitors and colliders to be 2 external assets and connect them to the inputs of the solver SOP. Every frame, the solver SOP will read the updated emitors and colliders and refresh the corresponding settings. This procedure decouples the geometry editing and the solver's advancing and utilizes Houdini's flexibility.

Selecting parameters in the solver

The parameter interface of the solver lets you adjust global parameters such as dimension, resolution, dx, and gravity. It also lets you select the initial particles.

Making the materials, Editing the emitors in Houdini, FREELY

Material-Maker is an independent, packed SOP node, whose sole purpose is to create point attributes for all the points of the incoming node's geometry. We have made 4 selectable materials: 1. elastic, 2. water, 3. sand and, 4. snow.

The emitors are going to the 0th input of the solver. You can enjoy the 100% flexibility brought by Houdini and just merge the particles before feeding into the solver's 0th input. In the below demo, we can easily control the timing for different emitters by the parameter expressions and the Houdini Built-in Switch nodes.

Adding analytical collisions

The analytical collision goes to the 1st input of the solver. We have made the analytical planes(walls) and the analytical spheres. We are looking forward to contribution concerning box, tets, moving analytical collisions, and generalized SDF-based collisions.

Saving the cooked results via the ROP_geometry node

A quick tip from the Houdini side is to save your cooked results and do the post-processing later. We show below an example of the acid rain balls crashing at our planet. Do protect the environment!

Known issues

  • Editing a connected MPMSolver node will not update the hda. If you would like to contribute to this hda, always remember to sync your update to an unlocked, isolated htotiMPMSolver node after testing well, then lock and save it.
  • Reseting the simulation or modifying the SOP network before the MPM solver. This operation will dramatically slow down the following solving, try to save all the modifications then, restart Houdini.

More Repositories

1

taichi

Productive, portable, and performant GPU programming in Python.
C++
24,605
star
2

difftaichi

10 differentiable physical simulators built with Taichi differentiable programming (DiffTaichi, ICLR 2020)
2,378
star
3

taichi-nerfs

Implementations of NeRF variants based on Taichi + PyTorch
Python
687
star
4

games201

Advanced Physics Engines 2020: A Hands-on Tutorial
Python
490
star
5

taichi_elements

High-performance multi-material continuum physics engine in Taichi
Python
454
star
6

awesome-taichi

A curated list of awesome Taichi applications, courses, demos and features.
322
star
7

taichi_three

A soft renderer based on Taichi (work in progress)
Python
216
star
8

voxel-challenge

Python
210
star
9

meshtaichi

MeshTaichi: A Compiler for Efficient Mesh-based Operations (SIGGRAPH Asia 2022)
Python
201
star
10

taichi_blend

Taichi Blender intergration for physics simulation and animation
Python
152
star
11

quantaichi

QuanTaichi evaluation suite
Python
134
star
12

taichi-docs-zh-cn

Taichiไธญๆ–‡ๆ–‡ๆกฃ
127
star
13

faster-python-with-taichi

Python
76
star
14

taichicon

TaichiCon: Taichi Conferences
71
star
15

taichi_glsl

A Taichi extension library providing a set of GLSL-alike helper functions
Python
68
star
16

taichi-aot-demo

A demo illustrating how to use Taichi as an AOT shader compiler
C++
67
star
17

taichi.js

Run compiled Taichi kernels in JavaScript and WASM
Python
63
star
18

image-processing-with-taichi

Python
52
star
19

soft2d-release

Soft2D: A 2D multi-material continuum physics engine designed for real-time applications.
C++
48
star
20

Taichi-UnityExample

C#
46
star
21

cpp-training-season1

C++ training, season 1
C++
45
star
22

taichi_benchmark

Python
25
star
23

cheatsheet

TeX
24
star
24

taichi_dem

A minimal DEM simulation demo written in Taichi.
Python
24
star
25

docs.taichi.graphics

Home of the Taichi documentation site.
HTML
23
star
26

taichi-unity2

C++
20
star
27

cloth-simulation-homework

Python
16
star
28

community

13
star
29

advanced_examples

More advanced Taichi examples
Python
10
star
30

soft2d-for-unity

Soft2D-for-Unity
C#
10
star
31

poisson-sampling-homework

Python
9
star
32

sourceinspect

A unified inspector for retriving source from Python objects
Python
8
star
33

mls_mpm_88_extensions

Python
6
star
34

test_actions

C++
5
star
35

taichi_elements_blender_examples

5
star
36

public_files

5
star
37

dummy-rdp-client

Keep a live session by RDP, so OpenGL can function.
Rust
4
star
38

docstring-gen

Workflow for generating the docstring website
Python
4
star
39

mpm_3d_exercise

Python
4
star
40

stock_trading_strategy

Optimal stock trading strategy using Taichi
Python
3
star
41

taitopia-status-page

Taitopia status page
Markdown
3
star
42

taichi_assets

Taichi binary assets (submodule of the main Taichi repository)
3
star
43

taichi-release-tests

Python
2
star
44

blogs

Python
2
star
45

taichi-zoo-issue-tracker

This repository is used for collecting user feedback from the community
1
star
46

hackathons

Taichi โค๏ธ Hackathons
1
star
47

taichi_glad_ready

Ready to use GLAD as a OpenGL API loader
C
1
star