yes, i think the basic theory for normal mapping is like this.
tex=LoadTexture ("normalmap.bmp")
TextureBlend tex,4 ;dot3
EntityTexture mesh,tex,0,0
tex2=LoadTexture ("imagemap.bmp")
TextureBlend tex2,5 ;multiply 2
EntityTexture mesh,tex2,0,1
There was a post in general discussion that was called "BumpMapping & Lightmaps?" which seems to have disappeared now, but i saved it to my hd because it had the code below, by Red Ocktober. I found it a bit messy but still a good place to start.
It uses functions by Aurora which can be found here
http://www.blitzbasic.com/codearcs/codearcs.php?code=1148
Graphics3D 1024,768,16,1
AmbientLight 120,120,120
ClearTextureFilters
cam=CreateCamera()
CameraRange cam,1,100000
PositionEntity cam,-36,-23,-20
TurnEntity cam, 0.0,0,0
CameraClsColor cam, 9,20,40
CameraFogMode cam,0
CameraFogColor cam,9,20,40
CameraFogRange cam,0,1800
AntiAlias True
l=CreateLight(2)
LightRange l,888
RotateEntity l,0,0,0
LightColor l,150,25,25
s=CreateCube(l)
;ScaleEntity s,.1,.1,.1
EntityFX s,1:EntityColor s,255,255,255
PositionEntity s,0,0,0
;------------------------------- lightmapped b3d, mine came from Gile[s]
; but a CShop mesh will work just as well
m=LoadMesh ("c:\program files\cshop4\maps\testwall\testwall.b3d")
;RotateEntity m,-90,0,0
PositionEntity m,-2,-3,0
;------------------------------- load the normal mapped texture
tex=LoadTexture ("c:\program files\cshop4\maps\testwall\redbricknormalmap.bmp")
;ScaleTexture tex,.5,.5
TextureBlend tex,4
EntityTexture m,tex,0,0
;------------------------------ reload the original texture don't ask me why...
; if you don't, everything will look greyish
tex2=LoadTexture ("c:\program files\cshop4\maps\testwall\redbrick.bmp")
;ScaleTexture tex2,3.0,3.0
TextureBlend tex2,5
EntityTexture m,tex2,0,2
;------------------------------ ya don't need this, i think i used it with .x files
;tex3=LoadTexture(".\metal.jpg",1+512)
tex3=LoadTexture ("c:\program files\milkshape 3d 1.7.1\projects\default lightmap.bmp",512+1)
;ScaleTexture tex2,2,2
;TextureBlend tex3,5
;EntityTexture m,tex3,0,1 ;not needed with b3d
r#=0
g#=0
b#=50
angle#=155
While Not KeyDown(1)
If KeyDown(30) camturn=camturn+1
If KeyDown(32) camturn=camturn-1
TurnEntity cam,0,camturn,0
camturn=0
If KeyDown(209) MoveEntity cam,0,-1.1,0
If KeyDown(201) MoveEntity cam,0,1.1,0
If KeyDown(31) MoveEntity cam,0,0,-1.1
If KeyDown(17) MoveEntity cam,0,0,1.1
If KeyDown(44) MoveEntity cam,-1.1,0,0
If KeyDown(46) MoveEntity cam,1.1,0,0
If KeyDown(45) yaw=yaw-1 ;RotateEntity cam,0,yaw,0
If KeyDown(44) yaw=yaw+1 ;RotateEntity cam,0,yaw,0
If yaw>359 Then yaw=0
If yaw<0 Then yaw=359
TurnEntity l,1,2,3
;If KeyDown(28) MoveEntity cam,0,0,.005
;If KeyDown(30) TurnEntity m,0,1,0
;If KeyDown(31) TurnEntity m,0,-1,0
If KeyDown(200) b=b+1
If KeyDown(208) b=b-1
If KeyDown(203) c=c+1
If KeyDown(205) c=c-1
If angle>=360 angle=0
PositionEntity l, EntityX(m)+c,EntityY(m)+b,EntityZ(m)
PositionEntity m,-2-zpos#,-43,40+zpos#
entityLight(m,l,10.5,1)
UpdateWorld
RenderWorld
Text 5,5,r+" = red"
Text 5,15,g+" = green"
Text 5,25,b+" = blue"
Text 5,440,"use UP and DOWN arrows to increase/decrease brightness"
Text 5,450,"use A and S to rotate the model"
Text 5,460,"W =wireframe toggle"
Text 5,35, angle + " angle"
;If KeyHit(17) Then w=Not w WireFrame w
Flip
Wend
End
; ------------------ TheDudes NormalMap Functions is what makes it work
;
Function entityLight(entity,light,inten#=0.5,hull=False)
ox#=EntityX(light)
oy#=EntityY(light)
oz#=EntityZ(light)
inten =0.5
;If Not hull inten=1.-inten
tp=CreatePivot()
PositionEntity tp,EntityX(light),EntityY(light),EntityZ(light)
TFormPoint ox,oy,oz,tp,entity
;FreeEntity tp
light=tp
PositionEntity light,TFormedX(),TFormedY(),TFormedZ() ;Transpose light into
dx# =(EntityX(light)-EntityX( entity));*inten
dy# =(EntityY(light)-EntityY( entity));*inten
dz# =(EntityZ(light)-EntityZ( entity));*inten
nl#=Sqr(dx*dx+dy*dy+dz*dz)
nx#=dx/nl
ny#=dy/nl
nz#=dz/nl
nl#=(nl*10.-255.)/255.
nl=1.-nl
If nl>1. nl=1
If nl<0. nl=0
nl=in
nx=nx;*inten
ny=ny;*inten
nz=nz;*inten
;If nx<0 nx
FreeEntity tp
;EntityColor entity,128.+(128.*nx),128.+(128.*nz),128.+(128.*ny)
EntityColor entity,256+(256*nx),256.0+(256*ny),256.0+(256*nt)
;PositionEntity light,ox,oy,oz ;return light.
End Function
Function vectorLight(entity,light,inten#=0.5,hull)
ox#=EntityX(light)
oy#=EntityY(light)
oz#=EntityZ(light)
If Not hull inten=-inten
tp=CreatePivot()
PositionEntity tp,EntityX(light),EntityY(light),EntityZ(light)
TFormPoint ox,oy,oz,tp,entity
light=tp
PositionEntity light,TFormedX(),TFormedY(),TFormedZ() ;Transpose light into
srf=CountSurfaces(Entity)
lx#=EntityX(light)
ly#=EntityY(light)
lz#=EntityZ(light)
cs=CountSurfaces(entity)
For s=1 To cs
srf=GetSurface(entity,s)
For v=0 To CountVertices(srf)-1
TFormPoint VertexX(srf,v),VertexY(srf,v),VertexZ(srf,v),entity,0
vx#=TFormedX()
vy#=TFormedY()
vz#=TFormedZ()
dx# =(lx-vx)
dy# =(ly-vy)
dz# =(lz-vz)
tdx#=vx-lx
tdy#=vy-ly
tdz#=vz-lz
nl#=Sqr(tdx*tdx+tdy*tdy+tdz*tdz)
nx#=dx/nl
ny#=dy/nl
nz#=dz/nl
nl#=(nl*10.-255.)/255.
nl=1-nl
If nl>1 nl=1
If nl<0 nl=0
nl=in
nx=nx*inten
ny=ny*inten
nz=nz*inten
VertexColor srf,v,128+(128*nx),128+(128*nz),128+(128*ny)
Next
Next
FreeEntity tp
End Function