Jump to content
  • Advertisement

Matt Aufderheide

Member
  • Content count

    881
  • Joined

  • Last visited

Community Reputation

129 Neutral

About Matt Aufderheide

  • Rank
    Advanced Member
  1. Matt Aufderheide

    Trouble with marching cubes

    ok I got it working :) should have been like this: vec_set(CELL.p[0],vector(x,y,z)); vec_set(CELL.p[1],vector(x+1,y,z)); vec_set(CELL.p[2],vector(x+1,y,z+1)); vec_set(CELL.p[3],vector(x,y,z+1)); vec_set(CELL.p[4],vector(x,y+1,z)); vec_set(CELL.p[5],vector(x+1,y+1,z)); vec_set(CELL.p[6],vector(x+1,y+1,z+1)); vec_set(CELL.p[7],vector(x,y+1,z+1)); CELL.val[0]=voxel[x][y][z]; CELL.val[1]=voxel[x+1][y][z]; CELL.val[2]=voxel[x+1][y][z+1]; CELL.val[3]=voxel[x][y][z+1]; CELL.val[4]=voxel[x][y+1][z]; CELL.val[5]=voxel[x+1][y+1][z]; CELL.val[6]=voxel[x+1][y+1][z+1]; CELL.val[7]=voxel[x][y+1][z+1];
  2. Matt Aufderheide

    Trouble with marching cubes

    Changed some things , works better now but still not right...this is what I have now : GRIDCELL CELL; TRIANGLE TRI[5]; vec_set(CELL.p[0],vector(x,y,z)); vec_set(CELL.p[1],vector(x+1,y,z)); vec_set(CELL.p[2],vector(x,y+1,z)); vec_set(CELL.p[3],vector(x+1,y+1,z)); vec_set(CELL.p[4],vector(x,y,z+1)); vec_set(CELL.p[5],vector(x+1,y,z+1)); vec_set(CELL.p[6],vector(x,y+1,z+1)); vec_set(CELL.p[7],vector(x+1,y+1,z+1)); CELL.val[0]=voxel[x][y][z]; CELL.val[1]=voxel[x+1][y][z]; CELL.val[2]=voxel[x][y+1][z]; CELL.val[3]=voxel[x+1][y+1][z]; CELL.val[4]=voxel[x][y][z+1]; CELL.val[5]=voxel[x+1][y][z+1]; CELL.val[6]=voxel[x][y+1][z+1]; CELL.val[7]=voxel[x+1][y+1][z+1]; int i=0; int p=0; int q=0; p=Polygonise(CELL,0.5,TRI);
  3. Trying to implement simple marching cubes using Paul Bourke's code example (http://paulbourke.net/geometry/polygonise/)   I first set up a test voxel field like so: void setup_voxels() {  int x=0;  int y=0;  int z=0;    for(x=0;x<voxel_num;x++)  {   for(y=0;y<voxel_num;y++)   {    for(z=0;z<voxel_num;z++)    {     if (z<4)     {      voxel[x][y][z]=1;     }          else     {      voxel[x][y][z]=0;     }    }    }  }   This would be a 16*16*16 cube, with only the the first four levels  actually set as "on" . I then loop through each cell and try to set up the grid cells and call the polygonise function   for(x=0;x<voxel_num;x++)  {   for(y=0;y<voxel_num;y++)   {    for(z=0;z<voxel_num;z++)    {      GRIDCELL CELL;      TRIANGLE TRI[5];       XYZ tempvec;              tempvec.x=x*16;tempvec.y=y*16;tempvec.z=z*16;        vec_set(CELL.p[0],tempvec);            tempvec.x=x*16+16;tempvec.y=y*16;tempvec.z=z*16;      vec_set(CELL.p[1],tempvec);            tempvec.x=x*16+16;tempvec.y=y*16+16;tempvec.z=z*16;      vec_set(CELL.p[2],tempvec);            tempvec.x=x*16;tempvec.y=y*16+16;tempvec.z=z*16;      vec_set(CELL.p[3],tempvec);            tempvec.x=x*16;tempvec.y=y*16;tempvec.z=z*16+16;      vec_set(CELL.p[4],tempvec);            tempvec.x=x*16+16;tempvec.y=y*16;tempvec.z=z*16+16;      vec_set(CELL.p[5],tempvec);            tempvec.x=x*16+16;tempvec.y=y*16+16;tempvec.z=z*16+16;      vec_set(CELL.p[6],tempvec);            tempvec.x=x*16;tempvec.y=y*16+16;tempvec.z=z*16+16;      vec_set(CELL.p[7],tempvec);      CELL.val[0]=voxel[x][y][z];      CELL.val[1]=voxel[x+1][y][z];      CELL.val[2]=voxel[x+1][y+1][z];      CELL.val[3]=voxel[x][y+1][z];             CELL.val[4]=voxel[x][y][z+1];      CELL.val[5]=voxel[x+1][y][z+1];      CELL.val[6]=voxel[x+1][y+1][z+1];      CELL.val[7]=voxel[x][y+1][z+1];          int i=0;      int p=0;            p= Polygonise(CELL,0.5,TRI);   This is written in something called "lite-c" so it might seem a bit weird. Compiles fine and does return triangles, but they all seem messed up as far as positions and so on. I'm assuming I'm not getting something about the  CELL.val and what the values are actually supposed to be , I just made it one or zero depending on if a voxel cell is filled or not.    I hope this makes at least some sense...maybe I am totally misunderstanding how this method works..?? If anyone has any idea what's going on I'd be happy to get some help.    
  4. Matt Aufderheide

    Rebuilding normals from position

    Works perfectly, thanks so much
  5. Matt Aufderheide

    Rebuilding normals from position

    Works perfectly, thanks so much
  6. HI, I'm trying to reconstruct approximate normals in a pixel shader using only the inputs from the vertex shader...This is because the mesh I am rendering doesn't have proper normals, and it's too costly to recomputed them  any time I deform it in the application. Don't want to use a normal map because the mesh is too big (its a terrain).   I know you can render a depth texture out and reconstruct normal from that, but I wanted to try to do it all at once without rendering depth.. I don't know If this is possible.   I was thinking I could simply pass a few different positions from the VS and do something in the pixel shader.. but not sure what...   The basic result ought to be flat normals in view space or world space...
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!