Problem with lights

Posted By: FatherGuido

Problem with lights - 08/27/07 20:16


So I have 5 dynamic lights working in the level not including dynamic sun. They are scripted to go on/off relative to player position and depending on time of day. The problem is that all lights seem to behave strangely depending on..
1. Where the player is in the level
2. Rotation of the camera in relation to where the lightsource/surfaces being lit

The level is comprised of all models and sprites except for the invisible skybox which i'm not even sure I need since I use the day/night script by loopix for environment.

Here is my light action code attached to light sources.

action light
{

my.passable = on;
my.transparent = on;

while(1)
{

if(vec_dist(camera.x, my.x)< 6000) // if light entity is within range of camera

{
if((sun_angle.pan > 170)&&(sun_angle.pan < 360)) // and if the sun is over the horizon
{
my.bright = on;
my.ALPHA = 80;
my.LIGHTRED = 195;
my.LIGHTGREEN = 255;
my.LIGHTBLUE = 150;
while (my.LIGHTRANGE < my._l_range) // run this loop until the entity gets to full light range
{
my.LIGHTRANGE = max(0, my.LIGHTRANGE + 15 * time_step); // increase my.LIGHTRANGE (15 = speed)
wait (1);
}

}

if((sun_angle.pan > 20)&&(sun_angle.pan < 180)) // when sun begins to rise
{
my.bright = off;
my.ALPHA = 100;
my.LIGHTRED = 255;
my.LIGHTGREEN = 255;
my.LIGHTBLUE = 150;
while (my.LIGHTRANGE > 0) // run this loop until the entity becomes invisible (LIGHTRANGE = 0)
{
my.LIGHTRANGE = max(0, my.LIGHTRANGE - 15 * time_step); // decrease my.LIGHTRANGE (15 = speed)
wait (1);
}
}
}

else // if light entity is not within range of camera
{
while (my.LIGHTRANGE > 0) // run this loop until the entity becomes invisible (LIGHTRANGE = 0)
{
my.LIGHTRANGE = max(0, my.LIGHTRANGE - 15 * time_step); // decrease my.LIGHTRANGE (15 = speed)
wait (1);
}
}
wait(1);
}
}

Please let me know what I'm doing wrong. Or are the lights supposed to act this way?? Unlit Surfaces Lit surfaces
Posted By: FatherGuido

Re: Problem with lights - 09/01/07 17:24

"Me" Hi self, are you still looking for an answer?

"Self" Why yes, yes I am. Do you have an answer?

"Me" No, not yet. Patience my friend, someone will get to you.
Posted By: tindust

Re: Problem with lights - 09/01/07 18:55

Hi, not entirely sure from your post what you think is wrong with the lights except that they "behave strangely". Could you specify in what way they are wrong, i.e do they not come on, too early, too late etc.?

cheers,
tindust
Posted By: FatherGuido

Re: Problem with lights - 09/01/07 20:25

Well they do come on. However, they only light (some) surfaces. If I pan with the mouse slightly, they light the other surrounding surfaces that they are supposed to. This includes the player himself. Please see the photos. You will notice the player in the same position in both pics. In the first pic (unlit surfaces), The light is actually on but is only lighting some of the surfaces within it's light range. In the second pic(lit surfaces), the view has been rotated very slightly, thus lighting the other surfaces. this is the same with all lights in the level.

Thank you much
Posted By: tindust

Re: Problem with lights - 09/01/07 21:35

OK. Here is one detail I noticed in your code: Your light action uses the distance to the camera as cue, not the distance to the player model. Since you use the 3rd person view this means that the camera is always located at a distance behind the player model and when you turn, the location of the camera will change which in turn will have an effect on the light intensity of the given light. One solution would be to use the distance from the light to the player model instead of the distance to the camera. This should help for starters.
Posted By: FatherGuido

Re: Problem with lights - 09/02/07 01:36

tindust, thanks for the suggestion. However, I tried changing if(vec_dist(camera.x, my.x)< 6000) to if(vec_dist(player.x, my.x)< 6000) and have the same result. Any other suggestions? I must be missing something somewhere!
Posted By: tindust

Re: Problem with lights - 09/02/07 03:58

Well, the pointers for player and for camera are probably the same unless you specify otherwise. So, I would try something like this:

you = ptr_for_name("thewdlnameoftheplayermodel_mdl_012");
if(vec_dist(camera.x, you.x)< 6000)
Posted By: FatherGuido

Re: Problem with lights - 09/05/07 15:57

Thanks, no good though. I get the same thing. I deleted every light from the level and started over Placing/Building/Running them one by one. It seems that every time I got to 5 lights I got these errors again. I even disabled the on/off switch and the dynamic increase/decrease of the light. I also noticed that if I create any light in the level higher than 1500 quants above 0 on the z axis I get this as well and it doesn't matter if I have 1, 2, 3 or more lights. I guess we are limited to 4 dynamic lights?
Posted By: tindust

Re: Problem with lights - 09/05/07 18:54

I have routinely worked with 8 dynamic lights. So there is defitively not a general limit of 4. However, there are other possible limitations, both hardware and software that can limit the number of dynamic lights that can be active at any one time. Your graphics card from what I can see should easily handle 8, but I'm not sure if the Commercial 3DGS7 is has a limitation as to how many dynamic lights that can be handled by the engine. Also, your default engine setting might be 4 lights. You can make sure that 8 light are allowed by adding the code:

max_lights = 8;

somewhere in your startup code.

Also, you might already have tried this, but make sure each light has its own action that controls its dynamic behavior. I never trust the WED settings only to handle dynamic lights. I might be wrong on this, but I always give each dynamic light its own action.

You mention a z limit position to get normal light behavior. This seems really odd. Not sure what to make of that. Do you have a geometry box around your World? That might help to get beyond that limit.

All in all there seems to be more than one problem issue going on here.

These are just a few suggestions, I hope they will help...

edit: just thought of another thing ... try turning off the sun while working with other lights. Done be adding the code:

sun_light = 0;
© 2024 lite-C Forums