Page 1 of 1

Relighting Doom

Posted: Sun Jan 09, 2022 11:19 am
by Hey Doomer
Is it possible to relight the game completely based on natural and texture light sources and let dynamic lights out of it? In other words, start from no light and ask, Where would light be coming from if this was real? Consider: if your home doesn't have any lights on during the day, the only light entering is from outside through windows. Wouldn't the same be true in Doom? This is the idea behind my new project called Relighting.

Screenshot_Doom_20220109_120331-576x324.png

Screenshot_Doom_20220109_120323-576x324.png


This crude proof of concept illustrates the idea well enough. How it works is simple. Outdoor regions (for now only F_SKY1 ceiling textures) have a light level of 255. At 2-sided linedefs "LightSensors" spawn that look for a "SkyLight" to decide what the sector lighting is in real time. In other words, if a door opens to the outside, the area is flooded with light and goes dark when the door closes.

This is very rough, very early, but it looks like there is potential here to relight the game completely based on light coming from the outside and ceiling textures, which I have not yet added.

Re: Relighting Doom

Posted: Sun Jan 09, 2022 2:20 pm
by Kzer-Za
Looks like a very promising idea!

For now it has too sharp a contrast between lit sectors and unlit ones, I think there should be some gradient. Also the light level probably should be determined not by the amount of sectors or lines between LightSensors, but by the distance between the neighboring LightSensors. And any sector that is contained entirely within a well-lit sector and not separated from the latter by impassable linedefs should be as well-lit as the surrounding sector.

Re: Relighting Doom

Posted: Sun Jan 09, 2022 2:58 pm
by Hey Doomer
Kzer-Za wrote:Looks like a very promising idea!

For now it has too sharp a contrast between lit sectors and unlit ones, I think there should be some gradient. Also the light level probably should be determined not by the amount of sectors or lines between LightSensors, but by the distance between the neighboring LightSensors. And any sector that is contained entirely within a well-lit sector and not separated from the latter by impassable linedefs should be as well-lit as the surrounding sector.


Thanks, Kzer-Za. All good points. I'm making progress:
Screenshot_Doom_20220109_154825-576x324.png


This is entirely lit by code. The default sector lighting is either 255 or 64, depending on lights or no lights. All I've done is averaged in the sector's minimum surrounding sector light and added flats and textures and bright light sources. That's really it. The screenshot is not original E1M1 lighting, believe it or not.

The mod parameters are in text lumps instead of the code itself, so it's very easy to update. I should be able to add color next.

I'll post an update soon.

Re: Relighting Doom

Posted: Sun Jan 09, 2022 3:29 pm
by Hey Doomer
Closed:
Screenshot_Doom_20220109_162145-576x324.png

Open:
Screenshot_Doom_20220109_162600-576x324.png


All code with color added.

Here's the idea of a text lump config:

Code: Select all

F_SKY1,#ffffff
TLITE6_1,#ffff00
TLITE6_4,#ffff00
TLITE6_5,#ff0000
TLITE6_6,#ffff00


Each sector that has one of these ceiling textures (similarly for the sidedef middle textures) has a light level of 255 and a "BrightSector" marker. All the other sectors start with a light level of 64. Everything else is done by the light sensors. Nothing fancy, but it seems to work. It should be universal barring specific lighting effects. More to come.

Re: Relighting Doom

Posted: Sun Jan 09, 2022 11:44 pm
by Kzer-Za
May I make a couple more suggestions?

Currently any sky sector has light level of 255. And probably it's okay for Doom, but in Heretic and Hexen there are maps where sky texture is murky and the light level in those maps in sky sectors is supposed to be lower. I don't know how universal you intend your mod to be, but if it's intended to be more or less universal, then there are also maps where the author has made a night sky and set the light level in the sky sectors accordingly. It would be strange if the light level there was 255. So how about adjusting the light level only in sectors that are not under the sky, while for sky sectors — leave the light that was set in the map data?

Second thing: game-wise it's the opposite, i.e. Heretic and Hexen are unaffected, but Doom actually has wall textures that are supposed to make a sector bright. Remember those white lamps? In Doom maps the sectors that have them on the walls are very brightly lit. So at least these wall textures should be taken into account. But I personally think that to account for everything, also textures of CRT monitors (with all those planets, charts, etc) should be taken into account for slightly increasing the light level, and there are also textures of stone walls with lamps right on the texture.

And the lower light level limit of 64 — isn't it making Light-Amp Goggles redundant? I personally have no trouble navigating in sectors with 64, and I haven't touched brightness settings, it's default in my case. So maybe, set the light level of 64 only for non-sky sectors that already have the light level of >= 64? And if a sector has the light level < 64, leave it as it is?

Edit: probably, sector specials that make the light blink should also be removed from the sectors' data upon WorldLoaded.

Edit 2: probably, some floors (like lava) also should be taken into account.

Re: Relighting Doom

Posted: Mon Jan 10, 2022 4:32 am
by Hey Doomer
Kzer-Za, these are all great suggestions! I have included light textures in flats and sidedefs (although I have not uploaded this version). That part is easily configured by changing a text lump. I am working with a light level of 64 so I can see (as you say) during testing. I haven't considered Heretic and Hexen. I'm not sure how this would work with those games, since I don't play them. You're correct about sectors with electronic screens as well. It seems to me a dimmer light from an electronic screen would not bleed into surrounding sectors and therefore not be a light source per se. Just ain't there yet.

Originally I wondered "What if windows in Doom lit the indoors with skylight?" and as you have pointed out that isn't always the case. Interestingly, in practice the effectiveness of this idea depends on how large and gloomy the interior is. It's exactly as if it's high noon outside and the sun isn't shining directly through window openings. As in real life it adds some light and just looks very bright outside. It depends on the area. It's very interesting to see in action, since smaller areas (turn left up the stairs in E1M1) are much brighter. And that makes sense, since there are more windows to light that space. That isn't hard coded, anyway, and is in the config lump (also not in the upload). Authors can always leave the outdoors as is.

A fundamental issue with dynamic lighting vs. sector lighting is one changes, one doesn't. I want to have a similar effect on sector lighting as when a dynamic light source is extinguished and an area gets darker, if that makes sense. I want sector lighting to be dynamic. Here are two screenshots from E1M1 showing how the light level in the short hallway before the exit area increases when the door opens:

Spoiler:


The screenshots don't do this justice. I'm still working on details, but it's pretty cool to see in action.

Re: Relighting Doom

Posted: Mon Jan 10, 2022 6:51 am
by Hey Doomer
Better example of dynamic sector lighting in E1M3 (current sector becomes slightly brighter when the door is opened):

Screenshot_Doom_20220110_074826-576x324.png

Screenshot_Doom_20220110_074832-576x324.png

Re: Relighting Doom

Posted: Mon Jan 10, 2022 8:22 am
by Kzer-Za
It looks really cool!