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: 395
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.0156b - many improvements

Post by Hey Doomer_ »

DarkkOne wrote: Sun Mar 12, 2023 9:15 pm Would it be possible to prioritize light-sources originating at the player, or at least weighing them more heavily? Often some other light source that seems less bright will create shadows while the Flashlight++ flashlight doesn't. While those other sources may be "brighter," I wouldn't be surprised if it ends up looking better if light sources either originating at the player, or that are between the player and the lit object, are weighted more, or are just given priority for creating shadows.
Testing keeping a flashlight as one of the light sources for the next version. This is cheap. :|

I've tried this before and abandoned it from comments in the code, but I've added this back with some tweaks. Example that shows the effect. I'll have to look at this in a little detail, since I don't remember why I removed this code. But that's the idea.
DarkkOne
Posts: 258
Joined: Mon Jun 06, 2016 11:26 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Widnows 11
Graphics Processor: nVidia with Vulkan support

Re: Relighting v4.0156b - many improvements

Post by DarkkOne »

I think the addition of stretched wall shadows probably changed it a lot too. Those are a lot more dramatic and noticeable than the basic floor shadows were before, and that probably has a big impact on how flashlight shadows look and "feel" now. Hopefully it works out!
cosmos10040
Posts: 164
Joined: Mon Dec 20, 2021 6:16 am
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Relighting v4.0156b - many improvements

Post by cosmos10040 »

DarkkOne wrote: Sun Mar 12, 2023 9:15 pm Would it be possible to prioritize light-sources originating at the player, or at least weighing them more heavily? Often some other light source that seems less bright will create shadows while the Flashlight++ flashlight doesn't. While those other sources may be "brighter," I wouldn't be surprised if it ends up looking better if light sources either originating at the player, or that are between the player and the lit object, are weighted more, or are just given priority for creating shadows.
I noticed this too with flashlight ++ would be nice if it's compatible.
User avatar
Hey Doomer_
Posts: 395
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.0156b - many improvements

Post by Hey Doomer_ »

WIWO for v4.0157b

Code: Select all

v4.0157b

3/14 - clamped light level to avoid DIV/0 error
3/15 - added check for no sprite in shadow caster
3/16 - added Y-shrinking over drop offs close to player view

Since some DECORATE and ZScript monsters begin with a placemarker sprite (TNT1A0) that returns a height of zero, I added those back in for v4.0156b to allow those items to cast shadows. This has caused a few mods such as Beautiful Doom to generate casters when the caster doesn't have a sprite. To avoid endless exception coding I've fixed that in this version by adding a check for TNT1A0 in the shadow itself. So far it appears that everything with a sprite generates a shadow, and TNT1A0 casters are destroyed if they don't use a sprite. I'd like to overhaul this spawning code to get rid of all exceptions if possible. 8-)

While sprites can't be clipped, the overhang effect can perhaps be minimized to be less jarring. Generally shadows sticking out over edges are very noticeable when overhead (a problem addressed in v4.0156b) to the player level. Triangle stairs at MAP01 start are a good example of acceptable overhang, where shadows appear to be going down the stairs. To make this less obvious at eye level I've tried a "clipcheck" LineTrace function to shrink overhanging shadows.

This effect can be seen here.

If you look closely you can see floor shadows shrink when getting too close to edges of the nukage bridge. This isn't perfect as I've taken shortcuts to avoid lag. Not sure how I feel about this yet.

Edit

After commenting out all exception coding, this is what is logged for TNT1A0 casters with Beautiful Doom:
Spoiler:
The BD explosive barrels have a sprite. Items without a sprite (and no shadow) are destroyed, which greatly reduces the number of thinkers and improves performance and compatibility. Still testing mods, but this approach should work universally.
User avatar
Kanok
Posts: 6
Joined: Fri Mar 17, 2023 3:40 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Relighting v4.0156b - many improvements

Post by Kanok »

I just joined the forums and I wanted to say, I love what I'm seeing. Even tried it out and it's amazing. However, I can't seem to get it to work with Project Brutality. I get the same error that Ginji23 got about the division by 0 and I did change the code to what you suggested, but did not work. I am using the most up-to-date version of PB. If it can't be done, that's alright, but I figured I'd mention it if it wasn't already. Keep up the great work!
User avatar
Hey Doomer_
Posts: 395
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.0156b - many improvements

Post by Hey Doomer_ »

Progress on v4.0157b

Code: Select all

v4.0157b

3/14 - clamped light level to avoid DIV/0 error
3/15 - added check for no/null sprite in shadow caster, deleted exception coding
3/16 - added Y-shrinking over high drop offs close to player view
3/17 - added light size adjustment based on color settings
3/17 - checks for caster lights, bug fixes for shadow pitching of long shadows (bug fix)
3/17 - check for 3d distance of light (performance)
3/17 - search animated texture lumps instead of list
Lots of progress.

I've eliminated almost all hard-coded items with the exception of flashlights (working on that, since these are inventory items), making this that much closer to universal. :D Lots of code cleanup and simple bug fixes, especially in the long shadow code. Since I now pitch these shadows, I use the LineTrace HitLocation data to get the Z-height where a shadow hits a far wall. Priority is given to flashlights and missiles. It's early in testing and quite imperfect, but here are two examples of what this looks like with these shadows hugging walls:

E2M2
MAP10

Sprites still suck of course - they don't bend, fold, or mutilate - but generally it looks pretty cool. 8-) Haven't looked at alpha as much, so there is more work to do.

I fixed a few bugs in the shadow thinker code, and while these improve performance it's not dramatic. The big improvement should be in eliminating shadow generators without a sprite to cast a shadow, more of a problem in complex gameplay mods. Reducing the number of thinkers improves performance.

I've also linked the size of dynamic lights based on the GLDEF files to menu color preferences, another universal improvement. Doom is a brown and green game, but that's not true for all games and mods (and users have their own preferences), and tweaking these values can now (very little testing) tweak dynamic light size. This was more of an afterthought on my part and isn't that dramatic, since dynamic lights lower framerates.

Many many thanks for the interest, comments, and suggestions. I appreciate it!

Release "soon."
User avatar
Hey Doomer_
Posts: 395
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.0156b - many improvements

Post by Hey Doomer_ »

Kanok wrote: Sat Mar 18, 2023 12:42 am I just joined the forums and I wanted to say, I love what I'm seeing. Even tried it out and it's amazing. However, I can't seem to get it to work with Project Brutality. I get the same error that Ginji23 got about the division by 0 and I did change the code to what you suggested, but did not work. I am using the most up-to-date version of PB. If it can't be done, that's alright, but I figured I'd mention it if it wasn't already. Keep up the great work!
Interesting. Is it the exact same error?
User avatar
Kanok
Posts: 6
Joined: Fri Mar 17, 2023 3:40 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Relighting v4.0156b - many improvements

Post by Kanok »

This was the error in full:

TITLEMAP - PB_Introduction
VM execution aborted: division by zero.
Called from hd_relighting_EventHandler.WorldLoaded at relighting v4.0156b.pk3:zscript/hd_relighting.zs, line 1270

To be clear, I disabled everything else except for PB and relighting to be sure there wasn't something else messing with it. Hope this helps!
User avatar
Hey Doomer_
Posts: 395
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.0156b - many improvements

Post by Hey Doomer_ »

Kanok wrote: Sat Mar 18, 2023 1:04 pm This was the error in full:

TITLEMAP - PB_Introduction
VM execution aborted: division by zero.
Called from hd_relighting_EventHandler.WorldLoaded at relighting v4.0156b.pk3:zscript/hd_relighting.zs, line 1270

To be clear, I disabled everything else except for PB and relighting to be sure there wasn't something else messing with it. Hope this helps!
That's very helpful, thanks! I'll check it out!

Edit

I don't see this error with PB, but I may not be on the same map. Try changing the line to this:

Code: Select all

						ptr.Scale.Y = clamp(sec.LightLevel / (d + 0.1), 0.0, r);
Very likely the map doesn't have any indoor lights or something of that nature that makes the variable d a zero (0 divided by a number is 0). See if the above fixes the problem.

I haven't tested Relighting with Project Brutality (a BD variant of sorts). These bug reports are very helpful - obvious as they always seem - given the number of mods and games. (Are there many Heretic mods, for example?) Many thanks for bringing this up.
User avatar
Kanok
Posts: 6
Joined: Fri Mar 17, 2023 3:40 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Relighting v4.0156b - many improvements

Post by Kanok »

I think the map in question is the title screen, not sure, but also, I changed it and it went to a different line now. It now says:

TITLEMAP - PB_Introduction
VM execution aborted: division by zero.
Called from hd_relighting_EventHandler.WorldThingSpawned at relighting v4.0156b.zip:zscript/hd_relighting.zs, line 1921

Not sure what's going on and I am excited to try your mod, but for now, it's not happening. Guess PB is just not wanting to play nice with your mod for me. lol
User avatar
Hey Doomer_
Posts: 395
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.0156b - many improvements

Post by Hey Doomer_ »

Progress v4.0157b - shadow corrections

Shadows now cast correctly by pitch and distance, and I've added shadows that may cast on upper textures that are not doors, although that should be less common. An obvious addition is a check for the Z-heights of the sector wall vs. dimensions of the shadow itself. This prevents "floating shadows" for things that do not float. Example.

Without this correction the shadow of the armor bonus on the right appears in the middle of the wall between the walkway and building. Still testing, but these wall shadows are looking better all the time. 8-)
User avatar
Hey Doomer_
Posts: 395
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.0156b - many improvements

Post by Hey Doomer_ »

Progress v4.0157b - shadow alerts monsters

Code: Select all

v4.0157b

3/14 - clamped light level to avoid DIV/0 error
3/15 - added check for no/null sprite in shadow caster, deleted exception coding
3/17 - added light size adjustment based on color settings
3/17 - checks for caster lights, bug fixes for shadow pitching of long shadows (bug fix)
3/17 - check for 3d distance of light (performance)
3/17 - search animated texture lumps instead of list
3/20 - added wall shadow alerts
Many bug fixes and small performance improvements.

An obvious addition in testing mods and maps is alerting monsters when your shadow appears on a far wall. This can be seen here. While the player is hidden from direct sight of the imp on the other side of the crate, as soon as the player shadow appears on the wall the monster is alerted. 8-) I was surprised a few times when this happened. I was planning to release this morning, but I'll be testing this feature tweak first. So far the wall shadow code is simple in PostBeginPlay:

Code: Select all

		if (self.args[1]) players[consoleplayer].mo.A_AlertMonsters(512, AMF_TARGETEMITTER);
If the shadow is the player, args[1] is true. That's it. I'm not checking if any monsters can actually see the shadow, etc. So that kind of thing. But so far it works and brings an extra dimension to the wall shadows.

I have abandoned the "clip check" to shorten shadows near an edge as too expensive. Ah well.
User avatar
Hey Doomer_
Posts: 395
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.0156b - many improvements

Post by Hey Doomer_ »

Release v4.0157b - tomorrow

This is very close, as the Brutal Doom zombies say.

Code: Select all

v4.0157b

3/14 - clamped light level to avoid DIV/0 error
3/15 - added check for no/null sprite in shadow caster, deleted exception coding
3/17 - added light size adjustment based on color settings
3/17 - checks for caster lights, bug fixes for shadow pitching of long shadows (bug fix)
3/17 - check for 3d distance of light (performance)
3/17 - search animated texture lumps instead of list
3/18 - added wall shadow alerts
3/21 - added "Death" decoration state spotlights
I've done a lot of code cleanup, separating actor and other classes into their own files. This makes it easier for me to maintain if nothing else. I also added an extra light to "Death" decoration items, most notably the explosive barrels in Doom. Not as obnoxious as PrBoom, with an example here.

I also (finally) completely revamped the menu system into submenus with helpful explanations of what different options tweak. I don't know how every option might affect different mods and games, so I've kept this all rather brief. Hopefully that will make more sense to users.

Again almost all exception coding as been removed except for sector specials and a few flashlight class names. So far so good, although there are sprite items (weapon drops in Brutal Doom) that do not cast shadows.
User avatar
hitmanx
Posts: 424
Joined: Sat Dec 18, 2004 4:58 am

Re: Relighting v4.0156b - many improvements

Post by hitmanx »

I think this mod is just getting better and better, except for one change that you made. I don't think the way you've done the wall shadows is as realistic anymore, I don't think the shadow would end on the floor before hitting the wall, I'd say that would require 2 light sources.

I think in order versions the floor shadow stretched out until it reached the wall if the light source was low enough.

That's my only critisicm haha, keep up the good work.
User avatar
Hey Doomer_
Posts: 395
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.0156b - many improvements

Post by Hey Doomer_ »

More Progress v4.0157b - ceiling shadows

Code: Select all

v4.0157b

3/14 - clamped light level to avoid DIV/0 error
3/15 - added check for no/null sprite in shadow caster, deleted exception coding
3/17 - added light size adjustment based on color settings
3/17 - checks for caster lights, bug fixes for shadow pitching of long shadows (bug fix)
3/17 - check for 3d distance of light (performance)
3/17 - search animated texture lumps instead of list
3/18 - added wall shadow alerts
3/21 - added "Death" decoration state spotlights
3/22 - added ceiling shadows for SPAWNCEILING actors
An obvious addition: ceiling shadows for hanging corpses, meat, and other sprite decor. These actors already have shadows and so this was a matter of tweaking a single function and one or two variables. Still tweaking it, but here's the idea:

Example

It does clash with some of the shadow code optimization, which I'm testing. Another delay in releasing the next version.

Return to “Gameplay Mods”