Forum

Compute Shader: Porting from Unity / Meshing a volume

I’m trying to port the Superformula3D implementation by ondeowl, which is mainly based on this Compute Shader: https://github.com/ondeowl/SuperFormula3D-Unity/blob/master/Assets/SuperFormula3D_GPU/SuperFormula3D.cginc

It’s not only calculating the Superformula but also meshing the created shape. I have a basic understanding of Compute Shaders both in vvvv and unity, but still have a hard time porting shaders with multiple threads inside one compute shader from Unity. I attached my first attempt, which is obviously far from working properly cause I only partly know what I’m doing here. I would be really glad if someone could have a look and help me get this right.

I especially would like to understand how to pass the Buffer from thread to thread and how to mesh the resulting point list.

PortingSuperformula3d.7z (5.5 KB)

i think that isn’t so easy in beta since the buffer is connected to the renderer. in any case, each compute shader in your example is a separate shader in beta (or gamma). and you would connect all of them to one renderer with a group and enable/disable them depending on when they should operate on the target buffer that is held in the Renderer (Buffer).

this is much easier in gamma because buffer (data) and shader (functionality) are separate and you can combine them in any way you want, see the GPU particles example in the help browser.

Thanks for your answer Tebjan! Now I understand what the problem with beta here is for the first time. I’m still thinking about if it’s possible in this particular case to pack the three shaders into one shader in vvvv. Which means doing the operation, normals and solving tangents all inside one compute shader.

I’ll definitely check out the GPU particles example in gamma. Still I’m somewhat afraid to do make the jump to gamma with all the gpu related stuff before fuse is around. But I’ll definitely give it a try today!

Bear in mind that the compute shaders probably don’t use different setups for thread groups just for fun, especially as one is two dimensional even.

yes, you will need 3 draw calls, you cant put that into one shader.

You’re probably right. I initially wondered though, why the ComputeFaceNormals shader is two dimensional at all because only the x dimension of the id is used, but I’m probably overseeing something here.

Thanks for your help and clarifying that three draw calls are needed :)