Shading a charactor based on a lightmap?
Blitz3D Forums/Blitz3D Programming/Shading a charactor based on a lightmap?
| ||
Hi, I have a charactor on a terrain object. The terrain has a lightmap on it. Is it possible to some how get the light map info for the pixel where my charactor is standing on the terrain, and then use that pixels luma value to shade my charactor darker or lighter depending on the map? This way his shading would change if he went under trees. any ideas? |
| ||
if you know what vertex the character is near, you could use VertexU and VertexV to get the U/V coords, then get the pixel luminance value at that location (or perhaps faster would be to preload the luminance values of the texture into a bank or array). |
| ||
To figure out which polygon is beneath the character do a LinePick straight down and then call PickedTriangle |
| ||
If you know the direction of the light, you could also do linepicks in the opposite direction - probably more accurate. |
| ||
Bot builder is correct. You are going to want to do more then just linepick once, might want to do a cemicircle of short casts to sample the lighting values from. Since it might be quite bright just next to the player, will *Sort* of simulate radiosity. Not accurately or anything, but better then nothing :). |
| ||
You are best off just checking for visibility between the character and the light posiiton. That will be pretty accurate, and match the shading of your lightmap. |
| ||
Haha, I cheated I guess. All I did to solve the problem was store the luma values of each pixal in the lightmap texure to an array, then check where the charactor was on the terrain and scale it to that array. Since the terrain mesh isn't rotated, it was pretty easy to scale the values. Seems to work fine for what I need. Thanks for the help though. |
| ||
I think the original Unreal (Tournament) checks the brightness of the lightmap texel right below the player, and lights the player accordingly. |
| ||
theres something that does this on blitzcoder.com cant find it though, if anyone knows where it is, please tell me! |
| ||
I think the original Unreal (Tournament) checks the brightness of the lightmap texel right below the player, and lights the player accordingly. Actually, it picks the closest X lights (4-8 depending on your system specs) and hits the character model with them. |
| ||
How do you tell the system to only light a charactor with certain X lights? Doesn't it just light from all of them(the 8 it can display) at the same time? |
| ||
"It" in my post being "Unreal Tournament". We didn't use hardware lights. But if you want to do this in Blitz, I suppose you could determine which lights were closest to the character, hide the ones that are too far away, and then draw the character. |
| ||
Actually, it picks the closest X lights (4-8 depending on your system specs) and hits the character model with them Oh. I wonder what game it was that did check the texel beneath, then. |
| ||
I think the original Quake engine did that ... |
| ||
Is it possible to hide lights? Would this make them not affect the scene? |