taichi-dev / taichi_elements

High-performance multi-material continuum physics engine in Taichi
MIT License
483 stars 69 forks source link

no (Force Fields) nodes #77

Closed AnasFX closed 2 years ago

AnasFX commented 3 years ago

blender : 2.82 taichi_elements : latest Also : https://github.com/victoriacity/taichi_elements commet

When trying to test the examples in blender there is no (Force Fields) nodes, it shows as red box with (Undefined) title. Also, Add > Force Fields > Gravity doesn't exist at all.

image

AnasFX commented 2 years ago

Hi, is there any new news about fixing this issue. Best regards

PavelBlend commented 2 years ago

@AnasFX Where did you download the sample scenes from? From here?: https://github.com/taichi-dev/taichi_elements_blender_examples If so, these scenes are outdated. For them to work properly, you need to download an older version of the blender add-on. The Works on commit column indicates on which commit these scenes were created.

AnasFX commented 2 years ago

@PavelBlend That's correct I download it from that link.

Does that mean that we can't use forces in the new versions ? or is there another way of testing taichi_elements in blender ? If there is a new workflow or help so I can test taichi_elements on blender would you kindly point me to it. Thanks

AnasFX commented 2 years ago

@PavelBlend also is there a discord channel for taichi and taichi_elements ? it would be nice to communicate on discord about features and fixing problems.

PavelBlend commented 2 years ago

@AnasFX I will now prepare a blend scene and give you a download link.

PavelBlend commented 2 years ago

@AnasFX created scenes: taichi_elements_blender_examples.zip

I've only tested them in blender 2.93.

AnasFX commented 2 years ago

@PavelBlend Thank you very much , I will test it and report back

AnasFX commented 2 years ago

@PavelBlend Sorry I forgot to mention that I have two gpus, gpu0 : 3090 FE on slot 0, gpu1 : 980ti on slot 1 on the motherboard, and I chose only the 3090 in the CUDA blender preferences @PavelBlend when I press simulate the first simple scene (and the second scene, I guess they have the same error , if you want I can paste the second error from the console) doesn't work, the console shows this error : Read prefs: C:\Users\Administrator\AppData\Roaming\Blender Foundation\Blender\2.93\config\userpref.blend [Taichi] version 0.8.0, llvm 10.0.0, commit 181c9039, win, python 3.9.2 drop file C:\New folder\taichi_elements_simple_example.blend Read blend: C:\New folder\taichi_elements_simple_example.blend [Taichi] Starting on arch=cuda Creating simulation of res 32, size 4.0 DeprecationWarning: ti.indices is deprecated. Please use ti.axes instead.

File "C:\blender-2.93.4-windows-x64\2.93\python\lib\threading.py", line 912, in _bootstrap self._bootstrap_inner() File "C:\blender-2.93.4-windows-x64\2.93\python\lib\threading.py", line 954, in _bootstrap_inner self.run() File "C:\blender-2.93.4-windows-x64\2.93\python\lib\threading.py", line 892, in run self._target(*self._args, **self._kwargs) File "C:\blender-2.93.4-windows-x64\2.93\scripts\addons\taichi_elements\operators.py", line 247, in init_sim solv = mpm_solver.MPMSolver((res, res, res), size=size, unbounded=True) File "C:\blender-2.93.4-windows-x64\2.93\scripts\addons\taichi_elements\engine\mpm_solver.py", line 185, in init block.dynamic(ti.indices(self.dim),

Voxelizer resolution [32, 32, 32] Frame: 0 Taichi JIT:0: allocate_from_buffer: block: [6,0,0], thread: [3,0,0] Assertion Out of CUDA pre-allocated memory. Consider using ti.init(device_memory_fraction=0.9) or ti.init(device_memory_GB=4) to allocate more GPU memory failed. [E 09/24/21 22:38:43.163 3836] [taichi/backends/cuda/cuda_driver.h:taichi::lang::CUDADriverFunction<void *>::operator ()@86] CUDA Error CUDA_ERROR_ASSERT: device-side assert triggered while calling stream_synchronize (cuStreamSynchronize)


Internal error occurred. Check out this page for possible solutions: https://docs.taichi.graphics/docs/lang/articles/misc/install Exception in thread Thread-1: Traceback (most recent call last): File "C:\blender-2.93.4-windows-x64\2.93\python\lib\threading.py", line 954, in _bootstrap_inner self.run() File "C:\blender-2.93.4-windows-x64\2.93\python\lib\threading.py", line 892, in run self._target(*self._args, *self._kwargs) File "C:\blender-2.93.4-windows-x64\2.93\scripts\addons\taichi_elements\operators.py", line 261, in init_sim self.run_sim() File "C:\blender-2.93.4-windows-x64\2.93\scripts\addons\taichi_elements\operators.py", line 182, in run_sim self.create_emitters(frame) File "C:\blender-2.93.4-windows-x64\2.93\scripts\addons\taichi_elements\operators.py", line 130, in create_emitters create_emitter(self.solv, emitter, vel) File "C:\blender-2.93.4-windows-x64\2.93\scripts\addons\taichi_elements\operators.py", line 108, in create_emitter solv.add_mesh(triangles=tris, material=ti_mat, color=color, velocity=vel) File "C:\blender-2.93.4-windows-x64\2.93\scripts\addons\taichi_elements\engine\mpm_solver.py", line 986, in add_mesh self.voxelizer.voxelize(triangles) File "C:\blender-2.93.4-windows-x64\2.93\scripts\addons\taichi_elements\engine\voxelizer.py", line 126, in voxelize self.voxelize_triangles(num_triangles, triangles) File "C:\blender-2.93.4-windows-x64\2.93\python\lib\site-packages\taichi\lang\kernel_impl.py", line 738, in call return self._primal(self._kernel_owner, args, *kwargs) File "C:\blender-2.93.4-windows-x64\2.93\python\lib\site-packages\taichi\lang\kernel_impl.py", line 606, in call return self.compiled_functions[key](args) File "C:\blender-2.93.4-windows-x64\2.93\python\lib\site-packages\taichi\lang\kernel_impl.py", line 563, in func__ t_kernel(launch_ctx) RuntimeError: [taichi/backends/cuda/cuda_driver.h:taichi::lang::CUDADriverFunction<void *>::operator ()@86] CUDA Error CUDA_ERROR_ASSERT: device-side assert triggered while calling stream_synchronize (cuStreamSynchronize)

AnasFX commented 2 years ago

@PavelBlend I will try the LTS Release 2.93.0 Version as you mentioned and report back

AnasFX commented 2 years ago

@PavelBlend unfortunately even with version 2.93.0 I have this error. I tried to check the 980ti alone in the preferences, even checked my cpu only, with no luck. It falls back to cuda, but displays this error

[Taichi] Starting on arch=cuda Creating simulation of res 32, size 4.0 DeprecationWarning: ti.indices is deprecated. Please use ti.axes instead.

File "C:\blender-2.93.0-windows-x64\2.93\python\lib\threading.py", line 912, in _bootstrap self._bootstrap_inner() File "C:\blender-2.93.0-windows-x64\2.93\python\lib\threading.py", line 954, in _bootstrap_inner self.run() File "C:\blender-2.93.0-windows-x64\2.93\python\lib\threading.py", line 892, in run self._target(*self._args, **self._kwargs) File "C:\blender-2.93.0-windows-x64\2.93\scripts\addons\taichi_elements\operators.py", line 247, in init_sim solv = mpm_solver.MPMSolver((res, res, res), size=size, unbounded=True) File "C:\blender-2.93.0-windows-x64\2.93\scripts\addons\taichi_elements\engine\mpm_solver.py", line 185, in init block.dynamic(ti.indices(self.dim),

Voxelizer resolution [32, 32, 32] Frame: 0 Taichi JIT:0: allocate_from_buffer: block: [6,0,0], thread: [3,0,0] Assertion Out of CUDA pre-allocated memory. Consider using ti.init(device_memory_fraction=0.9) or ti.init(device_memory_GB=4) to allocate more GPU memory failed. [E 09/24/21 23:09:33.947 15612] [taichi/backends/cuda/cuda_driver.h:taichi::lang::CUDADriverFunction<void *>::operator ()@86] CUDA Error CUDA_ERROR_ASSERT: device-side assert triggered while calling stream_synchronize (cuStreamSynchronize)


Internal error occurred. Check out this page for possible solutions: https://docs.taichi.graphics/docs/lang/articles/misc/install Exception in thread Thread-1: Traceback (most recent call last): File "C:\blender-2.93.0-windows-x64\2.93\python\lib\threading.py", line 954, in _bootstrap_inner self.run() File "C:\blender-2.93.0-windows-x64\2.93\python\lib\threading.py", line 892, in run self._target(*self._args, *self._kwargs) File "C:\blender-2.93.0-windows-x64\2.93\scripts\addons\taichi_elements\operators.py", line 261, in init_sim self.run_sim() File "C:\blender-2.93.0-windows-x64\2.93\scripts\addons\taichi_elements\operators.py", line 182, in run_sim self.create_emitters(frame) File "C:\blender-2.93.0-windows-x64\2.93\scripts\addons\taichi_elements\operators.py", line 130, in create_emitters create_emitter(self.solv, emitter, vel) File "C:\blender-2.93.0-windows-x64\2.93\scripts\addons\taichi_elements\operators.py", line 108, in create_emitter solv.add_mesh(triangles=tris, material=ti_mat, color=color, velocity=vel) File "C:\blender-2.93.0-windows-x64\2.93\scripts\addons\taichi_elements\engine\mpm_solver.py", line 986, in add_mesh self.voxelizer.voxelize(triangles) File "C:\blender-2.93.0-windows-x64\2.93\scripts\addons\taichi_elements\engine\voxelizer.py", line 126, in voxelize self.voxelize_triangles(num_triangles, triangles) File "C:\blender-2.93.0-windows-x64\2.93\python\lib\site-packages\taichi\lang\kernel_impl.py", line 738, in call return self._primal(self._kernel_owner, args, *kwargs) File "C:\blender-2.93.0-windows-x64\2.93\python\lib\site-packages\taichi\lang\kernel_impl.py", line 606, in call return self.compiled_functions[key](args) File "C:\blender-2.93.0-windows-x64\2.93\python\lib\site-packages\taichi\lang\kernel_impl.py", line 563, in func__ t_kernel(launch_ctx) RuntimeError: [taichi/backends/cuda/cuda_driver.h:taichi::lang::CUDADriverFunction<void *>::operator ()@86] CUDA Error CUDA_ERROR_ASSERT: device-side assert triggered while calling stream_synchronize (cuStreamSynchronize)

AnasFX commented 2 years ago

I do remember something like this message, the problem was about choosing how much VRam for the device_memory :

Taichi JIT:0: allocate_from_buffer: block: [6,0,0], thread: [3,0,0] Assertion Out of CUDA pre-allocated memory. Consider using ti.init(device_memory_fraction=0.9) or ti.init(device_memory_GB=4) to allocate more GPU memory failed

but I don't remember the fix, any thoughts ?

PavelBlend commented 2 years ago

I have tested the simulator on taichi 0.7.32. Taichi 0.8.0 was released two days ago. Try to install taichi version 0.7.32: pip install taichi==0.7.32 If the problem persists, then turn off the rendering with cuda. To do this, you need to change the line here: https://github.com/taichi-dev/taichi_elements/blob/e6d2db2b74f5177a1bdd615d485f49ca0fcfb9d3/blender/operators.py#L245

change to: ti.init(arch=ti.cpu) or ti.init(arch=ti.cuda, device_memory_GB=4)

PavelBlend commented 2 years ago

@AnasFX I updated the addon. Download the latest commit: https://github.com/taichi-dev/taichi_elements/tree/d33bf33042b75cc8452b6b8f5ecdb2aeb093884e I added parameters for the Simulate button: 01

AnasFX commented 2 years ago

@PavelBlend That actually did the trick. The simple scene works on the latest Taichi 0.8.0. Water - Snow - Elastic - Sand - Stationary all work on CPU and GPU.

When I press Simulate I can see where the cache files are, but when I press Render I can't see where are the rendered images , is this normal, are they saved automatically or should I assign a save node ?

PavelBlend commented 2 years ago

@AnasFX the render is saved here: 01

AnasFX commented 2 years ago

@PavelBlend Thank you very much, Can you help me to know what is the function of the Render button ? 0020

I assumed that the Render button would mesh the particles with some kind of a meshing algorithm to get a solid representation of the particles so it can be rendered directly without the need to create a heavy dense mesh. Is my assumption correct ? or should we use another method to convert and render these particles to a mesh, something like rendering Jelly or Water

I also noticed that after it uses the memory and finishes the simulation it doesn't release the memory, and when you render with the GPU nothing would be left for the rendering process, is this normal, or is there a way to make it release the memory manually , something like a button similar to the one that you created ?

PavelBlend commented 2 years ago

@AnasFX if you start rendering with the standard button, the blender will often crash. So I added a render button that renders the animation frame by frame, rendering it single frames, but in automatic mode. This makes the rendering of the particles more stable.

The button has no other functions.

For the particles to be visible on the render, you need to set up the standart particle system. Or use dupli-verts for the mesh object.

As for the memory, I don't know exactly why it is not released. I will deal with this later.

Probably for now you need to restart blender before starting rendering. I am not the author of the taichi language and the MPM engine. So I don't know why the graphics card memory is not freed.

AnasFX commented 2 years ago

@PavelBlend Thank you so much for the detailed explanation, for the quick reply and for the quick fix. I will continue testing, and if I had any issues I will report them here. Best regards

AnasFX commented 2 years ago

@PavelBlend Hi, I have a question please, is there a way to implement a collider node so one can use objects for collisions ? I found only a Ground node, but nothing else that can be used as a collision object.

PavelBlend commented 2 years ago

@AnasFX Hi. There are no colliders at this time. The only colliders are ground. But recently, static particles have been added that can replace colliders. Add an emitter with Stationary material. And it will be necessary to remove static particles from the render in some way. Probably this can be done using the Transparent BSDF node. And static particles should be, for example, black (0, 0, 0) so that they can be easily filtered using the nodes in the Shader Editor.

AnasFX commented 2 years ago

@PavelBlend Sorry I couldn't figure out how to use the stationary particles with the normal particles as a collider, could you give me an example how to use them both.

AnasFX commented 2 years ago

@PavelBlend I manged to figure out how to use the stationary particle, unfortunately the results are not good and can not be used like a ground or a normal collider, also I believe the increase in particles would lead to unnecessary overhead simulation power and time 😞