Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doom does not have sector brightness 256 #499

Closed
hawkwind3 opened this issue Nov 14, 2020 · 6 comments
Closed

Doom does not have sector brightness 256 #499

hawkwind3 opened this issue Nov 14, 2020 · 6 comments
Labels

Comments

@hawkwind3
Copy link

I noticed this in Doom_misc.cfg ...

sectorbrightness
{
256; 240; 224; 208; 192; 176; 160; 144;
128; 112; 96; 80; 64; 48; 32; 16; 0;
}

It should read ...

sectorbrightness
{
255; 240; 224; 208; 192; 176; 160; 144;
128; 112; 96; 80; 64; 48; 32; 16; 0;
}

i.e. 255 insead of 256. easily fixed.

@biwa
Copy link
Collaborator

biwa commented Nov 14, 2020

256 is a valid value. 240 and 255 are the same light value (for ports that use the vanilla way to calculate light values). See https://github.com/chocolate-doom/chocolate-doom/blob/df1837c1210b85ebc4ec84e42b5edb2001c66463/src/doom/r_segs.c#L96

@biwa biwa closed this as completed Nov 14, 2020
@biwa biwa added the no a bug label Nov 14, 2020
@hawkwind3
Copy link
Author

hawkwind3 commented Nov 14, 2020

That link did not help me. I guess the DeepSea and Eureka teams got it wrong then. They have their light levels from 0 to 255. A total of 256 light levels. 0 to 256 means there are 257 light levels ?

@biwa
Copy link
Collaborator

biwa commented Nov 14, 2020

Vanilla Doom does this:

  1. bit-shift the brightness to the right by 4 (which is equivalent to taking the whole number part of dividing the brightness by 16)
    • for lines that are aligned to the grid horizontally: subtract 1 from the computed light value (this is where the brightness of 256 matters)
    • for lines that are aligned to the grid vertically: add 1 to the computed light value
  2. clamp the light value between 0 and 15

For a line that's horizontally on the grid with and a sector brightness of 255:

  1. bit-shift: 255 >> 4 = 15
  2. subtract 1: 15 - 1 = 14
  3. clamp between 0 and 15: 14 <-- final light value

For a line that's horizontally on the grid with and a sector brightness of 256:

  1. bit-shift: 256 >> 4 = 16
  2. subtract 1: 16 - 1 = 15
  3. clamp between 0 and 15: 15 <-- final light value

Here's how it looks in Chocolate Doom:

255_256

@hawkwind3
Copy link
Author

hawkwind3 commented Nov 14, 2020 via email

@biwa
Copy link
Collaborator

biwa commented Nov 14, 2020

Example WAD is attached. I used GRAY1 as a texture to make it more clear. The left half of the wall belongs to a sector with 256 brightness, the right half to a sector with 255 brightness. Note that the lighting also depends on your distance to the line, so if you're walking towards the line you'll see the right half "flip" to a higher brightness.

255-256.zip

@hawkwind3
Copy link
Author

hawkwind3 commented Nov 14, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants