I had a look into what petethesparky mentioned and tried it. Hiding light zero does have an impact and it seems the normals are set on the matrix. Still a little more experimenting to fully test this though.
Rem Project: Dark Basic Pro Project
Rem Created: Thursday, September 15, 2011
Rem ***** Main Source File *****
sync on
sync rate 60
autocam off
dot 0,0,0xff0000 : dot 1,0,0xdd0000 : dot 0,1,0xdd0000 : dot 1,1,0xff0000
get image 1, 0,0,2,2
set normalization on
make matrix 1,100,100,5,5
randomize matrix 1,15
prepare matrix texture 1, 1, 1, 1
`fill matrix 1,0,1
for x=1 to 5
for y=1 to 5
`set matrix normal 1,x,y,0,1,0
next
next
hide light 0
make light 1
set spot light 1,5,25
set light range 1,500
position camera 0,10,0
do
mx# = mousemovex() / 4.0
my# = mousemovey() / 4.0
move camera left ( leftkey() - rightkey() ) * 2.0
move camera ( upkey() - downkey() ) * 2.0
xrotate camera wrapvalue( camera angle x() + my# )
yrotate camera wrapvalue( camera angle y() + mx# )
position light 1, camera position x(),camera position y(),camera position z()
rotate light 1, camera angle x(),camera angle y(),camera angle z()
`update matrix 1
sync
loop
The light works on the matrix fine without me even calculating the normals so far. I commented out the set matrix normal command, I originally put that in as a default normal pointing upwards.
As soon as I've fiddled a bit more I'll post some more but I think at the moment the normals are correct.
EDIT: Try this now with your code, it calculates the normals and still seems to work correctly with lighting.
Rem Project: Dark Basic Pro Project
Rem Created: Thursday, September 15, 2011
Rem ***** Main Source File *****
sync on
sync rate 60
autocam off
dot 0,0,0xff0000 : dot 1,0,0xdd0000 : dot 0,1,0xdd0000 : dot 1,1,0xff0000
get image 1, 0,0,2,2
set normalization on
make matrix 1,100,100,5,5
randomize matrix 1,15
prepare matrix texture 1, 1, 1, 1
`fill matrix 1,0,1
for x=1 to 5
for y=1 to 5
x1# = (100.0/5.0)*x
x2# = (100.0/5.0)*(x-1)
x3# = (100.0/5.0)*x
y1# = get ground height(1,(100.0/5.0)*x ,(100.0/5.0)*y)
y2# = get ground height(1,(100.0/5.0)*(x-1),(100.0/5.0)*y)
y3# = get ground height(1,(100.0/5.0)*x ,(100.0/5.0)*(y-1))
z1# = (100.0/5.0)*y
z2# = (100.0/5.0)*y
x3# = (100.0/5.0)*(y-1)
normx# = (z1#-z2#)*(y3#-y2#)-(y1#-y2#)*(z3#-z2#)
normy# = (x1#-x2#)*(z3#-z2#)-(z1#-z2#)*(x3#-x2#)
normz# = (y1#-y2#)*(x3#-x2#)-(x1#-x2#)*(y3#-y2#)
normlength# = sqrt((normx#*normx#)+(normy#*normy#)+(normz#*normz#))
normx# = normx# / normlength#
normy# = normy# / normlength#
normz# = normz# / normlength#
set matrix normal 1,x,y,normx#,normy#,normz#
next
next
hide light 0
make light 1
set spot light 1,5,25
set light range 1,500
position camera 0,10,0
do
mx# = mousemovex() / 4.0
my# = mousemovey() / 4.0
move camera left ( leftkey() - rightkey() ) * 2.0
move camera ( upkey() - downkey() ) * 2.0
xrotate camera wrapvalue( camera angle x() + my# )
yrotate camera wrapvalue( camera angle y() + mx# )
position light 1, camera position x(),camera position y(),camera position z()
rotate light 1, camera angle x(),camera angle y(),camera angle z()
`update matrix 1
sync
loop
I almost wrote out another post...
Warning! May contain Nuts!