【作业2】用太极实现墨戏水墨引擎

作业1

作业描述

我根据墨戏的论文实现了效果类似的水墨效果。

效果展示

代码链接

Code

10 Likes

【更新】

支持了稀疏计算
优化了混色方式,看起来更自然
优化了一些kernel
调整了一些参数

【效果展示】

【问题】

不知道为什么无法使用Ggui,代码如下:

from Taichi_Moxi import *
import random

res=512
moxi=Taichi_Moxi(res,gravity=True)

window=ti.ui.Window("taichi_moxi",(res,res))
canvas=window.get_canvas()
moxi.setCurrentColor(0.1, 0.3, 0.25,0.5)
moxi.setPigmentFlowRate(4)
moxi.brushRadius=0.03
moxi.set_edge_parameters(-0.1,0.4,0.9)
while window.running:
    event=window.get_event()
    if(window.is_pressed(ti.ui.RMB)):
        moxi.setCurrentColor(random.random(),random.random(),random.random(),random.random())
        
    if(window.is_pressed(ti.ui.LMB)):
        moxi.setCursor(window.get_cursor_pos()[0],window.get_cursor_pos()[1])
        moxi.drawStrok()
    moxi.update()
    moxi.render()
    canvas.set_image(moxi.FrameBuffer)
    
    window.show()

会弹出gui窗口然后报错:

[Taichi] version 0.8.3, llvm 10.0.0, commit 021af5d2, win, python 3.9.6
[TaiGLSL] version 0.0.11
[Taichi] Starting on arch=cuda
Assertion failed: allocator && allocation && pAllocationInfo, file D:\a\taichi\taichi\external\VulkanMemoryAllocator\include\vk_mem_alloc.h, 
line 17085
[E 10/19/21 23:44:39.376 9940] Received signal 22 (SIGABRT)


***********************************
* Taichi Compiler Stack Traceback *
***********************************
0x7ff805d9f81a: taichi::print_traceback in taichi_core.pyd
0x7ff805c6ee79: PyInit_taichi_core in taichi_core.pyd
0x7ff805d899c8: PyInit_taichi_core in taichi_core.pyd
0x7ff8ab8a1881: raise in ucrtbase.dll
0x7ff8ab8a2851: abort in ucrtbase.dll
0x7ff8ab8a426e: get_wpgmptr in ucrtbase.dll
0x7ff8ab8a4165: get_wpgmptr in ucrtbase.dll
0x7ff8ab8a44f1: wassert in ucrtbase.dll
0x7ff805ff2281: taichi::print_traceback in taichi_core.pyd
0x7ff805fc8908: taichi::print_traceback in taichi_core.pyd
0x7ff805eb1a8c: taichi::print_traceback in taichi_core.pyd
0x7ff805eb1646: taichi::print_traceback in taichi_core.pyd
0x7ff805eb379f: taichi::print_traceback in taichi_core.pyd
0x7ff805eb4b55: taichi::print_traceback in taichi_core.pyd
0x7ff805b500d4: PyInit_taichi_core in taichi_core.pyd
0x7ff805b3bb25: PyInit_taichi_core in taichi_core.pyd
0x7ff805b2cd46: PyInit_taichi_core in taichi_core.pyd
0x7ff805b26ccb: pybind11::error_already_set::discard_as_unraisable in taichi_core.pyd
0x7ff8335387d2: PyArg_ParseTuple_SizeT in python39.dll
0x7ff833594cbc: PyObject_MakeTpCall in python39.dll
0x7ff83366a32d: Py_gitversion in python39.dll
0x7ff8335f95ec: Py_DecodeUTF8Ex in python39.dll
0x7ff833700fa3: PyEval_ThreadsInitialized in python39.dll
0x7ff833701f12: Py_FatalError_TstateNULL in python39.dll
0x7ff83366dd41: Py_gitversion in python39.dll
0x7ff83353f984: PyFunction_Vectorcall in python39.dll
0x7ff8335f95ec: Py_DecodeUTF8Ex in python39.dll
0x7ff833700fa3: PyEval_ThreadsInitialized in python39.dll
0x7ff833701f12: Py_FatalError_TstateNULL in python39.dll
0x7ff83366e1ee: Py_gitversion in python39.dll
0x7ff83353e0a3: PyObject_GC_Del in python39.dll
0x7ff8335968fd: PyEval_EvalCodeWithName in python39.dll
0x7ff83358e9d3: PyEval_EvalCodeEx in python39.dll
0x7ff83358e931: PyEval_EvalCode in python39.dll
0x7ff83358e7b2: PyMemoryView_FromObject in python39.dll
0x7ff83358e6bb: PyMemoryView_FromObject in python39.dll
0x7ff83357c97b: PyObject_GetBuffer in python39.dll
0x7ff8335f95ec: Py_DecodeUTF8Ex in python39.dll
0x7ff833700fa3: PyEval_ThreadsInitialized in python39.dll
0x7ff833701fca: Py_FatalError_TstateNULL in python39.dll
0x7ff83366e87f: Py_gitversion in python39.dll
0x7ff83353e0a3: PyObject_GC_Del in python39.dll
0x7ff83353fa67: PyFunction_Vectorcall in python39.dll
0x7ff8335f95ec: Py_DecodeUTF8Ex in python39.dll
0x7ff833700fa3: PyEval_ThreadsInitialized in python39.dll
0x7ff833701f12: Py_FatalError_TstateNULL in python39.dll
0x7ff83366e87f: Py_gitversion in python39.dll
0x7ff83353e0a3: PyObject_GC_Del in python39.dll
0x7ff83353fa67: PyFunction_Vectorcall in python39.dll
0x7ff8335f95ec: Py_DecodeUTF8Ex in python39.dll
0x7ff833700fa3: PyEval_ThreadsInitialized in python39.dll
0x7ff833701f12: Py_FatalError_TstateNULL in python39.dll
0x7ff83366ef8a: Py_gitversion in python39.dll
0x7ff83353e0a3: PyObject_GC_Del in python39.dll
0x7ff83353fa67: PyFunction_Vectorcall in python39.dll
0x7ff8335f95ec: Py_DecodeUTF8Ex in python39.dll
0x7ff833700fa3: PyEval_ThreadsInitialized in python39.dll
0x7ff833701f12: Py_FatalError_TstateNULL in python39.dll
0x7ff83366ef8a: Py_gitversion in python39.dll
0x7ff833542fa2: PyEval_EvalFrameDefault in python39.dll
0x7ff83353f984: PyFunction_Vectorcall in python39.dll
0x7ff833542883: PyEval_EvalFrameDefault in python39.dll
0x7ff83353e0a3: PyObject_GC_Del in python39.dll
0x7ff8335968fd: PyEval_EvalCodeWithName in python39.dll
0x7ff83358e9d3: PyEval_EvalCodeEx in python39.dll
0x7ff83358e931: PyEval_EvalCode in python39.dll
0x7ff83358e7b2: PyMemoryView_FromObject in python39.dll
0x7ff83358e6bb: PyMemoryView_FromObject in python39.dll
0x7ff833541e1f: PyEval_EvalFrameDefault in python39.dll
0x7ff83353e0a3: PyObject_GC_Del in python39.dll
0x7ff833544904: PyEval_EvalFrameDefault in python39.dll
0x7ff83353e0a3: PyObject_GC_Del in python39.dll
0x7ff83353fa67: PyFunction_Vectorcall in python39.dll
0x7ff8335207dc: PyVectorcall_Call in python39.dll
0x7ff8335205d7: PyObject_Call in python39.dll
0x7ff8335dea52: Py_MakePendingCalls in python39.dll
0x7ff8335a22c6: Py_RunMain in python39.dll
0x7ff8335a21d1: Py_RunMain in python39.dll
0x7ff83359e3f1: Py_Main in python39.dll
0x7ff7c85e1254: Unknown Function in python.exe
0x7ff8ada97034: BaseThreadInitThunk in KERNEL32.DLL
0x7ff8ade62651: RtlUserThreadStart in ntdll.dll

Internal error occurred. Check out this page for possible solutions:
https://docs.taichi.graphics/lang/articles/misc/install

之前也有人反应过类似的问题,好像是把初始内存调小,但我试了不行。

1 Like

除了刚开始显存调小,初始化的时候,设置成pack mode试试?
ti.init(arch=ti.gpu, packed=True)

1 Like

还是不行,我在任务管理器看显存调用不是很多。而且我的D盘没有这个路径和文件:

D:\a\taichi\taichi\external\VulkanMemoryAllocator\include\vk_mem_alloc.h

之前看到别人也是这个文件出错

报错信息中的路径是打包环境的,这个是使用的第三方的内存分配器。

另一个问题中出现的错误在PR中已经修复了,下一个版本应该就好了。

我没有复现出你的错误,在我这里GGUI可以运行 :joy:

2 Likes

这个问题会在新的版本(0.8.4)中解决:https://github.com/taichi-dev/taichi/pull/3222

1 Like