Page 1 of 1

Attn. spotlights do not illuminate wall decals

PostPosted: Wed Feb 07, 2018 1:27 pm
by Nash
Image

Thread title. Attenuated spotlights are not affecting decals.

Re: Attn. spotlights do not illuminate wall decals

PostPosted: Thu Feb 08, 2018 2:20 am
by Graf Zahl
Decals are lit like sprites by dynamic lights. I think it'd be better to light them like walls - but that may make some older systems choke. Fortunately this should be doable by reusing the wall's light lists so it wouldn't put more drag on the CPU side where it'd really hurt.

Re: Attn. spotlights do not illuminate wall decals

PostPosted: Thu Feb 08, 2018 4:31 am
by dpJudas
Nash, did you use Gutawer's flashlight mod to get that screenshot? Back when I did the initial spotlight support the decals blinked whenever you moved. Once stopped, there'd be 50% chance it showed the right light and 50% chance it would be black like on the screenshot.

At the time I concluded it was probably a general bug not directly caused by the spotlights as it was also happening when the flashlight was a normal point light. The sprite light calculate code does take spot lights into account and it worked just fine when I tested it on things in e1m1 - I'm not entirely sure what makes decals so different.

Re: Attn. spotlights do not illuminate wall decals

PostPosted: Thu Feb 08, 2018 5:39 am
by Nash
dpJudas wrote:Nash, did you use Gutawer's flashlight mod to get that screenshot


No, it's my own implementation. But I guess there's only so many ways you can attach a spotlight to a player so I guess you could say it's similar.

Code: Select allExpand view
class LADLightSource DynamicLight
{
    
// <snip>

    
override void BeginPlay(void)
    {
        
Super.BeginPlay();

        
// initialize dynamic light stuff
        
args[0] = def_r;
        
args[1] = def_g;
        
args[2] = def_b;
        
args[3] = def_intensity;
        
bAttenuate bool(def_atten);
        
bDontLightSelf bool(def_dontlightself);
        
bSpot bool(def_spot);
        if (
bSpot)
        {
            
SpotInnerAngle def_spotinnerangle;
            
SpotOuterAngle def_spotouterangle;
        }
    }
}
 


The light is then SetOrigin'd inside my player pawn's Tick().

Moving or not doesn't blink the spotlight - it stays black permanently.

Re: Attn. spotlights do not illuminate wall decals

PostPosted: Fri Feb 09, 2018 5:53 pm
by dpJudas
I've found the general source of the problem here. gl_SetDynSpriteLight does the following check:

Code: Select allExpand view
if (light->visibletoplayer &&
    !(light->flags2&MF2_DORMANT) &&
    (!(light->lightflags&LF_DONTLIGHTSELF) || light->target != self) &&
    !(light->lightflags&LF_DONTLIGHTACTORS))

If any of those four conditions are false, then the light does not apply to the sprite/decal. The problem is that light->target is null, self is always null for decals and the DONTLIGHTSELF flag is set for this light. That makes the third clause always false.

What is the correct fix for this? add "|| self == nullptr" to the third check?

Re: Attn. spotlights do not illuminate wall decals

PostPosted: Fri Feb 09, 2018 6:08 pm
by dpJudas
Decided to just add the !self check. This should be working now.

Re: Attn. spotlights do not illuminate wall decals

PostPosted: Fri Feb 09, 2018 6:22 pm
by Graf Zahl
The proper fix here should be, as I already said, to change decal lighting to use the wall's light list. As long as that isn't done, that self check is indeed the correct thing to do.

Re: Attn. spotlights do not illuminate wall decals

PostPosted: Fri Feb 09, 2018 6:51 pm
by dpJudas
I don't really disagree with you on that. It is just that I assume there was a reason you didn't make it use the light list in the first place - i.e. something needs to be fixed and/or adjusted for that to become a possibility. So I went for at least fixing the blackness bug.

Re: Attn. spotlights do not illuminate wall decals

PostPosted: Sat Feb 10, 2018 4:51 am
by Graf Zahl
dpJudas wrote:I don't really disagree with you on that. It is just that I assume there was a reason you didn't make it use the light list in the first place


Surely there is. When this code was written, there was no shader based lighting and using a light texture to illuminate sprites is not particularly well doable...
It just was never changed because with point lights it never became a serious issue.

Re: Attn. spotlights do not illuminate wall decals

PostPosted: Wed Jun 13, 2018 7:59 am
by Caligari87
bumping because I got a fresh report of this problem on DarkDoomZ, but I'm pretty sure it's not my mod.

Glaice wrote:I have noticed that with blood decals from custom gore mods don't always play nice, they sometimes show up as black and sometimes normally.

Screenshot example. GZDoom 3.4.0 64 bit used with a ATI Sapphire RX 480 8 GB video card under Windows 7 64 bit.


Image

8-)

Re: Attn. spotlights do not illuminate wall decals

PostPosted: Wed Jun 13, 2018 8:02 am
by Graf Zahl
Don't expect any quick results here. Decal lighting should be done properly. Currently it just uses sprite lighting which is insufficient.

Re: Attn. spotlights do not illuminate wall decals

PostPosted: Wed Jun 13, 2018 12:40 pm
by Glaice
In my situation, the blood isn't always black but sometimes flickers between normal and black when moving my perspective around, sometimes not at all.

Re: Attn. spotlights do not illuminate wall decals

PostPosted: Wed Jun 13, 2018 1:00 pm
by Graf Zahl
Ok. But like I said, the decal lighting is rather crappy right now and needs some serious improvement, not just a hacky patch to make this case work.