Relighting v4.0165b - blurry shadows w/ rlassets

Projects that alter game functions but do not include new maps belong here.
Forum rules
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.

Got a cool project idea but nothing else? Put it in the project ideas thread instead!

Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.

Please read the full rules for more details.
User avatar
Hey Doomer_
Posts: 415
Joined: Tue Oct 18, 2022 1:59 am
Operating System Version (Optional): Windows 11
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Re: Relighting v4.0165b - next steps

Post by Hey Doomer_ »

Next Steps

I think the current version of Relighting has gone as far as it can go with ZScript except for a few ideas. I'm still discouraged by performance issues associated with thinkers, hitscans, and dynamic lights. Dynamic point lights, in particular, emphasize how flat the engine is, and the performance hit is often not worth it. Also there are features that work but aren't necessarily that interesting (dynamic sector lighting, reflective floors, glow heights).

However, I do like baked sidedef lighting (an idea that is minimally implemented) and sprite shadows (especially interesting with blurry sprites). Colored lighting is a mixed bag but adds an interesting dimension. I'd like to do more with those concepts combined with contour analysis using OpenCV in Python; ZScript is insufficient for that work.

I'm going to start with a stripped-down, limit-removing version of the mod starting with baked lights in ZScript. Not sure what I'll do with these tests but they will likely be posted here for those who are interested. I'll still support the current version of course (remove bugs etc) but I have no plans to do anything more with it.
User avatar
Dan_The_Noob
Posts: 874
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support

Re: Relighting v4.0165b - blurry shadows w/ rlassets

Post by Dan_The_Noob »

I think there's potential to be found with making a spin-off that is less about maintaining the original art direction of a wad and more about transformative options.
Skrell
Posts: 353
Joined: Mon Mar 25, 2013 11:47 am

Re: Relighting v4.0165b - blurry shadows w/ rlassets

Post by Skrell »

Dan_The_Noob wrote: Mon Aug 28, 2023 6:02 am I think there's potential to be found with making a spin-off that is less about maintaining the original art direction of a wad and more about transformative options.
+1
User avatar
Hey Doomer_
Posts: 415
Joined: Tue Oct 18, 2022 1:59 am
Operating System Version (Optional): Windows 11
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Baked test progress

Post by Hey Doomer_ »

I'm making some progress on the baked lighting, accounting for the following: a light threshold of 192, sector lighting specials, and sky sectors without steps. Meeting that criteria a light source actor is placed at the POI in that sector and disperses light beams in all directions to add light to walls. I'm accounting for off-center beams, outside light hitting inside walls, and top and bottom sides. This is understandably a mixed bag given Doom's tortured sector lighting and geometry, but here are two random examples illustrating the effect:

E1M2
MAP01

Note varied lighting in sectors with the same lighting throughout. This doesn't add decorative lights or dynamic lights.

I've built in code to make this dynamic for fireballs, doors, etc. in what I hope is performance-friendly.

The big issue is the extremely inconsistent author lighting; many areas are very bright with no light source anywhere, and some areas are inexplicably dark. I did examine OpenCV contours more closely, but that would not help this problem and indeed only apply to a handful of levels in Romero's levels. Most light sources in the game are mysterious to say the least. In Relighting I've just darkened sectors that are far away and out of sight from light sources. I can also add decorative lights.

Next I'll probably add decorative lighting to this test. I'll post when it's a stable build. 8-)
User avatar
Hey Doomer_
Posts: 415
Joined: Tue Oct 18, 2022 1:59 am
Operating System Version (Optional): Windows 11
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Baked test progress 2

Post by Hey Doomer_ »

FYI adding minimal code to look for decorative lights. This is pretty similar to Relighting with far fewer variables and tweaks.

Reading lumps:

Code: Select all

	Array<string> gl_defs;
	void readgldefs(int startlump)
	{
		int fhnd = Wads.FindLump("gldefs", startlump, Wads.ANYNAMESPACE);
		if (fhnd == -1) return;
		gl_defs.Push(Wads.ReadLump(fhnd).MakeUpper());
		readgldefs(++fhnd);
	}
Adding decorative light sources (does not take into account the intensity of attached color)

Code: Select all

			Actor thing = Level.Sectors[sec.sec].ThingList;
			while (thing)
			{
				string cname = thing.GetClassName();
				cname = cname.MakeUpper();
				foreach(g: gl_defs)
				{
					if (g.IndexOf(cname) != -1 && !thing.bIsMonster && thing.bSolid && !thing.bShootable)
					{
						Actor p = Actor.Spawn("hd_lightsource", (thing.pos.x, thing.pos.y, thing.height));
						if (p)
						{
							p.args[0] = th_light;
							sec.sources++;
							break;
						}
					}
				}
				thing = thing.snext;
			}
Working on baseline lighting for sectors without a light source based on how far away a light source is.

Edit: done and works OK thus far.

I've decided to rely on brightmap definitions to decide if a texture is a light source. This is similar to how a GLDEFS entry determines if a static object is a light source. This is consistent, and there are many, many brightmaps out there. It would be nice, also, if this altered lighting based on different brightmaps. :idea:


Should have something soon.
User avatar
Dan_The_Noob
Posts: 874
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support

Re: Relighting v4.0165b - blurry shadows w/ rlassets

Post by Dan_The_Noob »

maybe you can scale brightness/intensity by brightmap + size of the block the texture is on or something.
User avatar
Hey Doomer_
Posts: 415
Joined: Tue Oct 18, 2022 1:59 am
Operating System Version (Optional): Windows 11
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Re: Relighting v4.0165b - blurry shadows w/ rlassets

Post by Hey Doomer_ »

Dan_The_Noob wrote: Fri Sep 01, 2023 4:23 pm maybe you can scale brightness/intensity by brightmap + size of the block the texture is on or something.
More or less my idea as well. Thus far I've added recursive functions to read gldef and brighmap definition lumps (flats or full textures) and should be able to attach a light source to a texture or put one in a sector where a ceiling flat has a brightmap. (All in ZScript.) This is similar to using GLDEFS to decide what is or isn't a decorative light source.

This does depend on added dynamic lights and brightmaps, but it saves me the trouble of trying to recreate data in these common add-ons by other means.
User avatar
Hey Doomer_
Posts: 415
Joined: Tue Oct 18, 2022 1:59 am
Operating System Version (Optional): Windows 11
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Texture Lights POC successful

Post by Hey Doomer_ »

This idea is based on pulling brightmap definitions for textures. A sector is looped through, the Side.Mid texture is pulled. If it exists in the brightmaps array then a light is attached. Here is proof of concept showing lights attached for only decorative and texture lights independent of author lighting.

texture lights example

This is so simple, so fast, and works so well as POC that it may be the solution to the problem of attaching lights to textures. 8-)

I'm not sure if brightmap definitions are universally defined. What I've done is recursively searched through GLDEFS lumps for texture and/or flat brightmaps or #include statements for more specific files and then grabbed those to see if they contain texture and/or flat brightmaps. This works with the bmplus_textures mod at least.

I've more work on this before a release, but that's the idea.
User avatar
Dan_The_Noob
Posts: 874
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support

Re: Relighting v4.0165b - blurry shadows w/ rlassets

Post by Dan_The_Noob »

I dont see the light or is it just sector light.
User avatar
Hey Doomer_
Posts: 415
Joined: Tue Oct 18, 2022 1:59 am
Operating System Version (Optional): Windows 11
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Re: Relighting v4.0165b - blurry shadows w/ rlassets

Post by Hey Doomer_ »

Dan_The_Noob wrote: Sat Sep 02, 2023 3:51 pm I dont see the light or is it just sector light.
The light is baking the wall lights...
User avatar
Hey Doomer_
Posts: 415
Joined: Tue Oct 18, 2022 1:59 am
Operating System Version (Optional): Windows 11
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Texture lights POC with dynamic lights

Post by Hey Doomer_ »

More progress

I have tweaked baked lights. I have divided light sources into decorative, texture, flat, and outside. Interestingly none of these are placed based on author lighting. Here's the function:

Code: Select all

	void build_hd_sectors()
	{
		foreach(sec: Level.Sectors) hd_sectors.Push(new ("hd_sector").init(sec));
		foreach(sec: hd_sectors)
		{
			Sector this = Level.Sectors[sec.sec];
			foreach(lin: this.Lines)
			{
				// set wall flags
				int fside = (lin.FrontSector != this) ? Line.Back : Line.Front;
				Side wall = lin.Sidedef[fside];
				wall.flags = wall.flags | Side.WALLF_SMOOTHLIGHTING | Side.WALLF_NOFAKECONTRAST;
				wall.Light = -int(this.LightLevel * 0.1);
			}
		}
		find_decorativelights();
		find_texturelights();
		find_flatlights();
		find_outsidelights();
		add_lightseekers();
	}
As you can see, all wall flags are set and light is crudely reduced. Light source actors are added by looping through textures, and "light seekers" are added to account for sectors without light. This is a more granular approach that used in Relighting. Here are examples of dynamic lighting attached to only texture and flat lights:

E1M5
MAP01
MAP02

This uses bmplus brightmaps. (Some choices are odd. I may have to revise this for my purposes, but you get the idea.) This is very performance friendly. 8-)

These aren't particularly strong dynamic lights; there are no allowances for number of sources and other performance variables. There is no color. It's pretty much everything that has a brightmap as a flat or a texture gets a white light attached. Note that I have used different icons for different actors. As an early POC this looks generally very good combined with baked lighting.
User avatar
Hey Doomer_
Posts: 415
Joined: Tue Oct 18, 2022 1:59 am
Operating System Version (Optional): Windows 11
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Relit testing

Post by Hey Doomer_ »

This new project is called Relit.

What's done so far: reading brightmap and gldef information, appropriately placing decorative, texture, flat, and outdoor light sources, baking texture lighting, adding dynamic lights only to textures, and adding color to sectors based on ceiling flat light color. Nothing is based on author lighting, which is kept as is or minimally changed depending on visible sources of light. Code used from Relighting uses R defaults.

I hesitated to add dynamic lighting which is always flat, but lights added to textures are so minimal, so impressive, and so performance-friendly I couldn't resist. The only restriction is the size of the wall itself and so these are limited to relatively small areas. These are only middle textures.

Examples:
1
2
3

Again the only dynamic lights added are to bitmap textures (works with bmplus-textures and Sbrightmaps thus far). Colors are derived from reading flats and textures, which is far from perfect. This is a bare-bones, limit-removing fork that starts with light placement, baked lighting, and adds dynamic lights and color. That's it so far. Not much to it expect for some syntax optimization.

Mod size is slightly over 9 KB at present.
User avatar
Dan_The_Noob
Posts: 874
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support

Re: Relighting v4.0165b - blurry shadows w/ rlassets

Post by Dan_The_Noob »

can i get a v0.0001 to run? because im not entirely sure what is happening still.
User avatar
Hey Doomer_
Posts: 415
Joined: Tue Oct 18, 2022 1:59 am
Operating System Version (Optional): Windows 11
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Re: Relighting v4.0165b - blurry shadows w/ rlassets

Post by Hey Doomer_ »

Dan_The_Noob wrote: Sun Sep 03, 2023 4:28 pm can i get a v0.0001 to run? because im not entirely sure what is happening still.
Soon. 8-)

I've added blurry shadows and separate StatNum variables for flashlight and missile actors. This should greatly improve performance in a firefight.

Floor and wall shadows work. I'm currently adding legacy features to wall shadows. So far this is 135 lines of codes instead of 610. Since this is limit-removing I'm not tracking the number of types of shadows or adding convoluted optimizations (such as only showing what can be seen by the player, tracking what happens at what distance, etc.). Dual shadows have been removed and shadows are "thrown" to a floor or wall, which is simpler, faster, and cheaper.

Iterators are what they are - they suck performance-wise - but I've eliminated a number of distance comparisons using simple arithmetic and greatly simplified visibility issues. Offhand I'd say I'm getting as much as +100 FPS. Too early to tell.

Very likely I won't be adding back reflections, dynamic sector lighting, light and color bleeding, dynamic lights other than texture lights, and miscellaneous other effects present in Relighting. I'm not even sure I need an options menu :lol: . The lighting looks good for now, and I'm tweaking shadows. A 0.1 release for testing "soon."
cosmos10040
Posts: 181
Joined: Mon Dec 20, 2021 6:16 am
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Relighting v4.0165b - blurry shadows w/ rlassets

Post by cosmos10040 »

Im struggling to understand the differences between relighting and relit, please explain in layman terms and also a short video / gif showing side by side. Either way it looks very interesting.

Return to “Gameplay Mods”