How could I draw an Outlined Mesh like this?

415 Views Asked by At

So I saw a blog about parsing OBJ files, but what really caught my eye was the object they were parsing (this question isn't about parsing OBJ files).

enter image description here

I know the mesh was created using a 3D noise algorithm, probably simplex noise, but what I want to know is how I could make a similar line effect to that in LWJGL.

I already have a 3D simplex noise algorithm, and some code that I thought would work but really doesn't do quite the same thing.

The pattern I notice about the mesh is there are rows of lines that start on the outside where the noise density is highest. Those lines then evolve based on the noise density in specific spots, so what I tried to do was make an algorithm to produce those lines and evolve them as well, but that didn't quite so work.

SimplexNoise noise = new SimplexNoise(23453) //Variable is the seed
worldList = glGenLists(1);
glNewList(worldList, GL_COMPILE); //Inefficient but gets the job done
    float prevx = 0.0f;
    float prevy = 0.0f;
    float prevz = 0.0f;
    for(int x=0;x<256;x++){
        for(int y=0;y<256;y++){
            for(int z=0;z<256;z++){
                float xf = x/100;
                float yf = y/100;
                float zf = z/100;
                density = noise.simplex(3,xf,yf,zf); //octaves,x,y,z
                if(density>3){ //filter out some results
                    drawLine(prevx,prevy,prevz,x+1,y*density,z*density);
                    drawLine(prevx,prevy,prevz,x*density,y+1,z*density);
                    drawLine(prevx,prevy,prevz,x*density,y*density,z+1);
                }
            }
        }
    }
glEndList();

It shouldn't be hard to realize that this doesn't produce anything near the same results. I do not know how to approach or exactly produce the same mesh shape or something similar, so can anyone help me?

1

There are 1 best solutions below

0
On

I'm not familiar with LWJGL, but I think I may be able to point you in the right direction as far as the algorithm itself goes. You can plug Perlin/Simplex noise into a marching cubes algorithm and generate a triangle mesh from it. I used this technique to create this mesh:

Perlin Noise and Marching Cubes

I believe you may be able to get the result you want by drawing the wireframe of the outputted mesh. After all, if you look closely, all of those lines make triangles. You can find more info about marching cubes here.