Alternate way of checking character lighting
Miscellaneous Forums/General Discussion/Alternate way of checking character lighting
Just a theory i have, as i was thinking of ways of determining a way of checking if a character had stepped into a lightmapped part of a level.
What you do is create in your editor, a mesh detailing the boundries of the light. Then parent a pivot to your main character, always resetting the collision between it and light volumes, so it doesn't get stuck.
Now, every frame, you simply check whether the pivot is in the same co-ords as the character. If it is, then the character is standing in a light source, and can be lit.
A few possible applications i can think of. If you have a lightmapped scene, containing a fair number of lights, you know which vertex (directX lights) you can switch off. For instance, if a character goes behind a pillar, you can turn the light off, so it doesn't look like it's shining through the pillar.
The biggest drawback though, would be the time and effort of setting up these volumes. However, something like sswifts shadow system could be helpful and set up the light areas automatically, with some tweaking. Maybe alot of tweaking actually.
So, get cracking swifty, and get your shadow system to create light volumes :o)
Any thoughts?
This is easy though with a 2D look-up on the lightmap.
Having said that.
Checking the character is in a unlit area or lit area is easy - top-down point of view.
The problem is cross light - I see no way of doing that within the lightmap look-up.
Would have to be an independent system.
The stepping in and out of 'downlighter' (overhead lights) is all done with down picking - you can then return the individual texture to the triangle and know whether it is lit or not. However, I assume it would be easier to put them in a look-up table of purely the ones that are in dark - then everthing else is light. Then there is no need to look up the textures - you would just do it on triangle basis.
Well, you can use a combination of both. Looks up a lightmap value would work, but if your character jumps, or is being hit by an upwards light, then you don't have anything to work with, plus the light values can change alot, giving you an unrealistic change of light for your character.
The problem is we can only see lights that hit a surface - I don't see how you can check the lighting from a lightmap that you cannot pull from a surface.
This is easy with lights that all point in the same direction. Everthing else causes problems.
I can't replicate this from my look-up method.
Technically, if the level has a lot of corridors you can do it as you can check a 45 degree surface as well as a floor surface - however, once you move into open spaces you cannot check the crosslighting - the amount of picking would kill the idea.
Surely it is just as easy to light the character with LightMesh, without faffing about? This can be done dynamically. No worrying about real-time lighting.
We are dealing with static lighting here so the shadow can be applied after the character has been fakelit.
Right, all sorted.
..what i do is store rgb values from lightmap in to an array and simply entitycolor my character acording to its current position with given rgb what matching UV and its working like a charm...downside of this method is if you enter under tree shadow for example, and light passing trough some leaves...character will be lighten up by one color whole..not exactly with multiple light dots as light passing trough leaves...what im trying to sort out now is actually to map my character with lightmap too in dynamic way so if my character enter tree shadow, it will be mapped by lightmap and corectly get shaded with all fancy parts of light passing trough leaves....or someone did this already?
You could potentially environment map the leaf shadows - ie fake it.
..what i do is store rgb values from lightmap in to an array and simply entitycolor my character acording to its current position
http://www.research.scea.com/gdc2003/spherical-harmonic-lighting.pdf
I was thinking of blurring the lightmap, to provide a subtle lighting, in conjunction with the light volume idea. I even tried rendering a cubemap to give super realistic results, but it always made my lighting too shiney unfortunelty. Too much contrast.
I would just make a top-down camera and check if any pixels on the buffer on the character are brighter than a certain value.
That's pretty slow though. Unless there is a way to read a (16x16) * 3 texture extremely quickly. 3 because you can only see 3 side of a cubemap at any time.