Give the image numbers of the source texture, light map, and destination image. Texture and light map are combined to create a new image. It's important that both source images are the same size, and its square. I haven't tested it yet with images that aren't square.
screenwidth = 800
screenheight = 600
set display mode screenwidth,screenheight,32
load image "clouds.jpg", 1, 1
load image "lightmap.bmp", 2, 1
create_shadowed_image(1,2,3)
sync on
autocam off
backdrop on
position camera 0,0,0
make object plain 1, 150,150
position object 1, -150,0,400
texture object 1, 1
make object plain 2, 150,150
position object 2, 0,0,400
texture object 2,2
make object plain 3, 150, 150
position object 3, 150,0,400
texture object 3,3
do
set cursor 0,0
print screen fps()
sync
loop
function create_shadowed_image(texture as integer, light as integer, destination as integer )
make memblock from image 255, texture
make memblock from image 256, light
make memblock from image 257, light
width as dword
height as dword
width = memblock dword(255, 0)
height = memblock dword(255, 4)
for x = 1 to width
for y = 1 to height
location = ((y-1)*width + x - 1)*4 + 12
b = (memblock byte(255,location) * memblock byte(256,location)) / 255
g = (memblock byte(255,location+1) * memblock byte(256,location+1)) / 255
r = (memblock byte(255,location+2) * memblock byte(256,location+2)) / 255
write memblock dword 257, location, rgb(r,g,b)
next y
next x
rem image number, memblock number
make image from memblock destination, 257
delete memblock 255
delete memblock 256
delete memblock 257
endfunction
you can download the images here.
http://www.dannywartnaby.co.uk/rgt/attachments/images45465.zip
"eureka" - Archimedes