qbism / q2tools-220

Quake 2 map compiler tools with v220 map support, automatic phong, enhancements, and fixes.
GNU General Public License v2.0
61 stars 20 forks source link

[Feature request] proper SURF_ALPHATEST support #43

Closed SirYodaJedi closed 4 months ago

SirYodaJedi commented 10 months ago

From #42; reformatted as issue:

Issue

The new Quake II remaster (henceforth Q2EX) supports an additional surface flag (bit 25, 0x02000000) for binary transparency, as seen in Q2Pro and KMQuake2. Like SURF_TRANS33 and SURF_TRANS66, this flag needs to be used in conjunction with CONTENTS_TRANSLUCENT in order to actually allow the contained brush to be seen through.

Solution

Q2Tools-220 currently automatically flags brushes with faces containing Trans33 and Trans66 as translucent, and this function could be extended to do the same for alphatest. I have drafted an example (#42) of what might need to be done. I don't really do much programming, so I don't completely understand everything involved, which is why this is currently labeled as incomplete and a draft. For example, there are some mentions of the translucency flags in src/patches.c that I have no clue what they do. I hope though, that as a draft, it explains well enough what should be necessary to accomplish what I am suggesting be added.

Additional questions

Originally posted by @qbism in https://github.com/qbism/q2tools-220/issues/42#issuecomment-1676393208:

  1. Do any existing .map files compatible with q2pro support this? What compile tools for Q2EX exist?
  2. Does rad need changes? For example, when transparency mask is enabled (SURF_TRANS33 + SURF_TRANS66) rad basically passes half the light through.
  3. What do these maps look like in non-supporting engines?
SirYodaJedi commented 10 months ago
  1. Do any existing .map files compatible with q2pro support this?

Yes, although I'm not familiar enough to name any off the top of my head.

What compile tools for Q2EX exist?

The dev versions of ericw-tools (automated builds) were used to compile all the maps in the remaster except the Q2N64 maps. Ask @Paril for the exact compile parameters used. It can load vanilla maps fine, though.

  1. Does rad need changes? For example, when transparency mask is enabled (SURF_TRANS33 + SURF_TRANS66) rad basically passes half the light through.

Maybe. It wouldn't strictly need to restrict light (VHLT just passes all light through alphatested surfaces, while still lightmapping the surface), but blocking some amount of light could look nicer if done carefully.

  1. What do these maps look like in non-supporting engines?

Opaque, probably? With the texels that would be transparent being whatever color is underneath the alpha (for 8-bit WALs, this is that gaudy nougat at index 255).

Paril commented 10 months ago

the TRANS33 + TRANS66 thing is unsupported in most engines, we have a unique flag now that matches other supported engines for it as mentioned above (bit 26 I believe).

qbism commented 10 months ago

Understood. I assumed TRANS33 + TRANS66 support in some engines but textures in these maps (SMD and SPIRIT2DM7 for examples) are just TRANS66 and window contents or similar. Not fully opaque fence in-game.

SURF_ALPHATEST has been committed and the test build should be available in artifacts https://github.com/qbism/q2tools-220/actions/runs/5852362521

Excerpt from Spirit tutorial: https://maps.rcmd.org/tutorials/q2_palette_textures/ To make a plant you may also want to save a small texture that is totally transparent for faces that should not be visible in-game. You can use this one. I made the plants in spirit2dm7 by using two very thin brushes (1 quake unit) with the TRANS66 and MIST flags set. Each brush has 2 faces with the partly transparent plant texture and 4 faces with the trans.wal texture. It looks like this in Radiant: image

JafiMapping commented 10 months ago

Quake II- Version Date_ Aug  3 2023 2023-08-19 14_55_15 I made a test with the color 255 ,in Trench Broom editor, with Qbism Tools and different transparencies. The translucent flag was also checked. This an exemple of Trans33 , Trans66 , Trans33+Trans66, and running it on Quake2 Enhanced . The trans33 +trans66 setting is a bit more opaque, but none of these are totally opaque, which it could be useful.

Paril commented 10 months ago

33|66 is not a valid flag combo, they are mutually exclusive. Only a couple engines used that. The "alphatest" flag is the correct way of doing it; the re-release FGD has it listed in its gameconfig.

JafiMapping commented 10 months ago

Thank you. I use the FDG Re-release in trenchbroom, but the "alpha test" flag does not appear in flag choices. 🤔

Paril commented 10 months ago

gameconfig.cfg I mean, sorry. That's where the flags are stored.

qbism commented 4 months ago

https://github.com/qbism/q2tools-220/commit/56abea11b0ec0cb3c5325739f6fc7831a1e644cf