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

support BRGHTMPS lump from Doom Retro #846

Merged
merged 28 commits into from
Jan 11, 2023
Merged

Conversation

rfomin
Copy link
Collaborator

@rfomin rfomin commented Dec 16, 2022

Tested on this lump: https://github.com/bradharding/doomretro/blob/master/res/BRGHTMPS

I used u_scanner.c but I think we could use it in Crispy too? (potential support for UMAPINFO).

src/r_bmaps.c Outdated Show resolved Hide resolved
@fabiangreffrath
Copy link
Owner

Thanks for starting the work on this! I wonder if we should parametrize our internal default values in a similar way?

@rfomin
Copy link
Collaborator Author

rfomin commented Dec 16, 2022

Thanks for starting the work on this! I wonder if we should parametrize our internal default values in a similar way?

Add BRGHTMPS lump to autoload folder? Or do you mean reorganize the arrays in r_bmaps.c?

@fabiangreffrath
Copy link
Owner

fabiangreffrath commented Dec 16, 2022

I'm not convinced of using the autoload folder for such features. Think of all the bfgdoom2.wad and freedoom2.wad and miniwad.wad and doom2_19.wad and udoom.wad etc IWAD files around.

I think we should handle it as we do for colored blood. Provide an internal default and if a PWAD provides its own, use this without asking.

@rfomin
Copy link
Collaborator Author

rfomin commented Dec 16, 2022

Think of all the bfgdoom2.wad and freedoom2.wad and miniwad.wad and doom2_19.wad and udoom.wad etc IWAD files around.

That's why we have doom-all

Provide an internal default and if a PWAD provides its own, use this without asking.

This is how it works in the current PR. Maybe we should somehow reorganize the data in r_bmaps.c.

@fabiangreffrath
Copy link
Owner

That's why we have doom-all

Hm, true.

Maybe we should somehow reorganize the data in r_bmaps.c.

That's exactly what I wanted to suggest in the first place. 😁

@fabiangreffrath
Copy link
Owner

This is how it works in the current PR.

You can still disable the feature even if the lump is provided. I think this is handled different for blood color and thing translucency.

Maybe we should somehow reorganize the data in r_bmaps.c.

Not sure if this works for anything else than texture brightmaps, though.

@fabiangreffrath
Copy link
Owner

Could you try this?

diff --git a/src/m_menu.c b/src/m_menu.c
index cd203da..19c5ec1 100644
--- a/src/m_menu.c
+++ b/src/m_menu.c
@@ -4030,12 +4030,13 @@ enum {
 static void M_UpdateStrictModeItems(void)
 {
   extern boolean deh_set_blood_color;
+  boolean wad_set_brightmaps = (W_CheckNumForName("BRGHTMPS") >= 0);
   // map_player_coords
   DISABLE_STRICT(auto_settings1[auto1_coords]);
   DISABLE_ITEM(strictmode || deh_set_blood_color, enem_settings1[enem1_colored_blood]);
   DISABLE_STRICT(enem_settings1[enem1_flipcorpses]);
   DISABLE_STRICT(gen_settings4[gen4_realtic]);
-  DISABLE_STRICT(gen_settings2[gen2_brightmaps]);
+  DISABLE_ITEM(strictmode || wad_set_brightmaps, gen_settings2[gen2_brightmaps]);
   DISABLE_STRICT(gen_settings3[gen3_level_brightness]);
   DISABLE_ITEM(strictmode && demo_compatibility, gen_settings1[gen1_trans]);
   DISABLE_STRICT(gen_settings3[gen3_palette_changes]);
diff --git a/src/m_misc.c b/src/m_misc.c
index 7527c1e..c9f678d 100644
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -106,7 +106,7 @@ extern int opl_gain;
 extern int midi_player_menu;
 extern boolean demobar;
 extern boolean smoothlight;
-extern boolean brightmaps;
+extern boolean default_brightmaps;
 extern boolean r_swirl;
 extern int death_use_action;
 extern boolean palette_changes;
@@ -260,7 +260,7 @@ default_t defaults[] = {
 
   {
     "brightmaps",
-    (config_t *) &brightmaps, NULL,
+    (config_t *) &default_brightmaps, NULL,
     {0}, {0,1}, number, ss_gen, wad_yes,
     "1 to enable brightmaps for textures and sprites"
   },
diff --git a/src/r_bmaps.c b/src/r_bmaps.c
index cfd234c..76ff7b1 100644
--- a/src/r_bmaps.c
+++ b/src/r_bmaps.c
@@ -26,7 +26,7 @@
 #include "m_misc2.h"
 #include "u_scanner.h"
 
-int brightmaps;
+int brightmaps, default_brightmaps;
 
 // [crispy] brightmap data
 
@@ -1093,6 +1093,9 @@ static const byte *R_BrightmapForTexName_Lump(const char *texname)
 void R_InitBrightmaps ()
 {
 	int lump = W_CheckNumForName("BRGHTMPS");
+
+	brightmaps = default_brightmaps;
+
 	if (lump >= 0)
 	{
 		const char *data = W_CacheLumpNum(lump, PU_CACHE);
@@ -1104,6 +1107,9 @@ void R_InitBrightmaps ()
 		R_BrightmapForSprite = R_BrightmapForSprite_None;
 		R_BrightmapForFlatNum = R_BrightmapForFlatNum_None;
 		R_BrightmapForState = R_BrightmapForState_None;
+
+		brightmaps = true;
+
 		return;
 	}

@rfomin
Copy link
Collaborator Author

rfomin commented Dec 17, 2022

patch

So if we turn off the brightmaps after loading the level, the textures are already cached and won't change, right? It is currently possible to disable brightmaps for sprites on the fly and for textures after a level reload, this is confusing.

Wait, no, there must be some bug in the patch, without it the switch works fine. I have a feeling we have already redesigned the DISABLE_ITEM system 😄 Can I postpone this logic a bit?

@fabiangreffrath
Copy link
Owner

Oh, right. We should improve on that.

@rfomin
Copy link
Collaborator Author

rfomin commented Dec 17, 2022

Oh, right. We should improve on that.

No, without a patch it seems to work fine. I suggest we defer the "bloodcolor-like" logic after we revisit the DISABLE_STRICT etc system.

@fabiangreffrath
Copy link
Owner

No, without a patch it seems to work fine. I suggest we defer the "bloodcolor-like" logic after we revisit the DISABLE_STRICT etc system.

Well, okay.

@JNechaevsky
Copy link
Collaborator

@bradharding, @rfomin yours attention is needed, It happens same way in DR too. If I have this lump structure, it works just fine:

BRIGHTMAP FULLBRIGHT 1-255

TEXTURE BRONZE2 FULLBRIGHT DOOM2
TEXTURE PIPE4 FULLBRIGHT DOOM2

image

Hovewer, if game version is omitted, i.e.:

BRIGHTMAP FULLBRIGHT 1-255

TEXTURE BRONZE2 FULLBRIGHT
TEXTURE PIPE4 FULLBRIGHT

Only the first one brightmap is working:

image

Also, current implementation supports only wall textures, not sprites/states (STbar weapons)/flats?

@fabiangreffrath
Copy link
Owner

Hovewer, if game version is omitted,

Only the first one brightmap is working:

I guess that's because in the second case the first line is already fully processed after the FULLBRIGHT keyword, so the parser is already on the second line after that and calling U_GetNextLineToken(s) will cause it to skip that line.

Also, current implementation supports only wall textures, not sprites/states (STbar weapons)/flats?

Yes. Textures are processed differently from sprites/states/flats. We have an array of size numtextures which contains a pointer to a brightmap for each texture available in the game. We would either have to do the same for sprites/states/flats, or we would have to populate some pendant to an unordered_list in C++. Currently, we determine the brightmaps for sprites/states/flats by means of hard-coded switch/case trees.

@rfomin
Copy link
Collaborator Author

rfomin commented Dec 18, 2022

I guess that's because in the second case the first line is already fully processed after the FULLBRIGHT keyword, so the parser is already on the second line after that and calling U_GetNextLineToken(s) will cause it to skip that line.

Yep, fixed in b694f5a

So should we add sprites/states/flats to BRGHTMPS? Then it won't be compatible with Doom Retro.

@fabiangreffrath
Copy link
Owner

So should we add sprites/states/flats to BRGHTMPS? Then it won't be compatible with Doom Retro.

Sounds more like Doom Retro's problem than ours. 😁

@rfomin
Copy link
Collaborator Author

rfomin commented Dec 19, 2022

Test lump:

BRIGHTMAP FULLBRIGHT 0-255
BRIGHTMAP greenonly3 112-123
SPRITE BAR1 greenonly3
FLAT FLOOR0_1 FULLBRIGHT

Not sure what to do with weapon states, how should we name them?

@fabiangreffrath
Copy link
Owner

Not sure what to do with weapon states, how should we name them?

Well, why not just STATE? Or PSPRSTATE?

@rfomin
Copy link
Collaborator Author

rfomin commented Dec 19, 2022

Not sure what to do with weapon states, how should we name them?

Well, why not just STATE? Or PSPRSTATE?

I meant how to name the states themselves. For example, we have a BFGG sprite and S_BFG1 .. S_BFG4 states, but how would the user know the names S_BFG1 .. S_BFG4 without the source code?

@rfomin
Copy link
Collaborator Author

rfomin commented Dec 22, 2022

Can we also have comments in BRGHTMPS lumps?

Yes, C-style comments (both /* */ and //) already work, they are built into u_scanner.c.

@fabiangreffrath
Copy link
Owner

Perfect!

@fabiangreffrath
Copy link
Owner

How do we proceed here?

@rfomin
Copy link
Collaborator Author

rfomin commented Jan 3, 2023

How do we proceed here?

I'll work on this tomorrow, wanted to finish the vcpkg stuff first.

@@ -0,0 +1 @@
TEXTURE SW2STON2 REDONLY
Copy link
Owner

@fabiangreffrath fabiangreffrath Jan 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer if we could have an optional fourth parameter on each line to indicate if a brightmap applies to Doom 1 or 2 (no such parameter would imply "both"). This way we would (1) keep our format compatible to Doom Retro's (which is the purpose of this change, c.f. PR title) and (2) have less external files to rely on which in turn rely on the IWAD file names themselves (remember my concerns regarding bfgdoom.wad, udoom.wad, freedoom1.wad, d2.wad, etc.).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternative approach: How about we support autoload directories based on the internal gamemission name (i.e. doom, doom2, pack_tnt, pack_plut, etc.)? Then we'd end up with only one pack_rekkr directory for example and would be independent of the actual IWAD file name - because game mission is detected based on content if in doubt (c.f. CheckIWAD()).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point, we can make a zip/wad resource file with all the optional content and identify everything by hash. But I like the current system, I think the cases of udoom.wad d2.wad are very rare.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anything that speaks against supporting the fourth field in the BRGHTMPS lump lines to differentiate between Doom 1 and 2? We could have a single brghtmps.lmp in autoload/doom-all and let the parser do the rest.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, we can get rid of the brghtmps.lmp files in the doom.wad and doom2.wad directories, but we'll keep the rest of the files, right?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, yes. Though, we could also get rid of the file in the tnt.wad directory and merge it into the one in doom-all. The textures which get assigned a brightmap in this file do not even exist in any other IWAD.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added DOOM, DOOM2 and DOOM|DOOM2 optional fields. I believe this PR is complete.

BRIGHTMAP CHEXREDGREEN 45,112-118,174-177

TEXTURE BIGDOOR1 GREENONLY3
// {"BIGDOOR4", DOOM1AND2, greenonly3}, // C1: some stray green pixels, C2: many stray green pixels
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer if these were converted from C syntax to the actual BRGHTMPS lump format, so that in theory it would be sufficient to just uncomment these lines.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about Chex 2, is it Doom 2 or Doom 1? I will check later.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chex 2 is a PWAD to Chex 1, i.e. Doom 1.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, in the context of brightmap parsing, calling Chex 2 as Doom 2 to differentiate it from Chex 1 is unambigious.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make chex-all, chex.wad and chex2.wad folders? 😄

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could. But, since chex2.wad is always loaded after chex.wad, its BRGHTMPS entries should override the ones for chex.wad anyway, right? Or, we could introduce a CHEX1|CHEX2 field in the BRGHTMPS spec if you don't like misusing the DOOM1|DOOM2 namespace. 😉

@rfomin rfomin merged commit 88a94d2 into fabiangreffrath:master Jan 11, 2023
@rfomin rfomin deleted the brghtmps branch January 11, 2023 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants