With the new image editing API, I saw the opportunity to make a “pseudo-shader” module where devs could create/play shader-like images based on some “draw” function provided by them that returns pixel data.
The first implementation was real-time, and it was very laggy… not because of the image API itself, but instead because of the draw function being called and doing work many, many times per frame depending on the resolution (and of course without the benefits of running on the GPU vs CPU). So, I set up a system where instead of being real-time, frames would be pre-rendered and stored for playback. It worked great!
video
Though… you can still see the game chugs while rendering, even at 64x64 resolution. Today while looking for ways to speed up this process, I came across the “Parallel Luau” page in the creator docs. I tried implementing it and got everything set up, but there was one problem: I can’t find a way for the parallel scripts to obtain and use the draw function from the module script.
SharedTable
is out of the question since functions are forbidden values; BindableFunction
isn’t usable in parallel; an intermediate module to hold functions doesn’t seem to update for the parallel scripts; and loadstring
isn’t available for LocalScript
.
Do I have any other options or workarounds? Or should I just revert to the previous version of the module without any threading?
Also, I’m not too experienced with Luau and asynchronous code; I do apologize if there’s any oversight here.