Fragment Shaders in Roblox!

so, just last night i found out about the new “EditableImage” class, its pretty cool.
naturally, i had to make a CPU fragment shader system.


how does this work?

the system is a simple 3 part mixture, a dispatcher, draw threads, and the shader itself of course.

the dispatcher chops up the image into squares (fragments), and sends the top left and bottom right corners of each square to the draw threads, which get put into their queues for later processing.

next, the parallel phase: running as many times as possible without exhausting the execution time limit i set (or until it runs out of work to do) the thread pops a task off of the queue and executes the shader for each pixel in the fragment, building an array of floats (r,g,b,a) as it goes along. which then gets queued for drawing.

the following serial phase works on the same basic principle as the parallel phase, popping elements off its queue and using WritePixels to send the final output.


thoughts?

any ideas as to what shaders i should try next?
currently, other than the mandelbrot zoom, i have also done a perlin noise scroll, which looks pretty interesting too.

9 Likes

These fragment shaders look good! Nice job on them!

2 Likes

Can you maybe make this open source?

1 Like

nice job dude have a like definatly!!! but how did you get the data from the image? or did you convert it to pure data outside of roblox?

everything here is just pure code! i used a pretty standard algorithm for generating the mandelbrot, i just grabbed an algorithm for it off of stack overflow and then slapped some zoom code and some colourization code onto it. it is all being generated live on the fly in roblox.

1 Like

Sure can, have fun!
Please do share anything you make with it!
Do note that it only works in studio for now, i guess it’s still considered an experimental feature