GPU marching cubes example

Hi All!
I ported a GPU marching cubes example to OF from, and added in parametric surface calculation on the GPU. The code is here… (for XCode 4)


1 Like

Very cool stuff. It’d take me a week to wade through those geometry shaders and understand everything in there, so it’s nice to have something running that I can check through and toy with to help me get it a little better. I found the strange bug too :slight_smile:

You might want to comment out the ofxMaxim inclusion in the project that you uploaded.

Great! this code was one of my dreams in OF! i know that code…i have run the original windows version time ago.i will try to use it in linux and windows OF. It is interesting because use a geometry shader to build the marching cube. Sure it will help us to undertand beter many things.
Many tanks!

hi, @luma I was able to use your example in Ubuntu 11.04. However, I had to make changes to your code:

  1. I had to rename the file mctables.cpp to mctables.h
  2. resulting in marchingCubesGPU.cpp # include “mctables.cpp” to # include “mctables.h”
    Other than that it works perfectly!

this is crazy! works perfectly for me right out of the box. is it possible to download the geometry back to the cpu after it is generated on the gpu?

I think you might be able to do this with transform feedback (see, but I’ve never tried this so I’m not sure how it works.

just tried the code on a macbook pro with a NVIDIA GeForce 320M and looks like the shaders do not behave correctly: it only renders fragments of the sphere and I’m getting this error:

Validation error: Validation Failed: Sampler error:  
  Samplers of different types use the same texture image unit.  
   - or -  
  A sampler's texture unit is out of range (greater than max allowed or negative).  

I have some free time, I’ll try to look deeper into the problem

Hi @naus3a,
i think the error message may be misleading for helping to find the fault - I get that error as well on my machine as well (330M) even though the code works on it - I think it may be that the validation check gets called too early.

ok, thanks: then I’ll simply poke my fingers around until I find what is not displayed correctly :slight_smile:

Could you please explain what this function does for (3 == curData)

void marchingCubesGPU::prepareToDraw()

Thanks for your work.