systemshock icon indicating copy to clipboard operation
systemshock copied to clipboard

UI bilinear filtering

Open HunterZ opened this issue 6 years ago • 1 comments

It would be great if bilinear filtering could (optionally?) be applied to scaled menus and UI elements.

HunterZ avatar Mar 08 '19 08:03 HunterZ

Bad news:

The game scales all UI elements in software. Look for usages of SCONV_X() & SCONV_Y() macros. It would take a fair amount of effort to change it to render pixel-perfect and then have SDL do the upscaling so that it can decide whether to apply filtering.

There's also another weird layer of scaling going on: The OpenGL and 2D portions of the screen are rendered at the resolution selected from the in-game video option, then SDL composites them and scales them to the real game window size. It's possible to have SDL apply bilinear filtering to this scaling operation by adding SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); before creating the texture in SDLDraw() in Shock.c, but this has minimal effect when rendering at 1024x768 and scaling to 1080p, and it doesn't seem to affect the OpenGL portion of the scene at all.

Here what I think would be a better solution:

  • Use the actual screen/window size as the basis for rendering minimap, text (possibly with some better anti-aliasing?), pointer line, and OpenGL elements
  • Render all other 2D UI elements to pixel buffers without any scaling
  • Use SDL calls to scale the 2D UI elements proportionally to the actual screen/window size, so that it can optionally do this in hardware and/or apply filtering
  • Composite everything together as-is

This should result in an increased fidelity for minimap, text, pointer lines, and OpenGL scene rendering, and smoother look for the remaining 2D elements.

Unfortunately doing this is currently way over my head, so I'll just leave these ideas here for now.

HunterZ avatar Mar 16 '19 00:03 HunterZ