Bay 12 Games Forum

Dwarf Fortress => DF Suggestions => Topic started by: Flying Mage on April 18, 2008, 11:03:00 am

Title: Light...
Post by: Flying Mage on April 18, 2008, 11:03:00 am
I was reading somewhere about this as planned feature, but now can’t remember where. Anyway, here is my suggestion about whole concept of light in the game. Maybe I will repeat something which is already present or planned. But maybe it will somehow useful. (I WILL be lost in translation for sure, but I kinda hope you will understand what I try to tell  :))

So from the beginning:

1.   Illumination critical for everything. So lack of it will slow down performing of any tasks, cause less quality goods production and dramatically rise risk of injury.

2.   Level of illumination is different from tile to tile. So I will call  total darkness as “0%light”, comfortable illumination as “100%light” and blinding flash as “200%light”

3.   There are light sources of different power, from little candle to sun itself. This “power” is basic number which is determines level and area of illumination.

4.   There are different types of objects. So any object in game must have number from 1 to 7 which is determines visibility (size) of object. This sizes can be micro, tiny, small, medium, large, colossal and mega. Every object has one particular size but when moving it’s counting as +1 size, when moving fast +2, but when hiding -1. Medium size is for dwarf, plate mail, barrel or throne. Kobold, goblin, dog, chain mail or shield is small. Elf, human, cow, horse, table or bed is large. Buckler, bucket, helm or cat are tiny, and rings, amulets, arrows and bolts is micro. Trees, catapults and other like this is colossal, and megabeasts are mega  :) etc.

Take a candle for example: it has little power and illuminate about 3 tiles around (which is 7x7 area). It has no blinding effect and have only 40%light in center, 30% in first tiles, 20% in second and 10% in third. Something like this. More powerful souses will create illumination more bright and more wide.

5.   Illumination percentage determines how good dwarfs (and anybody else) will see any items (or characters) on this particular tile. So they see anything on 100%light tile. They also see everything on 90% and 80%light tiles without any negative causes, so it’s best illumination for searching, work or anything else. 70%light tile will make micro objects hidden from distance more than 7 tiles. 60%light makes tiny objects hidden from distance more than 7 tiles, and micro hidden from 6. 50%light makes small objects hidden from distance more than 7 tiles, tiny hidden from 6 and micro from 5. And so on.

So if our candle illuminate a (small) dog sitting on next tile to it, this dog will be 30% illuminated and visible from 5 tiles and less. A candle is lesser of light sources, so lantern will illuminate dog for 40%, torch for 50%, gas lamp for 60% and light vent from surface for 90%. If dog will move, it makes him more visible and expand visibility range.

6.   Combined light sources creates combined illumination areas. Amount of %light on each tile will be summary of all %light on this tile. So two candles can bring 80%light on center tile and 60%light on first tiles next to source. It will be nice challenge to combine different light sources for comfortable illumination and do not overflow fortress with blinding zones. Cause if we take two or three powerful light sources in one point they will create combined light source which will blind anyone within several tiles.

7.   Blinding is similar to shading and 110%light is similar to 90% light. But there is difference between 0%light and 200%light. In first case creature (without night vision ability) will run to visible (10%light) place. So dwarf can travel from one VISIBLE lighted area to another thru darkness. But if he walks into 200%light area he will be absolutely blinded and will run in random direction in attempt of leaving blinding zone.

8.   Candles, torches and all kind of lamps have finite lighting ability. Candles will burn totally and require full exchange, torches have 5-10 life periods with changing of burning material, lanterns, gas and lava lamps must be just refueled. (Another labor must be created special for this.) And only light vents (which will transfer sun light into dungeon) absolutely endless. This vents, build from surface, makes light sources on every level they run, but require digging, architecture, masonry and mirrors from glassmaker. Small and tiny creatures can make their way in fortress thru light vents, so grates highly recommended, but micro creatures can get in anyway. Also vents can split, so one surface exit will fill several vents but power of sources provided by this vents will be -20% for every split.

9.   Quality of any light source objects can determine illumination radius. Maybe some artifact will illuminate entire dungeon.

10.   Walls and doors will be barriers for light, and illumination areas can be designated similar to room designation, only without resizing.

11. Illumination on surface is 100%. Any exit is light source equivalent to light vent but it can't transfer light to another level or another place on current level.

I know I just raving here  :) My system not ready for anything and not balanced at all, but has some potential, I think. So main question is what you think about it? Any comments…

Title: Re: Light...
Post by: gerkinzola on April 18, 2008, 11:15:00 am
if the engine has to handle anything like this it will cause a massive drop in FPS and i believe will be unbarable to have to handle all that micromanaging of light sources. im not canning it completely although has HUGE room for improvement.

[ April 18, 2008: Message edited by: gerkinzola ]

Title: Re: Light...
Post by: Drakale on April 18, 2008, 11:33:00 am
Imo, it would be saner to use something like 0-NOLIGHT 1-LOWLIGHT 2-BRIGHTLIGHT

I think it would cover most cases and not slow down things too much. Make programming simpler too. Low light is enough for working but may cause bad toughts on light loving creatures, Bright light is uncomfortable to dark dwellers etc..

Your system sound like it would be overengineered for the need of dwarf fortress(imho of course). Still, nice read.

Cheers.

Title: Re: Light...
Post by: Draco18s on April 18, 2008, 01:01:00 pm
See the Lighting Arc for details about Taody's plans.

As for bit used to represent data, my guess is
0 Dark
1 Dim
2 Normal
3 Bright

or an 8 bit solution like water has.

Title: Re: Light...
Post by: Derakon on April 18, 2008, 01:07:00 pm
Water uses three bits, not eight.
000 = no water
001 = 1/7
010 = 2/7
011 = 3/7
...
111 = 7/7
This has been your base-two nitpick of the day.
Title: Re: Light...
Post by: Flying Mage on April 18, 2008, 02:20:00 pm
quote:
Originally posted by gerkinzola:
<STRONG>if the engine has to handle anything like this it will cause a massive drop in FPS

[ April 18, 2008: Message edited by: gerkinzola ]</STRONG>


Actually I don't quite understand why DF is SO demanding.
Maybe future optimization of code will solve this.

Title: Re: Light...
Post by: Drakale on April 18, 2008, 03:16:00 pm
One way to optimize is to use more memory efficient algorithms, and that can be achieved by using smaller memory allocations for things like lighting etc.. A % based system need a minimum of 7 bits per tile for information while something with 4 states need 2. The impact on calculation/memory usage is huge in a game like DF that need to perform lots of checks in real time. It could certainly work with a % based system, but the question is is it really necessary, any processor time put on this might be used on something else.

Anyway these kind of decision are for toady to make, i guess i just can't help commenting on it   :D

Title: Re: Light...
Post by: Haedrian on April 18, 2008, 03:20:00 pm
quote:
Originally posted by Flying Mage:
<STRONG>

Actually I don't quite understand why DF is SO demanding.
Maybe future optimization of code will solve this.</STRONG>


Because every moment it has to know where each dwarf, animal is and what its doing, and it also has to store the location of all the stuff. That's why the save files are so huge. Even if most data is saved on secondary storage, the whole S.S. -> Memory -> S.S. thing kills the CPU.

Title: Re: Light...
Post by: Draco18s on April 18, 2008, 03:29:00 pm
quote:
Originally posted by Derakon:
<STRONG>Water uses three bits, not eight.
000 = no water</STRONG>

Sorry, I meant 8 bit positions (8 levels, 2^3).

Title: Re: Light...
Post by: Derakon on April 18, 2008, 03:34:00 pm
Actually, it's pretty well known that most of the cost of DF is in the pathing algorithm, which makes absolutely no assumptions about the layout of your fortress. This keeps it flexible but means that pathing decisions take longer.

There's certainly a lot of data in the savefiles, but most of it isn't used on a regular basis (e.g. the status of the humans in a small village on the other side of the world) and thus doesn't affect performance except when saving and loading files.

Title: Re: Light...
Post by: EOTistatron on April 18, 2008, 04:27:00 pm
Well as long as it didn't take too much, a mirror system might be worth implementing. Obviously it would only work during the day, but it would lower maintenance costs for forts with fewer resources. That and it'd allow for overly complex integrations, which are always fun.

I suppose giving water a light level would be a bit excessive, eh? Probably for the best, it'd just give the carp another way to ambush us...

Title: Re: Light...
Post by: Flying Mage on April 19, 2008, 01:59:00 am
quote:
Originally posted by Drakale:
<STRONG>A % based system need a minimum of 7 bits per tile for information while something with 4 states need 2.
</STRONG>

It's not necessary % based system. I use % (and other numbers) just for example. Everething can be changed in any way and adapted for the game.

quote:
Originally posted by EOTistatron:
<STRONG>Well as long as it didn't take too much, a mirror system might be worth implementing. Obviously it would only work during the day, but it would lower maintenance costs for forts with fewer resources. That and it'd allow for overly complex integrations, which are always fun.
</STRONG>

I didn't know there is day/night change. I thought only years and seasons.
Title: Re: Light...
Post by: Dae on April 19, 2008, 06:44:00 am
Had we an indicator of whether it's night or day, it would only blink. Totally useless.
In fact, this system would make pathfinding heavier, but as long as light sources are static it wouldn't be so much of a problem.
Now, about carriable torches  :roll:
Title: Re: Light...
Post by: Belteshazzar on April 19, 2008, 10:12:00 pm
Perhaps Day and night could be somewhat abstracted by having only one or two cycle per a season in fortress mode. This way we could still have dawn, Noon, dusk, Night  phases. This would allow those nocturnal, diurnal, ect tags for creatures to have greater effect. It would also make it a bad idea to bust into a vampire crypt or daemon pit during the night if certain creatures were much easier to fight in the light.
Title: Re: Light...
Post by: Dae on April 20, 2008, 11:32:00 am
Time flies in dwarf mode. 24 hours in game may last, say, 4 seconds IRL. The idea of having a day/night cycle spread over months (as dwarven sleep cycle is) just seems weird... I don't know what to think about it actually.
Title: Re: Light...
Post by: Draco18s on April 20, 2008, 05:12:00 pm
quote:
Originally posted by Dae:
<STRONG>I don't know what to think about it actually.</STRONG>

What if you embark near a polar regoin?  ;)

Title: Re: Light...
Post by: MaxVance on April 20, 2008, 06:00:00 pm
As for indoor lighting, I think one of the development pages said something about gem lamps. Whether this meant lamps with gems for windows or magic lamps that produce light using the gems, I'm not sure.

But this question stands: Would cave adapted dwarves get sick from artificial light? Likewise, would such light prevent cave adaptation?

Title: Re: Light...
Post by: Nadaka on April 20, 2008, 11:50:00 pm
I would actually prefer to model light as something of a flow...

Any outdoor tile would "bright" and causes problems for cave adapted dwarves. This implies a brightness of greater than 7/7.
the paths from outdoors to indoors are treated as a light source.

unlike a normal flow there is no random walk.
This means that light will form a "triangle"
7/7 6/7 5/7 4/7 3/7 2/7 1/7 0/7 ...

Dwarves are fine with anything from 7/7 to 1/7. At 0/7 or less the dwarves would be slowed in much the same way as they are without booze.

Allowing light flows to overlap and interact becomes a little trickier, and how to do it best may require some careful study.

X = wall
O = outdoors
# = amount of light

Example of a simple light source in a 1 wide hallway.

code:

XXXXXXXXXXXXXXXXXXXXX
O76543210000000000000
XXXXXXXXXXXXXXXXXXXXX

Example of a simple light source in a wide indoor area.

code:

X00000000
X11111110
X22222210
X33333210
X44443210
X55543210
X66543210
X76543210
O76543210
XXXX43210
X12333210
X12222210
X11111110
X00000000

Windows and glass block structures should allow light to pass through normally. And additional furniture could be devised to create or transport light for parts of the fortress farther from the surface. Torches, forges, candles, fires, etc would shed light in a similar but weaker manner.

A mirror could be placed that transmits light to a specific tile in line of sight (at -1 light level). Aim it at the wall at the end of a long hall to get a 6/7 light source (and light flowing outwards from there) from a mirror in 7/7 ilumination area. likewise, you could aim it at another mirror to bounce it around a corner.

One question that may arise is how light flowing from multiple light sources interact. If not at all, it would save a lot of CPU usage. If they stack, it wouldn't be to painful, but might lead to indoor areas with more than 7/7 light. and that would have to be addressed somehow.

One option would be to temporarily assign those tiles the same light sickness qualities as outdoor tiles and ignore everything over 7/7 light.

Another option would be that no matter how many sources, you can light sickness except outside as there are only so many light sources a dwarf can look at at the same time.

Yet another option might be that overlapping light zones "overflow" to create a footprint with a radius larger than the standard 7 tiles.

[ April 21, 2008: Message edited by: Nadaka ]

Title: Re: Light...
Post by: Mikademus on April 22, 2008, 02:11:00 pm
@Nadaka:

You're basically suggesting a BSP/portal-akin lightning engine. These are used in FPS games, and the data structures for real-time management of the lighting data is usually pre-computed and stored in the level information because It is EXTREMELY computationally expensive. DF, being essentially 2D, could manage this on the fly, but a likely estimate of a realistic and dynamic implementation would be at an expensive of 60-80% of the game's CPU cycles.

Title: Re: Light...
Post by: Coke_Can64 on April 23, 2008, 05:48:00 am
One word:

Infravision.   :p

Title: Re: Light...
Post by: RadioTrefoil on April 16, 2012, 06:38:06 am
Lighting and lamps should contribute to dwarven thoughts. Sufficient lighting should give a dwarf a happy thought "<dwarf> admired a fine lamp recently", and insufficient lighting will give a bad thought - "<dwarf> complained about a lack of lighting recently". Also lamps cannot be constructed from Wood or other flammables, and will set fuel on fire if it is on an adjacent tile.
Title: Re: Light...
Post by: NW_Kohaku on April 16, 2012, 07:34:34 am
Well, now here's a blast from the past...  I saw "Light", and was getting ready to remind people that this is already a devgoal. 

Anyway, if we are talking about ways to "enforce" lighting, then happiness thoughts are probably going to be problematic, as we are going to be getting Personality Rewrite soon(ish), and one of the objectives in that is to completely scrap and replace happiness for a more complex system. 

Likewise, lighting is probably going to need a more "serious" set of enforcements, possibly going as far as calculating "Fog of War" based upon lighting, but that might take up too much FPS to calculate real-time. 

Considering the ways that bogeymen work, however, we might see something like Grues appearing if we do not fully light the mines. (Which would of course lead to weaponizing grues.)
Title: Re: Light...
Post by: slothen on April 16, 2012, 08:45:30 am
unless I'm missing something, light and lamps are on the dev page only as a subsection of adventure mode improvements.  I very much doubt we'll see a comprehensive lighting system implemented for fortress mode.
Title: Re: Light...
Post by: NW_Kohaku on April 16, 2012, 10:12:38 am
unless I'm missing something, light and lamps are on the dev page only as a subsection of adventure mode improvements.  I very much doubt we'll see a comprehensive lighting system implemented for fortress mode.

Have you tried looking at the full dev goals (http://www.bay12games.com/dwarves/dev_single.html)?

Quote
FIRE AND LIGHTING ARC: The lighting in caves is artificial right now. It should be pitch black. This is also true of moonless cloudy nights. Once that's in, your adventurer will want fire. Fire can also come up in dwarf mode in various ways. Related to Core14, Core55, Req96 and PowerGoal150.

Quote
Req96, LIGHTING, (Future): Should be pitch black inside adventure caves and on cloudy moonless nights. Vision state should influence what you can see. Can try to make sunlight shine inside caves a bit by casting light lines on map-gen. Can track light with RGB filters so that things through red gem windows look red, etc. Things seen through glass statues could be distorted from their proper positions. Once fire is in, can do torches and other such light sources. Dwarves could place fires or gem lamps in dark places. Any magical take on alchemy could make extensive use of gems in this fashion, and the different colors of light can please certain nobles etc. Related to Core55.

So, one of the things Toady wants to do is have emerald lamps that cast a green glow over a fortress to please some of the nobles. 

Naturally, we will need to set up fortresses where secret messages are written in red over black walls, and surrounded only by green light, so that the message is only revealed when you bring in red light.
Title: Re: Light...
Post by: Supersnes on April 16, 2012, 11:09:02 am
Quote
Naturally, we will need to set up fortresses where secret messages are written in red over black walls, and surrounded only by green light, so that the message is only revealed when you bring in red light.

By then it will be too late.   Your torch will flicker its last flame and the sound and nashing of claws and teeth draw ever closer.....

Spoiler (click to show/hide)



Overall I do agree that this would be a great way to add depth to finding ambushes and sneaking.  Say a sneaking ambushers/adventures comes upon a torch wielding victim.  Ambushers/adventures, depending on their observation/perception skill, will be able to see them more clearly due to being outside the light ring looking in while the torch bearer is restricted to whats in the light ring due to their eyes not being accommodated to the darkness beyond it.  Furthermore it could lead to !!FUN!! if blinding light is added and could lead to some interesting traps.
Title: Re: Light...
Post by: NW_Kohaku on April 16, 2012, 11:28:30 am
Quote
Naturally, we will need to set up fortresses where secret messages are written in red over black walls, and surrounded only by green light, so that the message is only revealed when you bring in red light.

By then it will be too late.   Your torch will flicker its last flame and the sound and nashing of claws and teeth draw ever closer.....

Spoiler (click to show/hide)



Overall I do agree that this would be a great way to add depth to finding ambushes and sneaking.  Say a sneaking ambushers/adventures comes upon a torch wielding victim.  Ambushers/adventures, depending on their observation/perception skill, will be able to see them more clearly due to being outside the light ring looking in while the torch bearer is restricted to whats in the light ring due to their eyes not being accommodated to the darkness beyond it.  Furthermore it could lead to !!FUN!! if blinding light is added and could lead to some interesting traps.

No, worse than that, you were eaten by the Rumia that ate the Grue.  Her talisman is off, she has now gone EX.



The power goal on the old devpages mentions how an adventurer could block the light of the sun, then shift to the side to blind a target with the sun, then strike while they were temporarily dazed. 

Having something like a "shutter" system on a large scale from a fortress, so that you could block the (accursed) Sun before suddenly making it shine down upon your (accursed) enemies to blind them right before the crossbow bolts and mine carts came flying in to stun them and stop dodging might be amusing as a mega defense contract.
Title: Re: Light...
Post by: slothen on April 16, 2012, 01:20:06 pm
unless I'm missing something, light and lamps are on the dev page only as a subsection of adventure mode improvements.  I very much doubt we'll see a comprehensive lighting system implemented for fortress mode.

Have you tried looking at the full dev goals (http://www.bay12games.com/dwarves/dev_single.html)?


Now how was I supposed to find that page?

Hmm, here's a thought for light putting a big burden on FPS in fort mode.  Could light calculations basically be ignored and only invoked when needed?  ie, ambushing enemies, (unrevealed) caverns, etc.  The idea being that static light sources could be calculated once and then only checked when needed, and that dynamic/moving light sources wouldn't be checked at all except in certain circumstances.  Perhaps if a dwarf with a torch was moving through previously revealed spaces, there would be a yes/no check for lighting in a limited radius similar to adventure mode.

Also, would every dwarf carry a torch lantern, or only when going to certain areas, and in that case will the dwarf need to grab a lantern from the lantern stockpile before going into the mining tunnels?
Title: Re: Light...
Post by: Draco18s on April 16, 2012, 01:23:24 pm
unless I'm missing something, light and lamps are on the dev page only as a subsection of adventure mode improvements.  I very much doubt we'll see a comprehensive lighting system implemented for fortress mode.

Have you tried looking at the full dev goals (http://www.bay12games.com/dwarves/dev_single.html)?


Now how was I supposed to find that page?

Top of the forum:

Quote
Check our development pages. You can find everything in one place at this link (http://www.bay12games.com/dwarves/dev_single.html).
Title: Re: Light...
Post by: kaenneth on April 16, 2012, 05:12:12 pm
My take of dwarves and light:
Dwarves have a symbiotic bioluminescent fungus growing in their beards that feeds on their 'filth'. Taking care of the needs for sewage treatment and light sources at the same time.
Title: Re: Light...
Post by: NW_Kohaku on April 16, 2012, 06:08:47 pm
My take of dwarves and light:
Dwarves have a symbiotic bioluminescent fungus growing in their beards that feeds on their 'filth'. Taking care of the needs for sewage treatment and light sources at the same time.

Minus the "filth" part and the "growing in their beards", that's also a powergoal. 

I'd much rather that any bioluminescent fungus be a cavern feature, anyway.  If some of those species of fungus grew on a diet of "filth", that would be an amusing way to sculpt a fortress.

"Urist, pass more of the chamber pots, I need to "seed" the fungus to help light up my masterwork engraving on this wall."
Title: Re: Light...
Post by: dree12 on April 16, 2012, 09:30:17 pm
While we're on the topic of light, I figured I'd give my suggestion out now.

Basically, a tile's lighting consists not of a number, but many, many numbers. These numbers don't represent the "lighting" of the square, but rather the rays of light passing through. A single tile would have up to 27 possible entries in the lighting, one for each direction and one for light originating from the tile. Each direction would then have a mixture of light from different wavelengths; to simplify this, microwave, far infared, infared, red, green, blue, UV, and X-ray can be used as an approximation of the common range (there are 8, so the numbering can be simple). Each wavelength would then have an intensity, which can be packed into a 2 or 3 bit value. For example, at midday the sun's lighting on an aboveground tile may be as follows:

Code: [Select]
null,null,null,null,
[1,4,6,7,7,7,3,0],
null,null,null,null,
null,null,null,null,
null,
null,null,null,null,
null,null,null,null,
null,
null,null,null,null,

As the moon shines in the west and a nearby campfire radiates from below:
Code: [Select]
null,null,null,
[0,0,0,2,2,2,0,0],null,null,
null,null,null,
null,null,null,
null,null,null,
null,null,null,
null,null,null,
null,null,null,
[0,1,2,2,0,0,0,0],null,null

And when a firefly lights up some beautiful blue light while the stars shine with the lack of clouds:
Code: [Select]
[0,0,0,1,1,1,0,0],[0,0,0,1,1,1,0,0],[0,0,0,1,1,1,0,0],
[0,0,0,1,1,1,0,0],[0,0,0,1,1,1,0,0],[0,0,0,1,1,1,0,0],
[0,0,0,1,1,1,0,0],[0,0,0,1,1,1,0,0],[0,0,0,1,1,1,0,0],
null,null,null,
null,[0,0,0,0,0,3,0,0],null,
null,null,[0,0,0,0,0,1,0,0],null
null,null,null,
null,null,null,
null,null,null

While it may be straining on FPS, this system allows for gigantic mirrors focused on enemies, fireflies with varying colours, etc. Imagine lighting a campfire and setting up black screens with the sole purpose of producing shadow puppets on a wall. Or, imagine fort mode after a terrible lack of clouds has persisted for a few days, and the grass is on the verge of igniting, while your firefighting dwarf squad is in the hospital because of UV-related sunburns. The system even allows for severe solar ejections that produce huge amounts of microwaves that are absorbed into most things, but cause dielectric heating in the poor woodcutter, heating his bodily fluids to the point of exaustion.

And, deep inside, I've always wanted to take X-rays of the dwarves.
Title: Re: Light...
Post by: NW_Kohaku on April 16, 2012, 11:15:26 pm
Yeah, that sounds like gross overkill in Fortress Mode, and it would probably nuke FPS. 

If you put that data on every single tile, that's 27 more pointers per tile, of which a single embark can have theoretically as many as 80 million tiles.  There's a reason Toady compresses the map data to the greatest extent that he can.
Title: Re: Light...
Post by: slothen on April 17, 2012, 10:13:30 am
anything is possible if DF becomes magically multi-threaded and 64-bit-whatever.

allofmymoney.jpg
Title: Re: Light...
Post by: dree12 on April 17, 2012, 02:56:38 pm
The thing with lighting is that if it is done with rays instead of "light", it would be easily multi-threadable because each ray is independent of the others.
Title: Re: Light...
Post by: Draco18s on April 17, 2012, 03:16:52 pm
The thing with lighting is that if it is done with rays instead of "light", it would be easily multi-threadable because each ray is independent of the others.

...only in an application that is already set up to be multithreaded.
Title: Re: Light...
Post by: dree12 on April 17, 2012, 03:40:07 pm
The thing with lighting is that if it is done with rays instead of "light", it would be easily multi-threadable because each ray is independent of the others.

...only in an application that is already set up to be multithreaded.
It's fairly simple to spawn a few extra threads at the beginning and have them process only light.
Title: Re: Light...
Post by: Draco18s on April 17, 2012, 03:43:52 pm
The thing with lighting is that if it is done with rays instead of "light", it would be easily multi-threadable because each ray is independent of the others.

...only in an application that is already set up to be multithreaded.
It's fairly simple to spawn a few extra threads at the beginning and have them process only light.

Do you have experience to back this up, or are you talking out of your ass? (As so frequently happens when people discuss this topic)
Title: Re: Light...
Post by: NW_Kohaku on April 17, 2012, 03:57:38 pm
Okaaaaay...

Why don't we move on to talking about ways that light could actually work in a way that would be meaningful to fortress mode?

I seriously doubt we're going to see dwarves get the ability to create x-ray lasers in this game any time soon, so maybe we should work on other means of incorporating light into the game.

One of the things Toady was talking about was alchemy and "gem lights", and lights of different colors, so hypothetically, there could be some sort of light-based mechanism.  Combined with directional gem light lamps and possibly rotatable mirrors, that could allow us to have more fortress mechanics, as well as allowing Adventurers to have light color-based puzzles to deal with in dungeons.
Title: Re: Light...
Post by: Elone on April 17, 2012, 05:55:10 pm
I would say that 1bit lightmaps would be the best balance between function and looks. A tile is either lit or it is not. Perhaps 2 bits if one would handle the revealed tag in the same go.

Every time a dwarf makes a step, the radius of is vision +1 would be darkened (no questions) and the radius +0 would be lit up, based on the occluding objects like walls and trees. The situation is a lot more demanding and complex if there are other dwarves intersecting their LOS with others, which is why adventurer LOS was easy to implement, but the Fort LOS was not.

This simple models ensures that the tiles are darkened without checking the conditions, which eat FPS (contrary to the popular belief, every last one of them counts). It also ensures that the whole map is not constantly checked for lighting, which would be disastrous for any computer, not to mention if each tile had the aforementioned 27 checks. This would include even currently the strongest ones that so many people waves around as their e-length. I'm not calling any names though.

For static lights, it would be best not to refresh it every frame, and have it static as pathing data which recalculates only when the map's pathing is changed. Every time that a light is changed, like a torch being set or taken, the whole map would be blackened, then lit from each light. This is of course an expensive action, but not more expensive than pathing recalculation during mining or bridge operation.

If you wished to combine dynamic and static light, the situation gets even more complex and demanding. You would have to find a way to calculate dynamic light without overwriting the static light data, but you cannot properly do that without recalculating the statics lights once per frame, which whoah, makes them dynamic. You cant have dynamic environment lights because that means roughly 8.000.000 additional calculations PER FRAME on a default 4x4 embark. If you wish to maintain 100 fps, this means 800.000.000 such calculations PER SECOND, which is a lot, but now imagine doing 27 of those suggested calculation PER TILE, PER FRAME. That would be 21.600.000.000 calculations PER SECOND. With a 1bit light system. Now imagine combining their hues, and then multiply it by intensities/shades of light. Not dizzy yet? Look at the original post and imagine implementing each of those suggestions, a check for each, per tile, per second. That should do you in.

Have you ever wondered why the Minecraft character does not carry a torch in his hand that lights his way while he walks? Thats why.
Title: Re: Light...
Post by: Draco18s on April 17, 2012, 11:14:08 pm
Have you ever wondered why the Minecraft character does not carry a torch in his hand that lights his way while he walks? Thats why.

There's a mod that spawns a glowstone block above your head when you're holding a torch active.  It's actually not that lag-inducing.
(Thought it has other problems, such as sometimes forgetting to turn OFF....and once we* managed to get glowstone dust out of it)

*My friend, I was on the server at the time