Original Post
Hey all im trying to downsample the resolution of chunks of my height map for a LOD algorithm im writing but it seam to be showing up with some artifacts that i cant get rid of Here the input heightmap 513x513
Here the output heightmap 257x257
and here the code im using to downsample it <code> void FilterHeightmap(char *hmap,short dim) { //this function filters down a given height map to half its size short newdim = (dim/2)+1; char *newhmap; int i,j,i2,j2; //create a new temp hmap half the size newhmap = new char[newdim*newdim]; int count; SaveRaw(hmap,"input.raw",dim); for(i=0;i<newdim;i++) for(j=0;j<newdim;j++) { i2=i*2; j2=j*2; count = hmap[(j2*dim)+i2]+ hmap[(j2*dim)+i2+1]+ hmap[((j2+1)*dim)+i2]+ hmap[((j2+1)*dim)+i2+1]; count = count/4; newhmap[(j*newdim)+i] = (char)(count); } //test save output SaveRaw(newhmap,"output.raw",newdim); } </code>
Here the output heightmap 257x257
and here the code im using to downsample it <code> void FilterHeightmap(char *hmap,short dim) { //this function filters down a given height map to half its size short newdim = (dim/2)+1; char *newhmap; int i,j,i2,j2; //create a new temp hmap half the size newhmap = new char[newdim*newdim]; int count; SaveRaw(hmap,"input.raw",dim); for(i=0;i<newdim;i++) for(j=0;j<newdim;j++) { i2=i*2; j2=j*2; count = hmap[(j2*dim)+i2]+ hmap[(j2*dim)+i2+1]+ hmap[((j2+1)*dim)+i2]+ hmap[((j2+1)*dim)+i2+1]; count = count/4; newhmap[(j*newdim)+i] = (char)(count); } //test save output SaveRaw(newhmap,"output.raw",newdim); } </code>
