Found this on my hard drive, but I don't know who wrote it (apologies to whoever did). The filename in the code below is a link to the image... didn't expect that to work!
Graphics3D 640,480,0,2 bump=LoadTexture( "<a href="http://www.hi-toro.com/blitz/images/mynormal.jpg" target="_blank">mynormal.jpg</a>",1+8 ) cube=CreateSphere(16) EntityFX cube,1+2 TextureBlend bump,4 EntityTexture cube,bump,0,0 light = CreateLight(2) lighticon = CreateSphere(8,light) EntityFX lighticon,1 ScaleEntity lighticon,0.1,0.1,0.1 camera=CreateCamera() CameraClsColor camera,128,128,128 PositionEntity camera,0,0,-4.0 a# = 180.0 While Not KeyHit(1) a = a + 1 If a = 360.0 Then a = 0 PositionEntity light,Cos(a)*4,Sin(a*2)*1,Sin(a)*4 If KeyDown(200) TurnEntity cube, 1,0,0 If KeyDown(208) TurnEntity cube,-1,0,0 If KeyDown(205) TurnEntity cube,0,-1,0 If KeyDown(203) TurnEntity cube,0, 1,0 If KeyDown(30) TranslateEntity camera,0,0,0.01 If KeyDown(44) TranslateEntity camera,0,0,-0.01 UpdateBumpNormals(cube,light) UpdateWorld RenderWorld Flip Wend Function UpdateBumpNormals(mesh,light) n_surf = CountSurfaces(mesh) For s = 1 To n_surf surf = GetSurface(mesh,s) n_vert = CountVertices(surf)-1 For v = 0 To n_vert TFormNormal VertexNX(surf,v),VertexNY(surf,v),VertexNZ(surf,v),mesh,0 nx# = TFormedX() ny# = TFormedY() nz# = TFormedZ() TFormPoint VertexX(surf,v),VertexY(surf,v),VertexZ(surf,v),mesh,0 red# = EntityX(light,True)-TFormedX() grn# = EntityY(light,True)-TFormedY() blu# = EntityZ(light,True)-TFormedZ() d# = Sqr(red*red + grn*grn + blu*blu) red = (red/d) grn = (grn/d) blu = (blu/d) dot# = red*nx + grn*ny + blu*nz If dot>0.0 red = (1.0+(red*dot))*127.5 grn = (1.0+(grn*dot))*127.5 blu = (1.0+(blu*dot))*127.5 VertexColor surf,v,red,grn,blu Else VertexColor surf,v,127.5,127.5,127.5 End If Next Next End Function End