; ID: 2014 ; Author: bingman ; Date: 2007-05-16 00:45:23 ; Title: Batch Height to Normal Converter ; Description: Batch Converter for making Normal Maps AppTitle "BATCH HEIGHTMAP TO NORMAL MAP CODE" Graphics 800,600,32,0 ;IMPORTANT! ;1. Files should be 8 bit greyscale .bmps ;1. The images you want To convert must be in a folder called 'BMP' which is subfolder of where you run the program. ;2. A Second folder named 'Normals' must be in the 'Bmp' folder. Global Dir$ = CurrentDir$()+"Bmp\" Print Dir$ Global DirSave$ = Dir$ + "\Normals" MyDir = ReadDir(Dir$) Repeat Map$ = NextFile$(MyDir) If Map$ = "" Then Exit If FileType(Dir$+"\"+Map$) = 2 Then Goto NoFile Gosub MAKEMAP .NoFile Forever CloseDir MyDir End .MAKEMAP Global MapLength = (Len(Map$) -4) Global Map2$ = LSet$(Map$,MapLength) Global heightmap = LoadImage(Map$) Global img_w = ImageWidth(heightmap)-1 Global img_h = ImageHeight(heightmap)-1 Global lightmap = CreateImage(img_w+1,img_h+1) LockBuffer ImageBuffer(heightmap) LockBuffer ImageBuffer(lightmap) For y = 0 To img_h If y>0 : ym1=y-1 : Else : ym1=0 : EndIf If y0 : xm1=x-1 : Else : xm1=0 : EndIf If x