Hi everyone ![]()
I’m trying generating a procedural terrain using marching cubes and thanks to scrawk 'till know everything is going well.
Now my doubt is, can I use Compute Shaders to run the marching cubes algorithm (to calculate the model vertices) ? for obvious reasons… x)
Basically I want to be able to compute non-graphics code, just like OpenCL. Is it possible to do with Compute Shaders in Unity, and can someone point me to a good tutorial to start with? I don’t think I’ll need in-depth experience as it is as simple as run through an array and perform some bitwise operations and compare some values…
I think you can, but I haven’t done much with Compute Shaders yet. The basics are here:
http://docs.unity3d.com/Documentation/Manual/ComputeShaders.html
You’d write the compute shader as a .compute file, and then in your terrain script, set up a ComputeBuffer with your voxels, pass it to the shader with ComputeShader.Dispatch, and read back the new ComputeBuffer with the vertices.
Thank you ![]()
I already saw the documentation in unity website, but my main problem now is about datatypes, what kind of data types can I use, 'cause I tried with vector3[ ] and it didn’t work heheheheh and general syntax, 'cause I never tried to write a shader.
But you already gave me a good hint.
Thank you very much ![]()