Main sections
LOADBUMPTEXTURE
LOADBUMPTEXTURE datei$, num%
Loads a greyscale bitmap as a heightmap (white is a high point on the heightmap, black is a low point) and creates a normal map of it. The heightmap is required for dot3 bump mapping.
The loaded normals-texture can be specified as the 2nd parameter of the X_SETTEXTURE3D command.
Sample:
// Bump Mapping Demo
// -----------------
// Image data
LOADSPRITE "image.bmp",0
// Like LOADSPRITE but converts heightmap to normal map
LOADBUMPTEXTURE "bump.bmp", 1
// a simple square
X_OBJSTART 1
X_OBJADDVERTEX -20, -20, 0, 0,1, RGB(255,255,255)
X_OBJADDVERTEX -20, 20, 0, 0,0, RGB(255,255,255)
X_OBJADDVERTEX 20, -20, 0, 1,1, RGB(255,255,255)
X_OBJADDVERTEX 20, 20, 0, 1,0, RGB(255,255,255)
X_OBJEND
// main loop
WHILE TRUE
phi=phi+GETTIMER()/20; IF phi>=360 THEN phi=phi-360
X_MAKE3D 1, 500, 45
X_CAMERA 0, 10, 100, 0,0,0
// Light no -1 is bump light position
X_SPOT_LT -1, 0, 0,0,50, 0,0,0,90
X_SETTEXTURE 0, 1 // 0=Texture, 1=Bump-normal-map
X_ROTATION phi, 0, 1, 0
X_DRAWOBJ 1, 0
SHOWSCREEN
WEND