Skip to content

OpenGL palette rendering and related things

Hannu Hanhi requested to merge Hannu_Hanhi/SRB2:ogl-palette-rendering into next

This patch adds a palette rendering mode into the OpenGL renderer. It matches the look of software rendering very closely.

A new option are added to the OpenGL settings menu: "Palette rendering" (gr_paletterendering) switches the new mode on/off. (Shaders must also be enabled)

gr_palettedepth switches the look of the colors between what software mode displays on the screen (16 bits) and what software mode displays in screenshots saved by the game (24 bits). (Tip: Using an external screenshot tool (like the Print Screen key) instead of pressing F8 will capture what software mode is actually outputting to your screen.)

If you want everything else to look like software too, make sure you have these settings:

  • Texture filtering: Nearest
  • Anisotropic filtering: 1 (=disabled)
  • Lack of perspective: On
  • gl_fakecontrast on (I think?)
  • OpenGL bit depth: 32 bits (Lower settings have slightly worse color accuracy)

Features:

  • Lighting is done using software's light tables / colormaps
  • Light level calculation is upgraded to be more accurate (truecolor rendering also affected) (fixes or at least greatly improves #518)
  • Postprocess shader palettizes the translucent parts and the rest of the image
  • Composite textures are blended the same way as in software
  • Texture filtering still works. You can have software colors without software moire!
    • This is achieved by converting the RGB color sampled from the texture in the shader into a palette index using a lookup table
  • Full flash palette support
  • Fixes a minor inconsistency between hardware and software about the use of fake contrast in colormapped walls
  • Fades are more accurate to how they look in software

Other notes:

  • Continues (and includes) the work in !1507 (closed). The defines used by the preprocessor have a "SRB2_" prefix added to them. Shaders will have #define SRB2_PALETTE_RENDERING added to them when palette rendering is enabled.
  • The light levels are close to software but not perfect. Also translucencies don't always look the same.
  • Some color issues seem to be because of some bugs in the hardware renderer that are not directly related to palette rendering. Like incorrect appearance of the bottom side of the water surfaces in many maps, including GFZ and DSZ.

This should be tested on a diverse set of hardware (from AMD, Intel and NVIDIA) to make sure there aren't any GPU vendor-specific issues. Drivers on different operating systems can also behave differently.

Testing build (Updated 2023-09-23):

srb2win_ogl-palette-rendering-5.exe

(Note: it's disabled by default, go to the OpenGL settings to enable it!)

This build is netgame compatible with 2.2.13!

When reporting issues, please also report OS version and GPU model.

Edited by Hannu Hanhi

Merge request reports