2
\$\begingroup\$

I'm following the GPU Gems 3 chapter 1 (Generating Complex Procedural Terrains Using the GPU). The main difference is that I'm using the CPU for generating the mesh(es) based off of marching cubes. And I have this problem that I'm not sure how to solve or even debug.

In Figure 1-8, they start adding noise to the plane at y=0:

density += noiseVol.Sample(TrilinearRepeat, ws).x;

I tried to do the same thing, but I got a plane with island-like holes in it:

Plane with holes

Here is my density function:

float densityFunction(Vector3 ws) {
    float density = -ws.y;
    density += noise[(int)ws.x, (int)ws.y, (int)ws.z];
    return density;
}

noise is a 3-dimensional float array of pink (Perlin) noise whose mean is 0. It has a frequency of 2 and 3 octaves with half persistence. Its standard deviation is ~ 0.2. And it varies around ±0.65.

The isolevel of the marching cubes algorithm is set to 0.

What could be causing this undesired effect?

\$\endgroup\$
3
\$\begingroup\$

What I think is happening is that you are creating a marching cube for an area from [0,0,0] to [10,10,10] and the empty spots are the result of the plane being distorted away.

The density calculation seems to be simply moving up or down the points of the plane, this is causing some points to be below 0 and others above 0 (roughly 50/50). Your marching cubes is then sampling points at y=0 and finding that it should not put a triangle at this position.

Try putting your plane higher, this should work properly and is an easy enough change for a test. If that works then you need to make the marching cube area larger so it encompasses the entire distorted plane.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.