0
\$\begingroup\$

Hi I'm trying to reproduce GPU Gems 3 chapter 1 (Generating Complex Procedural Terrains Using the GPU) and so far I managed the basics... Now I'm betting some strange output.

I started with the suggested -ws.y to generate a plane. Then when I moved to the noise I noticed some holes in the mesh. But unlike this previous question.

The noise mesh: enter image description here

So I decided to try something more simple, 3 tubes: x^2+y^2-2 Everything seems ok on this one

x^2+z^2-2 Oh boy...

y^2+z^2-2 And finally

I would assume there is some problem with the z axis. But I can seem to figure out what. My function to get the triangles vertex positions also seems ok...

Vector3 vertexAlongEdge(int edge, Voxel v){
    Vector3 result=new Vector3(0,0,0);

    Vector3 p1=v.vertexes[edges [edge, 0]];
    Vector3 p2=v.vertexes[edges [edge, 1]];
    float v1 = density (p1);
    float v2 = density (p2);
    if (Mathf.Abs (isoLevel - v1) < 0.00001)
        return p1;
    if (Mathf.Abs (isoLevel - v2) < 0.00001)
        return p2;
    if (Mathf.Abs (v1 - v2) < 0.00001)
        return p1;

    float m = Mathf.Abs((isoLevel - v1) / (v1 - v2));
    result.x = p1.x + m * (p2.x - p1.x);
    result.y = p1.y + m * (p2.y - p1.y);
    result.z = p1.z + m * (p2.z - p1.z);

    return result;
}

The only thing I can think of right now is an error in my table with the edges for each case. Please help.

\$\endgroup\$
  • \$\begingroup\$ Any chance back-face culling is the issue? Unity expects front-facing tris to have their points in clockwise order. \$\endgroup\$ – rutter Nov 16 '14 at 23:16
  • \$\begingroup\$ if that was the case they would be visible from the outside I suppose. But they are not. \$\endgroup\$ – Leonardo Marques Nov 16 '14 at 23:29
1
\$\begingroup\$

I found the problem. I had a wrong value on the vertex for an edge. My edge table said that for the edge 10 the vertex were 2 and 4 when they should be 2 and 6.

Thank you for your time.

\$\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.