Software renderer's lighting in GZDoom (and Zandronum)

Discuss anything ZDoom-related that doesn't fall into one of the other categories.

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

Postby Enjay » Tue Jan 22, 2013 11:11 am

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
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

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

Postby Kate » Tue Jan 22, 2013 1:08 pm

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
Kate
... in loving memory ...
 
Joined: 16 Jul 2003

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

Postby Enjay » Tue Jan 22, 2013 1:51 pm

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.
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

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

Postby Gez » Tue Jan 22, 2013 2:11 pm

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.
Gez
 
 
 
Joined: 06 Jul 2007

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

Postby Enjay » Tue Jan 22, 2013 2:25 pm

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.
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

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

Postby Gez » Wed Jan 23, 2013 4:39 am

Speaking of maths, here's how the colormaps are generated:
Code: Select allExpand view
#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 allExpand view
(intensity + 16) / 32


So an intensity of 0 yields 0.5, and an intensity of 255 yields 8.46875.
Gez
 
 
 
Joined: 06 Jul 2007

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

Postby Kate » Tue Jan 29, 2013 9:38 am

also, found a genuine bug here:

Spoiler:

Shaded sprites aren't being rendered with their colors at all.
User avatar
Kate
... in loving memory ...
 
Joined: 16 Jul 2003

Previous

Return to General

Who is online

Users browsing this forum: No registered users and 4 guests