taichi-dev / taichi_glsl Goto Github PK
View Code? Open in Web Editor NEWA Taichi extension library providing a set of GLSL-alike helper functions
Home Page: https://taichi-glsl.readthedocs.io
A Taichi extension library providing a set of GLSL-alike helper functions
Home Page: https://taichi-glsl.readthedocs.io
The latest version (0.0.8) doesn't work because this line is not included in the release.
taichi_glsl/taichi_glsl/lagrangian.py
Line 6 in bdff10b
This affects examples (e.g. mass_spring_3d). Following error will be raised. Maybe we should release a new version? π€
[Taichi] mode=release
[Taichi] preparing sandbox at /var/folders/59/8w1k63jj0vs_rv19jwyf1nf00000gn/T/taichi-f1cw8gi3
[Taichi] version 0.6.29, llvm 10.0.0, commit f1bde29b, osx, python 3.8.5
[TaiGLSL] version 0.0.8
[TaiGLSL] Inputs are welcomed at https://github.com/taichi-dev/taichi_glsl
[Tai3D] version 0.0.3
[Taichi] Starting on arch=x64
[Taichi] materializing...
Traceback (most recent call last):
File "references/mass_spring_2d.py", line 105, in <module>
substep()
File "/Users/[REDACTED]/venv/lib/python3.8/site-packages/taichi/lang/kernel.py", line 580, in wrapped
return primal(*args, **kwargs)
File "/Users/[REDACTED]/venv/lib/python3.8/site-packages/taichi/lang/kernel.py", line 507, in __call__
self.materialize(key=key, args=args, arg_features=arg_features)
File "/Users/[REDACTED]/venv/lib/python3.8/site-packages/taichi/lang/kernel.py", line 378, in materialize
taichi_kernel = taichi_kernel.define(taichi_ast_generator)
File "/Users/[REDACTED]/venv/lib/python3.8/site-packages/taichi/lang/kernel.py", line 375, in taichi_ast_generator
compiled()
File "references/mass_spring_2d.py", line 52, in substep
v[i] = tl.ballBoundReflect(x[i], v[i], tl.vec(+0.0, +0.2, -0.0), 0.4,
File "/Users/[REDACTED]/venv/lib/python3.8/site-packages/taichi/lang/kernel.py", line 42, in decorated
return fun.__call__(*args)
File "/Users/[REDACTED]/venv/lib/python3.8/site-packages/taichi/lang/kernel.py", line 87, in __call__
ret = self.compiled(*args)
File "/Users/[REDACTED]/venv/lib/python3.8/site-packages/taichi_glsl/lagrangian.py", line 43, in ballBoundReflect
above = tl.distance(pos, center) - radius
NameError: name 'tl' is not defined
Can be very helpful for rendering purpose. Contributions are welcome!
GLSL docs:
reflect: https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/reflect.xhtml
refract: https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/refract.xhtml
Hi, I'm the guy who posted this.
I'm currently considering to refactor my project to make it easier to extend. So I remembered in that post you mentioned the ts.TaichiClass, which is an enhanced version for ti.data_oriented.
Could you explain more about what's the difference between these two class because I did not find a concrete example(except the complex class from glsl) or documentation?
For example, for the question I raised in that post, how exactly the ts.TaichiClass could make a difference?
Could I directly replace every @ti.data_oriented decorator in a typical taichi class to ts.TaichiClass ?
Sorry my python skill could not support me to master the exact difference from source code
Thanks in advance !
So ti.pyfunc can be called from both Taichi and py scope.
So is there any reason for the existence of ti.func(except for it takes time to refactor the previous code ?) for now?
If ti.func is kind of obsolete, could you update the ti.func in this repo to ti.pyfunc? Because that make it easier to debugπ, since we do not need to explicitly call @ti.kernel in our code to test.
import taichi as ti
import taichi_glsl as ts
ti.init(arch=ti.gpu)
@ti.func
def unroll(v):
for i in ti.static(range(3)):
v[i]= 0
@ti.data_oriented
class Test:
def __init__(self):
self.v = ti.Vector.field(3, dtype=ti.f32)
ti.root.dense(ti.i, 100 ).place(self.v)
@ti.kernel
def test(self):
for i in self.v:
unroll(self.v[i])
test1 = Test()
test1.test()
[Taichi] version 0.8.12, llvm 10.0.0, commit 2cc32047, osx, python 3.8.2
[TaiGLSL] version 0.0.11
Traceback (most recent call last):
File "demo-test.py", line 2, in <module>
from taichi_glsl import *
File "/Users/puffy/Library/Python/3.8/lib/python/site-packages/taichi_glsl/__init__.py", line 10, in <module>
from .hack import *
File "/Users/puffy/Library/Python/3.8/lib/python/site-packages/taichi_glsl/hack.py", line 37, in <module>
@ti.pyfunc
File "/Users/puffy/Library/Python/3.8/lib/python/site-packages/taichi/__init__.py", line 56, in __getattr__
raise AttributeError(f"module '{__name__}' has no attribute '{attr}'")
AttributeError: module 'taichi' has no attribute 'pyfunc'
As in Scientific Visualization, 1D and 3D textures are often used, we need 1D and 3D linear interpolations. Thanks!
Great library, thanks for sharing!
I would be very interested to use it but unfortunately it no longer works with latest Taichi due to several breaking changes
Is there any interest in bringing the library up to date? I don't know enough Taichi yet myself to help so much.
In hack.py, the statement _old_element_wise_binary = ti.Matrix._element_wise_binary
generates directly an AttributeError.
steps to reproduce (python3.11) :
in a file example.py:
2) import taichi_glsl as ts
this statement will do from .hack import *
that generates the error:
AttributeError: type object 'Matrix' has no attribute '_element_wise_binary'
Recently I see this on freshly installed instances:
[Taichi] mode=release
[Taichi] preparing sandbox at /tmp/taichi-utbwh7jc
[Taichi] version 0.7.16, llvm 10.0.0, commit bca037cf, linux, python 3.8.5
[TaiGLSL] version 0.0.10
Traceback (most recent call last):
File "branch.py", line 61, in <module>
import taichi_glsl as ts
File "/usr/local/lib/python3.8/dist-packages/taichi_glsl/__init__.py", line 24, in <module>
from .classes import *
File "/usr/local/lib/python3.8/dist-packages/taichi_glsl/classes.py", line 5, in <module>
class Complex(tl.TaichiClass, ti.TaichiOperations):
AttributeError: module 'taichi' has no attribute 'TaichiOperations'
Changing ti.TaichiOperations
to ti.lang.common_ops.TaichiOperations
in the Complex definition of taichi_glsl/classes.py seems to fix things.
[E 08/18/20 00:35:32.302] [codegen_llvm.cpp:visit@301] Assertion failure: from != to
* Taichi Core - Stack Traceback *
==========================================================================================
| Module | Offset | Function |
|----------------------------------------------------------------------------------------|
taichi_core.so | 110 | taichi::Logger::error(std::__1::basic_string< |
| char, std::__1::char_traits<char>, std::__1:: |
| allocator<char> > const&, bool) |
taichi_core.so | 3378 | taichi::lang::CodeGenLLVM::visit(taichi::lang |
| ::UnaryOpStmt*) |
taichi_core.so | 43 | taichi::lang::CodeGenLLVM::visit(taichi::lang |
| ::Block*) |
taichi_core.so | 786 | taichi::lang::CodeGenLLVMCPU::create_offload_ |
| range_for(taichi::lang::OffloadedStmt*) |
taichi_core.so | 1159 | taichi::lang::CodeGenLLVMCPU::visit(taichi::l |
| ang::OffloadedStmt*) |
taichi_core.so | 43 | taichi::lang::CodeGenLLVM::visit(taichi::lang |
| ::Block*) |
taichi_core.so | 103 | taichi::lang::CodeGenLLVM::emit_to_module() |
taichi_core.so | 25 | taichi::lang::CodeGenLLVM::gen() |
taichi_core.so | 123 | taichi::lang::CodeGenCPU::codegen() |
taichi_core.so | 97 | taichi::lang::KernelCodeGen::compile() |
taichi_core.so | 251 | taichi::lang::Program::compile(taichi::lang:: |
| Kernel&) |
taichi_core.so | 62 | taichi::lang::Kernel::compile() |
taichi_core.so | 136 | taichi::lang::Kernel::operator()() |
taichi_core.so | 103 | void pybind11::cpp_function::initialize<taich |
| i::export_lang(pybind11::module&)::$_9, void, |
| taichi::lang::Kernel*, pybind11::name, pybin |
| d11::is_method, pybind11::sibling>(taichi::ex |
| port_lang(pybind11::module&)::$_9&&, void (*) |
| (taichi::lang::Kernel*), pybind11::name const |
| &, pybind11::is_method const&, pybind11::sibl |
| ing const&)::'lambda'(pybind11::detail::funct |
| ion_call&)::__invoke(pybind11::detail::functi |
| on_call&) |
taichi_core.so | 4075 | pybind11::cpp_function::dispatcher(_object*, |
| _object*, _object*) |
python | 483 | (null) |
python | 111 | (null) |
python | 130 | (null) |
python | 130 | (null) |
python | 370 | (null) |
python | 179 | (null) |
python | 453 | (null) |
python | 46111 | (null) |
python | 414 | (null) |
python | 231 | (null) |
python | 46668 | (null) |
python | 414 | (null) |
python | 231 | (null) |
python | 189 | (null) |
python | 130 | (null) |
python | 46668 | (null) |
python | 414 | (null) |
python | 195 | (null) |
python | 183 | (null) |
python | 46111 | (null) |
python | 414 | (null) |
python | 256 | (null) |
python | 391 | (null) |
python | 9635 | (null) |
python | 125 | (null) |
libdyld.dylib | 1 | (null) |
??? | 2 | (null) |
==========================================================================================
Internal Error occurred, check this page for possible solutions:
https://taichi.readthedocs.io/en/stable/install.html#troubleshooting
Traceback (most recent call last):
File "/Users/limber/Documents/code/taichi_glsl/examples/sdf_rt1.py", line 85, in
render()
File "/Users/limber/anaconda3/lib/python3.7/site-packages/taichi/lang/kernel.py", line 578, in wrapped
return primal(*args, **kwargs)
File "/Users/limber/anaconda3/lib/python3.7/site-packages/taichi/lang/kernel.py", line 506, in call
return self.compiled_functionskey
File "/Users/limber/anaconda3/lib/python3.7/site-packages/taichi/lang/kernel.py", line 466, in func__
t_kernel()
RuntimeError: [codegen_llvm.cpp:visit@301] Assertion failure: from != to
Process finished with exit code 1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.