   Help with a raw file/heightmap.
  Hey all.   I downloaded a tutorial from gametutorials.com, on how to do heightmaps with OpenGL. It loads a .raw file. It also has the .bmp texture included. I wanted to make my own .raw file.So as a test, I looked around here, and apparently, you open the BMP, make it greyscale, and save it as a .raw. (in Paintshop pro).Thats what I did, and it didnt work. When I opened it, I got a large flat area, and a bunch of pointy things on the right and left hand sides.I even downloaded a heightmap generator thing. I opened the bmp, it made it greyscale etc.. and then saved it back as a bmp. I then tried saving this as a .raw file with no luck. The image is 512*512 and comes with the heightmap tutorial at gametutorials.com. (it also has the .raw file which loads fine, but when I try to convert it myself and load it, it wont work.)Maybe someone can help me? I'm really keen to make my own .raw files for the heightmap :DThanks,-Chris   
  Try my height map editor;  Let me just put it this way, don't use a raw file. I had this problem myself, probably after doing the same tutorial :p and I think any other format is better.A raw file means the files is just a long array of "plain" numbers. This might be easy to read to a file using a low level API but why bother? In a raw you can't know if it was 10x10 or 25x4. If you use a BMP you can get the image size! You can use a compressed format (such as JPG) and it should not be hard to find an API to let you read pixel values as easily as from a raw file.   ;  I would definitely use the RAW format.  I myself use 16bit RAW files because it gives extra precision when making heightmaps.  Anyway, here's an very easy way to make and load heightmaps.1.  Draw your heightmap in Photoshop2.  Go to menu "Image/Mode/Grayscale"3.  Go to menu "File/Save"4.  Choose "RAW"Now here's how I load my RAW files.void loadRAW(char *filename, int bpp)    { FILE *fp = fopen(filename, "rb"); if(!fp) return; fseek (fp , 0 , SEEK_END); int Size = (int)sqrt(ftell(fp)/(bpp)); rewind(fp); if(bpp == 1)    {    unsigned char *data = new unsigned char[Size*Size];    fread(data, 1, Size*Size, fp);    for(int i=0; i < size; i++)  for(int j=0; j < size; j++)   {  vertices[i*size+j].y =data[(int((i*Size)/float(size)) * Size   + int((j*Size)/float(size)))];  }    delete [] data; } else if(bpp == 2)   {    unsigned short *data = new unsigned short[Size*Size];    fread(data, 2, Size*Size, fp);    for(int i=0; i < size; i++)  for(int j=0; j < size; j++)   {  unsigned short h =data[(int((i*Size)/float(size)) * Size   + int((j*Size)/float(size)))];  vertices[i*(size)+j].y = h * (256.0/(1<<16)*1.0);  }    delete [] data; } else if(bpp == 4)   {    float *data = new float[Size*Size];    fread(data, 4, Size*Size, fp);    for(int i=0; i < size; i++)  for(int j=0; j < size; j++)   {  vertices[i*(size+1)+j].y =data[(int((i*Size)/float(size)) * Size   + int((j*Size)/float(size)))];  }    delete [] data; }  fclose(fp); calcnormals();   }Basically since you are probably making 8bit RAW files, then you should just pass in 1 for the BPP parameter in the function.   ;  what extra precision do you get useing RAW?   ;  I would probably avoid a lossy compression format (such as JPG).  Personally, I use PNG images that I load with SDL_image.  That works great for me.   ;  Another option is to use the Terragen (.TER) file format.It is widely used in many terrain tools and you will easilyfind some source code to read it.Beside of 16 bit accuracy it contains the height scaling.8 bit accuracy is often unsatisfactory due to shading artifacts.;Quote:Original post by OrenGLwhat extra precision do you get useing RAW?With RAW you get about 2 decimal places with the height value.  With any other format including BMP and JPG you only get the values 0-255 'integers' only !!!With 16bit RAW you get 0-65535, which you can then scale down to 0-255, and also retain 2 decimal places accurately.Another option is just to go with 32bit RAW files in which you get all the precision of an actual floating point value.  And you can go way beyond 255.As I said before, FarCry uses 16bit height values, and since FarCry does it, we should ALL do it....because FarCry is GOD...   