Hi to all.
I desperately need help with this piece of (s***) code. I am struggling with the transfer of the blocky voxel engine completely to the GPU, more closely to the Compute Shader.
To accomplish this, I used a great series of tutorials from b3agz : Code a game like Minecraft in Unity and examples of using the new mesh API from Keijiro: https://github.com/keijiro/ComputeMarchingCubes.
To the point. Compute Shader composes the mesh for entire 8x8x8 chunk of voxels using predefined arrays. After many adventures with appropriate adressing of RWByteAddressBuffers, I got stuck witch such results:
For some reason the chunk is not displayed completely which is strange because each thread reports activity by storing its own id into the buffer. Similar buffers are for vertices and indices.
I’m begging for help. Every day I work for a long time and I don’t have little time for this passion of programming and now it has stopped me. Here is the source code in three files:
Sorry. I don’t know how to post code. Best regards to the Unity team. I am your fan
1 Like
I didn’t look that much into your code. Just an observation, but most of DrawMesh is redundant per-frame. If things don’t change somehow, running them once in Start/AllocateXXXX is enough. Keijiro’s code has a change condition in Update and only does the stuff below if sth has actually changed, other than that, shader.Sets being run per frame etc.
As for debugging your issue, RenderDoc is your friend! Use it to debug the CS calculations and memory. No need for debug buffers if you can see their values on the fly. You can choose a specific workload and run through the CS kernels line by line looking at registers and stuff. Also Mesh Viewer can give you a visual for your generated mesh resource.
One tip. Since debugging CS usually involves an iterative process where you capture new frames every time you change sth in the code, the Search Event by String will help a lot with locating your dispatches. You can search for “Dispatch” or even better something else that’s unique to your dispatch events (e.g. a parent name) so you don’t waste time every capture, navigating towards the dispatch you want to debug.
Thank you sir for response. I finally found bug in “mesh.SetSubMesh()”. Must learn how to use RenderDoc.
Live long and prosper.
1 Like