character affected by lightmap

Blitz3D Forums/Blitz3D Programming/character affected by lightmap

jhocking(Posted 2006) [#1]
I'm pretty sure I have some sample code for this, but I can't find it. How do you make a character affected by the level's lightmap? So that the character darkens when you walk into a shadow.


Tyler(Posted 2006) [#2]
I remember seeing a code somewhere that linepicked straight down, and got the color info of the collided model's texture. I'm gonna need this soon too, so if you find it, share the wealth :D


puki(Posted 2006) [#3]
http://www.blitzcoder.com/ubb/Forum14/HTML/001711.html

Came with full source code - it was the one whereby you steer a sphere around a lightmapped level and as it moved into shade it darkened in relation to the shade.


t3K|Mac(Posted 2006) [#4]
the links to DSS_VLM.zip do not work fore me. anyone having a working one? i'd love to read and learn...


Naughty Alien(Posted 2006) [#5]
I have whole source for this stuff, but I am not sure is it same author..anyway, it is stuff Puki explained before...you can move scaled sphere over lightmapped level and its changin light over sphere surface according to lightmap light source...


t3K|Mac(Posted 2006) [#6]
thats exactly what i am looking for ;) do you mind if you mail it to me? adress is in my profile...


Naughty Alien(Posted 2006) [#7]
..of course, here is download link, enjoy this excellent stuff...

http://www.sendmefile.com/00224913


Damien Sturdy(Posted 2006) [#8]
I still have file however my ISP kept booting me off for running a server- I had to remove the file. Sorry all!


Naughty Alien(Posted 2006) [#9]
..hmm..my previous link doesnt work...try this one..

http://www.freefileupload.net/file.php?file=files/110106/1136977441/SMART_LIGHT_SYSTEM.zip


John Blackledge(Posted 2006) [#10]
"A connection with the server could not be established."
???


Naughty Alien(Posted 2006) [#11]
huhh...maybe this one...
http://www11.rapidupload.com/d.php?file=dl&filepath=4581

this one working..I try just now..


jhocking(Posted 2006) [#12]
Thanks!


Avrigus(Posted 2006) [#13]
Wow that's a fantastic example! Here's a simpler version I downloaded a few years ago (this example was created by kusanagi@... ):
http://www.secretsally.com/lightmap_col.zip


RifRaf(Posted 2006) [#14]
What i do for this is similar . on my main mesh i will go
through the lightmap, and give the appropriate vertexcolor
to the nearest vertex of the pixel.

Then after i mirror the lightmap to vetexcolors (i dont
remove the lm though) i can then do a linepick , and get
the vertexcolor below the player, wich is much faster than
getting the texture uv coords and reading the texture pixel
color as well.

Your lightmap, or colormap will need to be tweaked to use
this method. as the additional vertexcoloring will darken
the lightmap some.


JoshK(Posted 2006) [#15]
You don't need to mess around reading pixels from the lightmap.

Just keep track of where all your lights are. If they are visible to the player, and in range, use them to light the player model, either with vertex colors, or by settings up DX lights and rendering the model in a separate pass.


jhocking(Posted 2006) [#16]
The determining if they are visible to the player, wouldn't that be slow? I mean, that's occlusion culling you're talking about, to determine if the player is in the shadow of an object in the level.

Of course, it doesn't need to be super accurate, so just doing a linepick between the player and the light would do. Hm, I should code that and see how it works out.


RifRaf(Posted 2006) [#17]
You don't need to mess around reading pixels from the lightmap.


the original question was about using the lightmap, not a lighting "system"


jhocking(Posted 2006) [#18]
True, but halo's answer addresses the real intent behind my question. That is, he responded to my underlying concern, not just the literal question.

Incidentally, your vertexcolor suggestion wouldn't work. The whole point of lightmaps is that vertex color isn't detailed enough to show stuff like shadows. Note that the original request specifically referred to having characters affected by shadows in the level.


RifRaf(Posted 2006) [#19]
Yes it works very well. you dont remove the lightmap, you simply vertex color a best batch to the dark tones of the lightmap. the shot below has both lightmap and vertexcoloring for the purpose of picking the vertexcolor instead of reading pixels from the texture..

http://www.empowergames.com/pubimages/mc_treepack2.jpg?
http://www.empowergames.com/pubimages/mc_newlm4.jpg?

Plenty accurate if your using say a mesh terrain. as i am, i havent tried it in say an interior scene, you would be right in that case unless you segmented flat areas to accomodate the vertex light effects

but then i was just offering a suggestion to try, didnt realize you would want to debate it. I agree that Halos idea is a good one.


jhocking(Posted 2006) [#20]
Geez dude. You'll pick on somebody else's response, but you can't take your own medicine?


RifRaf(Posted 2006) [#21]
if you say so, i was just trying to offer an alternative idea.


OrcSlayer(Posted 2006) [#22]
I've tried out the smart light system by Loki, but I've got a few issues with it I hope someone can help me with...

First it makes a big difference if you have lights set to be real or not. This shouldn't effect it, from what I can tell, because the data comes from gile[s] lights, not blitz lights (right?). However, with real lights turned off, a few lights work (very well I might add) but others seem to simply not exist (they are there on the lightmap, but it doesn't recognize them, or it just doesn't display them). On the other hand, with real lights enabled you have colors bleed through walls since there is no occlusion culling for the DirectX lights (obviously).

Another problem is if I do use it with real lights enabled, which is the only way that seems to work, what is going to happen when I overstep the DirectX limit? No way I'm going to use maps that have less than eight lights in them...so this would certainly be a problem.

Any help would be appreciated!


KuRiX(Posted 2006) [#23]
I have a very fast solution for 1 height levels (for example a simple city).

You create a bitmap top view of the rendered scene in gray scale, then you load the file before starting the game into a Matrix of Colors.

Then you calculate the position of the character in the matrix and assign the color. It works very well and is the fastest solution.

If you have different lightmaps for the same X,Z value then you will need several matrixes.

Good Luck!


Sir Gak(Posted 2006) [#24]
Umm, what about setting the AmbientLight to 0,0,0, and then let the character/object be lit by whatever local lights there are?


jhocking(Posted 2006) [#25]
You seem to have missed the entire point of the question. At any rate, halo's suggestion worked great (at least for my needs, since the lighting setup is just a directional light.)


OrcSlayer(Posted 2006) [#26]
I'd really like to use the smart light system by loki myself, if anyone knows why it only wants to work with "real" lights.

Small update, after doing some testing it seems that all the guile[s] light objects end up being treated as if they are at xyz 0 when not using real lights. I think this would explain the problem, but I don't understand why it happens. Perhaps I need to look inside the code itself...which is bad since it all seems to be in french...


JoshK(Posted 2006) [#27]
Another problem is if I do use it with real lights enabled, which is the only way that seems to work, what is going to happen when I overstep the DirectX limit? No way I'm going to use maps that have less than eight lights in them...so this would certainly be a problem.

Once you eliminate lights that are too far away, or occluded from the player view, it is unlikely your character will be lit by more than 8 lights. If he is, dismissing lights over 8 won't make any difference in his appearance.

You could also calculate lighting per vertex and change the vertex colors. Advantages are you don't need to render the player in a separate pass, and you don't have to worry about the 8-light limitation (although this doesn't really matter anyways). A disadvantage is that calculating vertex lighting is rather slow compared to hardware lights.

Once you establish your lighting system, you may want to refine it by storing a list of lights that affect a model each frame. Instead of re-calculating the lighting each frame, which can make the lighting appear to change suddenly and sharply, you can fade out lights that no longer affect the model, for a smoother transition.


Ross C(Posted 2006) [#28]
To be quickier, wouldn't an EntityVisible be better than a linepick? You still need to set a pickmode for everything that will be in the way of lights. I used this method for a space shooter. If the sun could see the player, I disabled the SLIGHTLY larger, black copy of the mesh acting of a shadow. It does work well :o)


JoshK(Posted 2006) [#29]
Yes, entityvisible is usually faster than linepick. The former will exit the function as soon as one occlusion occurs, while the latter will create a list of all occlusions and return the closest one.