Page 1 of 1

Oriented light disapears when entity moves offscreen

Posted: Tue Jul 15, 2014 10:03 am
by Dark
When entity that has "oriented" light moves beyond the visible area (or screen zooms-in leaving entity outside) the light disappear, even if light directed to the center of the screen.
Petty wired I can say, I do understand that it was done for simplicity but still weird.

Re: Oriented light disapears when entity moves offscreen

Posted: Wed Jul 16, 2014 6:25 am
by slpwnd
What entity are we exactly talking about? Shouldn't happen for the train or the car (as of 0.10.3). It can happen for the character (though that is not a regular scenario because character is usually in the middle of the screen - unless disconnected) and couple of other entities (lab for instance - but those don't have an oriented light by default).

Also if the light is "big" then it will disappear eventually. The mechanism is such that there is a rectangle of about 15 tiles wider than the screen that is searched for lights rendering. Yes, this is a simplification but necessary one. We cannot go through all the entities in the world to check for light rendering :) Another thing is that some entities don't have the mechanism of rendering lights explicitly implemented (like lab for instance).

Re: Oriented light disapears when entity moves offscreen

Posted: Wed Jul 16, 2014 9:10 am
by Dark
Tested with both "car" and "player" types, everything seems like you said :)

Light is about 40 tiles long (its planned to be possible even bigger), when testing with "player"-type it disappears almost immediately, with "car" - about 15-20 tiles off-screen before it turns off.

Can this rectangle search for light-cone textures within player view instead? Or had a range setting in config file?
Right now a workaround is: place a "car" in the middle of a light cone, or even on it tip, but it will look kinda weird when light starts to position in certain direction.

Re: Oriented light disapears when entity moves offscreen

Posted: Wed Jul 16, 2014 9:21 am
by slpwnd
Dark wrote:Can this rectangle search for light-cone textures within player view instead? Or had a range setting in config file?
Right now a workaround is: place a "car" in the middle of a light cone, or even on it tip, but it will look kinda weird when light starts to position in certain direction.
I have fixed this for all the entities that produce any light for 0.10.4 (that includes the character, the lab, the assembling machine, etc.). The rectangle search for entities producing light does happen in the player view.

What exactly are you trying to do? :) I suppose this is for some mod, right?

Re: Oriented light disapears when entity moves offscreen

Posted: Wed Jul 16, 2014 9:46 am
by Dark
Yes, It is a mod, a screenshot can say more :)
screenshot
Spotlights can be rotated at any angle, not just 8 default direction. But if center of rotation is not in the same position as light source - it will look weird, and I have no means to disable car's light until rotation is finished.
I'm planning to release beta version of mod somewhere today.

Re: Oriented light disapears when entity moves offscreen

Posted: Wed Jul 16, 2014 10:11 am
by slpwnd
Nice. Maybe in the future we could have like "always draw" flag. For entities like this - that produce very big light and there are not that many of them. Moving it to minor issues till then. You will also be able to use character, assembling machine, lab or any other entity for this in 0.10.4.

Re: Oriented light disapears when entity moves offscreen

Posted: Wed Jul 16, 2014 10:19 am
by Dark
Only rotatable entities are usable for the purpose, otherwise I would had to draw 360*number_of_colors textures just for light cones and it would eat all video memory, "player" type is not usable for another reason - you can's keep him at certain angle, he snaps to 8 directions. So only a car and a locomotive are left, but loco is not quite useful for obvious reasons.

Re: Oriented light disapears when entity moves offscreen

Posted: Wed Jul 16, 2014 7:29 pm
by Dark
Follow up: If something like "always draw" flag is implemented it would be essential to have ability to toggle it during runtime.
I would write an intelligent drawer for semi-statical objects: player's view does not teleport around (usually), camera moves only one tile up or one tile left at a tick - when camera moves enough we only need to scan border (1 tile line, not rectangle) for entities to show.