reading colour from lightmap for lighting entity?

Blitz3D Forums/Blitz3D Programming/reading colour from lightmap for lighting entity?

Vorderman(Posted 2004) [#1]
I'm sure a while ago someone posted a routine to read the colour at an entity's position from the lightmap and then set the entity's colour, to enable it to darken when in shadow.

Does anyone have this routine? My attempt is very slow it seems.

Thanks
James


ckob(Posted 2004) [#2]
yeah the dudes email that wrote the example for what your asking is kusanagi@...
I coudnt find the example though


puki(Posted 2004) [#3]
Is this it?:
danjeruz.servegame.com/DSS/vollight.zip


Damien Sturdy(Posted 2004) [#4]
Sorry Puki, my server has been shut down by my ISP. i will email Vorderman as i still have the file though.


puki(Posted 2004) [#5]
I'm not sure if it is the one.

Hey, "Vorderman" - is it the one in this thread?:
http://www.blitzbasic.com/Community/posts.php?topic=38107


Damien Sturdy(Posted 2004) [#6]
I've sent the file to him via Email.


Vorderman(Posted 2004) [#7]
Thanks very much Cygnus - I'll have a look at it and see whether it's the thing I was after. I think there was a simple code example posted by someone somewhere, just posted up as normal in a [code] box - the forum search is next to useless though and I still can't find it...

by the way, how do you know my email :) ???


Vorderman(Posted 2004) [#8]
Anyone know who "kusanagi@..." is? I shall email him to see if he has the code example around still. Thanks ckob.


puki(Posted 2004) [#9]
"Cygnus" knows and, if not, I can find out - the original for the above zip was posted at Blitzcoder - I think the guy is Russian or something - I can get the info.

Is the zip file the code you wanted? If not, tell us everything you remember about the posted code you saw - names of people that posted in the thread - was it the code for an actual lightmapper routine or something else - any more info, will help me locate the code for you.


Tom(Posted 2004) [#10]
How about Fredborgs PickedU() & PickedV() commands?

http://www.blitzbasic.com/codearcs/codearcs.php?code=515

Linepick down
Get the Picked U & V
Read that pixel color from the lightmap.

Rough & Fast :)


Mustang(Posted 2004) [#11]
Freelance 3D Artist, full time dad (note: 'Dad' services not for hire!)


:)

I could use "full time 3D Artist & dad" - but I too wouldn't want to be a rent-a-dad for anyone else, it's too tough, one kid is more than enough...


puki(Posted 2004) [#12]
The volume light code was done by "DSS" (that is what he is called on Blitzcoder). I don't think he posts here. He lives in the UK and his email is mailto:dmitry.smirnov@...


Damien Sturdy(Posted 2004) [#13]
yes, DSS is the coder for the volume lightmap program. my server is down but providing im not flooded with requests, il send the code via email.


Vorderman(Posted 2004) [#14]
Hmm, I'm not sure that volume lightmap program is the correct one - what I saw was a small routine to just return the colour from the lightmap at the position of an entity. I've done this myself with just a few lines, but for some reason reading the pixel colour from the lightmap is very very slow - even a single read every render loop drops the framerate, and I've tried using lockbuffer and readpixelfast - I must be doing something wrong somewhere - any ideas anyone?


Tom(Posted 2004) [#15]
With certain NVidia drivers, I've noticed slow downs with textures using the flag 256 (vram), is your lightmap using this flag?


Sledge(Posted 2004) [#16]

for some reason reading the pixel colour from the lightmap is very very slow - even a single read every render loop drops the framerate, and I've tried using lockbuffer and readpixelfast - I must be doing something wrong somewhere - any ideas anyone?


The size of the lightmap matters greatly - make it as small as you can bear to see. (EDIT: I'm basing this advice on my experience with kusanagi's technique.)


Vorderman(Posted 2004) [#17]
I'm not using texture flag 256, the LM is just loaded as normal and set to blend in the second UV channel. It is 1024x1024 though - I might try reducing it to 256 or 512 and see what happens. Thanks.


MSW(Posted 2004) [#18]

Hmm, I'm not sure that volume lightmap program is the correct one - what I saw was a small routine to just return the colour from the lightmap at the position of an entity. I've done this myself with just a few lines, but for some reason reading the pixel colour from the lightmap is very very slow - even a single read every render loop drops the framerate, and I've tried using lockbuffer and readpixelfast - I must be doing something wrong somewhere - any ideas anyone?



Upon loading the lightmap, make and store a copy of it in a bank or array...read the colors from there, NOT the lightmap stored in video memory.


Afrohorse(Posted 2004) [#19]
Upon loading the lightmap, make and store a copy of it in a bank or array...read the colors from there, NOT the lightmap stored in video memory.


I 2nd that! You don't want to be reading texture data directly - oh no!

In addition, if you're dealing with a character running around a level you only need to store the lightmaps on surfaces the character can walk over. For example, you could only take copies of the lightmaps from polygons with normals that point upwards - this saves quite a lot of memory. To save even more, you don't have to have these 'memory copy' of the textures at the same resolution, you could store them at a lower resolution and interpolate the results.