Software renderer's lighting in GZDoom (and Zandronum)

Discuss anything ZDoom-related that doesn't fall into one of the other categories.
User avatar
Enjay
 
 
Posts: 26517
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Software renderer's lighting in GZDoom (and Zandronum)

Post by Enjay »

I have to admit, it always bugged me that 0 darkness in Doom wasn't really 0. Not saying that an emulation of the original lighting shouldn't try to have the Doom behaviour. It's just that I personally find it unwelcome from a mapping POV.

Oh, and
Kate wrote:Actually, I decided to do a little more experimentation, and I found that 0.5882 is a lot closer to what software probably used as a lower cap.
...
we find that 7 / 119 = 0.05882352941176470588235294117647, or 0.05882 rounded. so the lowest colormap is about 5.8% as bright as the fullbright colormap.
I assume that the 0.5882 is a typo.
User avatar
Kate
... in rememberance ...
Posts: 2975
Joined: Tue Jul 15, 2003 8:06 pm

Re: Software renderer's lighting in GZDoom (and Zandronum)

Post by Kate »

yeah it is, I missed a 0 in there, should be 0.05882.

And one of the serious problems with making the darkest lightmap total darkness is that doom2 actually *relies* on you being able to see in the dark in quite a few areas, for example the dark rooms on map10 refueling base wind up becoming "fumbling around in the dark searching for doors" rooms, and on map12 the factory you would *never* be able to find the BFG in the far corner. So for gameplay purposes, having total blackness is *really* a bad idea since it means you have NO clue where you're going or what is shooting at you until it's literally in front of your face.
User avatar
Enjay
 
 
Posts: 26517
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Software renderer's lighting in GZDoom (and Zandronum)

Post by Enjay »

I agree. That's why I said I don't like it from a mapping PoV. Existing maps that rely on you being able to see something at 0 light would be hampered by being in genuine 100% darkness. However, from an editing perspective, not being able to create somewhere that has absolutely no light even if that's exactly what you want and what would work in a particular situation is a limitation - albeit not one that has a huge implication most of the time. In fact, Doom's overall non-linear light-to-dark progression is pretty wacky too.
Gez
 
 
Posts: 17833
Joined: Fri Jul 06, 2007 3:22 pm

Re: Software renderer's lighting in GZDoom (and Zandronum)

Post by Gez »

If you want some place to be fully dark, you can give it black textures in addition to 0 light. Add a #000001 fog color (absurdly dark blue) if so you want.

You can also modify the COLORMAP, but that'll only affect software.
User avatar
Enjay
 
 
Posts: 26517
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Software renderer's lighting in GZDoom (and Zandronum)

Post by Enjay »

Gez wrote:If you want some place to be fully dark, you can give it black textures
Heh, I have actually done that in the past. It's not as convenient or as flexible as being able to do it just with sector light levels though.
Gez
 
 
Posts: 17833
Joined: Fri Jul 06, 2007 3:22 pm

Re: Software renderer's lighting in GZDoom (and Zandronum)

Post by Gez »

Speaking of maths, here's how the colormaps are generated:

Code: Select all

#define	NUMLIGHTS		32
/*
=====================
=
= RF_BuildLights
=
= 0 is full palette
= NUMLIGHTS	and NUMLIGHTS+1 are all black
=
=====================
*/

void	RF_BuildLights (void)
{
	int		l,c;
	int		red,green,blue, ri, gi, bi;
	byte	*palsrc;
	short	color12,color15;

	for (l=0;l<NUMLIGHTS;l++)
	{
//printf ("%i.",NUMLIGHTS-l);
		palsrc = palette;
		for (c=0;c<256;c++)
		{
			red = *palsrc++;
			green = *palsrc++;
			blue = *palsrc++;

			red = (red*(NUMLIGHTS-l)+NUMLIGHTS/2)/NUMLIGHTS;
			green = (green*(NUMLIGHTS-l)+NUMLIGHTS/2)/NUMLIGHTS;
			blue = (blue*(NUMLIGHTS-l)+NUMLIGHTS/2)/NUMLIGHTS;

			lightpalette[l][c] = BestColor(red,green,blue,palette,0,255);
		}

		memcpy (screen,lightpalette[l],256);
		screen+=320;
		memcpy (screen,lightpalette[l],256);
		screen+=320;
		memcpy (screen,lightpalette[l],256);
		screen+=320;
	}
}
(I snipped out the unused code for Doom Alpha's highcolor modes.)

So the formula for the darkest colormap range is (where l = 31, so NUMLIGHTS - l is 1) is:

Code: Select all

(intensity + 16) / 32
So an intensity of 0 yields 0.5, and an intensity of 255 yields 8.46875.
User avatar
Kate
... in rememberance ...
Posts: 2975
Joined: Tue Jul 15, 2003 8:06 pm

Re: Software renderer's lighting in GZDoom (and Zandronum)

Post by Kate »

also, found a genuine bug here:
Spoiler:
Shaded sprites aren't being rendered with their colors at all.
Post Reply

Return to “General”