Relighting v4.0152b - smarter lighting

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: 136
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.0141b - hotfix

Post by Hey Doomer_ »

WIWO for v4.0142b

I've tweaked routines that measure using sector lines by correctly stitching perimeter vertices: centroids, polygon areas, polylabels. Vertex arrays (clockwise or counterclockwise) replace sector Line arrays in those routines; lines are often not in order, reversed, etc. This and adding a little more light (the green Baron missiles are light source actor markers) create some interesting effects and generally more shadows (including dynamic sprite shadows):

https://i.postimg.cc/cL8frRpL/Screensho ... 043045.png
https://i.postimg.cc/50mBffZ5/Screensho ... 043145.png
https://i.postimg.cc/HsNQYZPN/Screensho ... 043247.png

This doesn't affect performance (if anything it's faster because it's looking at fewer vertices) and doesn't make areas darker for the sake of gloom. Indeed many areas that were dark previously are brighter or have added shadows that pop. None of this is perfect, some of it likely doesn't work at all, and this refactored code is still being tested. But so far so good.

The light source actors have small dynamic sector lights attached; the real difference they make is in baked sidedef lighting. This is noticeable in all the above, and in some areas e.g. MAP15 looks amazing. Since this version primarily corrects incorrectly stitched sector lines (an annoying map quirk but Doom maps aren't intended for a geometry class :) ), this is a maintenance release. So far testing is positive. I expect to have a release tomorrow.

Many thanks for your patience and interest.
User avatar
Dan_The_Noob
Posts: 741
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support

Re: Relighting v4.0141b - hotfix

Post by Dan_The_Noob »

that second screenshot has the dark floor problem? else looks like it is spreading light a little more evenly again.
User avatar
Hey Doomer_
Posts: 136
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.0142b

Post by Hey Doomer_ »

Posted v4.0142b

This is a maintenance update that fixes vertex issues with routines using them and above changes as noted.

I've also added extra lighting, adjusted sprite light levels to show when a sprite is in shadow, and exposed sidedef bake limits on the Settings menu, but these are minor features. Most of my time has been spent making the polylabel routine work with Doom's polygons (it's designed to label maps). I've been able to significantly reduce the number of probes to find the point of inaccessibility, and while not perfect it is faster and more accurate. Complex sectors that took thousands of probes to resolve the POI now take hundreds. Be aware that this depends on the map itself; maps with hundreds of sectors needing light will take longer to load. You can always try the Center or Centroid options in the menu in those cases.

Sidedef baked lights have not changed although more accurate placement of light sources affects them. An interesting example from MAP10:

https://i.postimg.cc/Y2QdYP3X/Screensho ... 165633.png

I have tested this with Ultimate Doom, TNT, Plutonia, and Heretic maps, in addition to Intensify, Hell_Crusher, Brutal Doom, and Honte... mostly to see if anything crashed and quickly check visuals. I did note that depending on setting Obsidian maps are slow AF. But I didn't try to load without Relighting.

Note that more light means more shadows. Reminder there is an option to turn off interpolation in Settings that may reduce flickering. 8-)
User avatar
Dan_The_Noob
Posts: 741
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support

Re: Relighting v4.0142b

Post by Dan_The_Noob »

don't suppose you have any ideas how to fix the shader affecting different renderstyles?

--EDIT--

couple of issues.
1. MAP01 imp fireballs on the first room causes entire sectors to turn fullbright individually. <<< most noticeable/distracting
2. I have a red armor bonus but with 4.0142b it has a green light
3. how do i turn off the lights added to pickups? not really a fan, and there doesn't seem to be any way to make them smaller/less bright.
4. *Min slider doesn't seem to work at all anymore? i turned it from 94 to 85 and lighting didn't change. Figured this one out, the curve is just much smoother now. 75 is a new 85.OK - turns out this was actually because i forgot i set the minimum area sizes to account for obsidian maps, either way it's ok now.
5. shader seems to be peaking at a much higher white value in MAP01 hallway now.
User avatar
Hey Doomer_
Posts: 136
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.0142b

Post by Hey Doomer_ »

Dan_The_Noob wrote: Fri Dec 02, 2022 4:19 pm don't suppose you have any ideas how to fix the shader affecting different renderstyles?

--EDIT--

couple of issues.
1. MAP01 imp fireballs on the first room causes entire sectors to turn fullbright individually. <<< most noticeable/distracting
2. I have a red armor bonus but with 4.0142b it has a green light
3. how do i turn off the lights added to pickups? not really a fan, and there doesn't seem to be any way to make them smaller/less bright.
4. *Min slider doesn't seem to work at all anymore? i turned it from 94 to 85 and lighting didn't change.
5. shader seems to be peaking at a much higher white value in MAP01 hallway now.
Not sure about the shader other than turning down the bleeding or changing the order of load. I'll have to look at that. I'm not that familiar with shader coding, and GZDoom's options seem limited.

The imp fireballs (and any missiles) light up a sector as they pass through them. I don't think that has ever changed. You can change the Size or Scale of the missile lights under Settings.

The red armor could be a GLDEFS issue. You could try changing the order of load. I assume the mod is using the first light it finds attached to the object. Maybe it's using the GZDoom lights file.

Any of the GLDEFS lights can be turned off in Settings. I think the pickups fall under the "Other" category, although it's been a while since I looked at that.

I'll check out the min slider. That did work the last time I checked, but I've been spending waaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaay too much time with geometry.

As for the whiteness in the hallway, that is likely the bleeding in the shader. There are a few Settings that affect that, but if you lower the bleeding value itself you should see it change. One of the side effects of color bleeding is that it tends to mimic bloom in making colors whiter, but this can be toned down.

You can't see it, but light placement in the hallway in MAP01 has also slightly changed with the optimized polylabel algorithm. It used to be near the imp and is now more or less in the center of the hallway, which is in front of the zombies, as I recall. Much of the lights didn't change location but enough did to subtlety affect most of the lighting.
User avatar
Dan_The_Noob
Posts: 741
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support

Re: Relighting v4.0142b

Post by Dan_The_Noob »

Dan_The_Noob wrote: Fri Dec 02, 2022 4:19 pm 1. MAP01 imp fireballs on the first room causes entire sectors to turn fullbright individually. <<< most noticeable/distracting
this one seems like a you fix.
Dan_The_Noob wrote: Fri Dec 02, 2022 4:19 pm 2. I have a red armor bonus but with 4.0142b it has a green light
this randomly fixes itself sometimes, sometimes its green sometimes red (???)
Dan_The_Noob wrote: Fri Dec 02, 2022 4:19 pm 3. how do i turn off the lights added to pickups? not really a fan, and there doesn't seem to be any way to make them smaller/less bright.
I will turn off GLDEF on "Other"i made all GLDEF smaller, seems to work ok now
Dan_The_Noob wrote: Fri Dec 02, 2022 4:19 pm 4. *Min slider doesn't seem to work at all anymore? i turned it from 94 to 85 and lighting didn't change. Figured this one out, the curve is just much smoother now. 75 is a new 85.OK - turns out this was actually because i forgot i set the minimum area sizes to account for obsidian maps, either way it's ok now.
Min slider seems to be a touch wider, but also I think the area sizes thing was throwing it way off. i found a good medium.
Dan_The_Noob wrote: Fri Dec 02, 2022 4:19 pm 5. shader seems to be peaking at a much higher white value in MAP01 hallway now.
I found the bleeding setting is just affecting it more now than before, i shrunk down bleed and saturation. found a good setting.
User avatar
Hey Doomer_
Posts: 136
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.0142b

Post by Hey Doomer_ »

Dan_The_Noob wrote: Fri Dec 02, 2022 5:00 pm
Dan_The_Noob wrote: Fri Dec 02, 2022 4:19 pm 1. MAP01 imp fireballs on the first room causes entire sectors to turn fullbright individually. <<< most noticeable/distracting
this one seems like a you fix.
Turn off "Dynamic Sectors" on Settings. At this time this also kills the door light switches.
User avatar
Dan_The_Noob
Posts: 741
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support

Re: Relighting v4.0142b

Post by Dan_The_Noob »

Hey Doomer_ wrote: Sat Dec 03, 2022 2:54 am Turn off "Dynamic Sectors" on Settings. At this time this also kills the door light switches.
ah, i see.
ill give that a try.
User avatar
Hey Doomer_
Posts: 136
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.0143b

Post by Hey Doomer_ »

Posted v4.0143b

This is a minor maintenance release that fixes a few bugs and improves lighting.
MAP10.png
MAP15.png
Sidedef baked lighting has been improved with no performance impact. The polylabel routine has been optimized to eliminate lines between points that cross internal sectors, greatly reducing the number of probes on a map. I've added a few lights here and there but nothing that impacts performance (such as a shadow on PSprite). Fake contrast has been removed, which makes much of the baked lights more natural looking. And of course bug fixes, although these are getting somewhat harder to find.
You do not have the required permissions to view the files attached to this post.
User avatar
Hey Doomer_
Posts: 136
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.0143b

Post by Hey Doomer_ »

WIWO for next maintenance release


I made a change in the last release to make the light source actors sector tall, but the LineTrace still looks from base to base when baking wall lights. This is now corrected.
map14.png
map10.png
e3m5.png
This correction is noticeable to a greater or lesser degree in the above screenshots. If the light is decorative e.g. attached to a Column actor, the light projects to the wall from origin using LineTrace. If the light is a sector light, however, it now loops from ceiling to floor (at least for now) and uses Vec3Diff instead of Vec3To for the resulting LineTrace parameters. This means, among other things, that intervening actors at WorldLoaded don't block light (map10, for example). Overall lighting is much more accurate.

The original code spawned non-decorative light actors at different positions in the sector, which I think resulted in some unnatural lighting. So this idea has progressed to better quality.

However as one can imagine the load time is increased depending on the number of sidedefs and number of lights. (This may fall under the "quality shadows" setting.) Here's the function to change in hd_relighting.zs for the curious (based on a function by Agent_Ash):

Code: Select all

	bool, double LightCheckSight(Actor light, Actor wall)
	{
	        if (!light || !wall) return false, double.infinity;
		int FLOOR = 0, CEILING = 1;

		// sector light that is tall as the sector
		if (light.Pos.z == light.CurSector.FloorPlane.ZAtPoint(light.Pos.xy))
		{
			for (double z = light.CurSector.CeilingPlane.ZAtPoint(light.Pos.xy); z > light.Pos.z; z--)
			{
				Vector3 delta = LevelLocals.Vec3Diff((light.Pos.x, light.Pos.y, z), wall.Pos);
				vector2 aim = (VectorAngle(delta.x, delta.y), -VectorAngle(delta.xy.Length(), delta.z) );

				if (!light.LineTrace(aim.x, delta.Length(), aim.y, TRF_THRUBLOCK|TRF_THRUHITSCAN|TRF_THRUACTORS))
				{
					return true, (delta.Length() == 0 ? 1 : delta.Length());
				}
			}
			return false, double.infinity;
		}
		else // decorative light
		{
			Vector3 delta = light.Vec3To(wall);
			vector2 aim = (VectorAngle(delta.x, delta.y), -VectorAngle(delta.xy.Length(), delta.z) );

			return !light.LineTrace(aim.x,delta.Length(),aim.y,TRF_THRUBLOCK|TRF_THRUHITSCAN|TRF_THRUACTORS), (delta.Length() == 0 ? 1 : delta.Length());
		}
	}

You do not have the required permissions to view the files attached to this post.
User avatar
Hey Doomer_
Posts: 136
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.0144b - more accurate lights

Post by Hey Doomer_ »

Posted v4.0144b with optimizations and a similar correction for shadows. This should not affect performance, although as usual in maps with an exceptional number of sectors there may be an extended loading time.

One thing to note (this has been in place for a few versions) is that sprites not only cast shadows but are cast in shadow. This mild effect can be seen here:

https://i.postimg.cc/Hxv1NLFp/sprites-in-shadow.gif

Not expensive. Looks cool. 8-)

Note the "shadow side" of the sprite is slightly darker than the side facing the light. This is also noticeable on the box of shells in the background and any other sprite. Hopefully this kind of thing and the baked lighting detract from the obvious flaws of FLATSPRITE. Pity it isn't possible to clip or at least stick them to the floor... Can't be helped. :|

Many thanks for your interest.
User avatar
Scripten
Posts: 854
Joined: Sat May 30, 2009 9:11 pm

Re: Relighting v4.0144b - more accurate lights

Post by Scripten »

I wonder if the voxel pack would adapt well to this or not. Either way, excited to try out the new version after work and in-person gaming tonight.
User avatar
Hey Doomer_
Posts: 136
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.0144b - more accurate lights

Post by Hey Doomer_ »

Scripten wrote: Wed Dec 07, 2022 10:22 am I wonder if the voxel pack would adapt well to this or not. Either way, excited to try out the new version after work and in-person gaming tonight.
Sprite shadows do not work with voxels (they are converted to models and are not sprites), although pitching them will be possible in future and that may change. Shadows would have to be disabled in Settings, but this doesn't affect baked or colored lighting.
cosmos10040
Posts: 85
Joined: Mon Dec 20, 2021 6:16 am
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Relighting v4.0144b - more accurate lights

Post by cosmos10040 »

Forgot to report but I received a vm abort with last three versions on drpg + drla

VM execution aborted: array access out of bounds. Negative current index = -1

Called from hd_relighting_EventHandler.WorldLoaded at relighting v4.0144b.pk3:zscript/hd_relighting.zs, line 810
]
Zaibatsu64
Posts: 6
Joined: Sun Nov 27, 2022 9:35 am

Re: Relighting v4.0144b - more accurate lights

Post by Zaibatsu64 »

This is a fantastic mod. Thank you very much for your continued efforts, it's getting better and better with every new version.

In the latest version of the mod, the ghost lights now move about the map in a random fashion. I wasn't sure if this was a bug or was intentional. If intentional, would it be possible to have a toggle for this behaviour?

I have some suggestions and feedback. The coloured sector lighting looks great, and I'd like to see more of it if possible. I think it would look good if coloured sectors affected the colour of neighbouring sectors to create a gradation.



The colour of the light in a sector could perhaps be influenced by sampling the colour of the walls and the flats. It would be good if the colour of the sky had a strong influence on the colour of the light. In the example below, the red sky is the only light source so everything in the scene should ideally be tinted red. Perhaps a toggle to control the intensity would work well.



Another suggestion would be to allow the user to select an average colour for the sectors, so it could be adjusted on a per-map basis.

Please note that I have no idea how feasible any of my suggestions are, and I'm not trying to make any demands of your time.

Thanks again for an excellent mod!

Return to “Gameplay Mods”