ID:155021
 
Okay, so while I'm not sure how to go about this, I'm also not even sure if I should try. My primary concern is performance costs. At the same time however I feel Dynamic Lighting can add depth and immersion to a game like no other.

For example, if you're flying through space you would expect a sun to be really bright, but if you happen to be in a 'void', it should be incredibly dark, but a sudden transition is like 'what just happened... did I teleport?'.

Another example is that if you can't see what a monster looks like that's running down a hall after you, you tend to be more afraid than if you could entirely see it, as it breaks into the light you may even be more terrified, up until you see entirely what it looks like and become used to it.

So this really comes with a few pros -and- cons. Should the costs not be too high, how should I go about it? I've seen shadowdarke's DL library which seemed alright, but I don't know how that would impact a server with say 100 players. I've also seen someone use a .dll to get dynamic lighting, but I know absolutely nothing about .dll's to begin with.

So with that, any ideas on where to start researching, reading, learning or a fast and dirty way to get it done would be greatly appreciated.

NOTE: I don't expect anyone to generate a code base for me.
Dynamic lighting has very low impact on performance if it's tied to static light sources. Having a day/night cycle with torches and street lamps scattered around is just fine. You take a performance hit when you tie those light sources to moveable objects. If the light source is static that area is only updating along with the world clock, if the light source is moving around then it has to update every time Move() is called.

There are many games which use this sort of lighting system, but they're all kinda ugly looking. I would recommend looking at D4RK3 54B3R's method of lighting because he figured out a way to smooth out the edges so you don't just have 32x32 blocks of a solid shade.
Stevenw9 wrote:
So this really comes with a few pros -and- cons. Should the costs not be too high, how should I go about it? I've seen shadowdarke's DL library which seemed alright, but I don't know how that would impact a server with say 100 players. I've also seen someone use a .dll to get dynamic lighting, but I know absolutely nothing about .dll's to begin with.

Shadowdarke's dynamicarealighting library is about as fast as it gets. It mostly depends upon view() and other native functions, but that's also why the result can seem somewhat simplistic.

Normally, what you would do is you would use dynamic alpha masks to generate light and shadow. Unfortunately, that's not possible on BYOND.

But what you can do is you can emulate this by computing and keeping track of the brightness value per tile and then interpolating the brightness in between with the icon.

That's more or less the basic idea behind my lighting system. Forum_account's lighting system operates on very very similar principles. We both use linear interpolation for our shadow icons, but use different algorithms to compute brightness and use different techniques in terms of placing the shadows on the map. For example: I keep track of brightness values per tile vertex, Forum_account keeps track of brightness values per tile.

Forum_account used to use cosine interpolation, but switched over to linear several months ago, iirc.

A problem with Shadowdarke's approach is the fact that he relies on the native functions. His lights are square as a result. If you applied interpolation to the shadows for Shadowdarke's system, you would get really pretty and smooth bright squares. This means that you need a way of determining brightness that is relative to Euclidean distance, if you wanted circular lights. Not too complicated.

So with that, any ideas on where to start researching, reading, learning or a fast and dirty way to get it done would be greatly appreciated.

First you should decide on how your brightness dropoff works, relative to distance.

I use inverse distance squared for brightness dropoff and I'm not sure how Forum_account does it.

I do not recommend using a .dll for lighting. The reason being that BYOND's string parsing is atrociously slow and you can only really pass strings to and from the .dll. If you had that .dll write to a dmi file and then loaded that dmi onto the map, then maybe there will be a worthwhile performance improvement. Unfortunately, that approach would make the dynamic solution only practical in singleplayer games.

Things to look into:
Bilinear Filtering (or in other words, linear interpolation along two axes)

Shadowcasting (I have this implemented in my lighting system. This is how I am casting shadows with opaque objects)

A demo for my lighting system

Forum_account's A Miner Adventure (which implements his lighting system)
In response to D4RK3 54B3R (#2)
The effect of your demo is exactly what I'm looking for. The 'sun' is static but small light sources move around (i.e., the torch in the players hand). And then there may be others that are also static.

It's smooth, looks good, and objects even block a fair amount of the light.

As far as your method, I'm not entirely sure what a vertex is but I think it's a specific point on the map? I.E. <1,1,1> My only past experience reference for this is LSL which may be completely different.

As for those 'things to look into', I think I'll be reading and rereading for awhile, lol.
In response to Stevenw9 (#3)
Tile vertices are another way of saying tile corners. Every point where four tiles meet at the corners is a tile vertex.

This doesn't have significant advantages, really. The last time I spoke to him about it, Forum_account kept track of brightness per tile and applied a -16,-16 pixel offset to the shadow objects (I think he used images?).

Another note: Shadowdarke's lighting can easily handle dozens of players on the same server before significant slowdowns. His stuff is fast because he's not dealing with Euclidean distance and makes good use of the native functions.

My lighting can probably handle... up to 30 players before significant slowdowns? It depends upon the game itself.

I don't have stats on Forum_account's, but I would imagine that it has similar performance statistics to mine given how similar the systems are.


Good luck on your project.
In response to D4RK3 54B3R (#4)
Oh, I see. I'll dig around shadowdarkes library then, figure out how it works, and then work from there. Thanks!

EDIT: Though it looks incredibly ugly IMO and finding an in-between for pretty vs performance is going to be annoying.
I know you've seen it, but I figure I should post a link to my library here for the sake of anyone who comes across this thread:

http://www.byond.com/developer/Forum_account/DynamicLighting

In response to Forum_account (#6)
Forum_account wrote:
I know you've seen it, but I figure I should post a link to my library here for the sake of anyone who comes across this thread:

http://www.byond.com/developer/Forum_account/DynamicLighting


I approve of this library. It is my new study tool.