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

Get rid of linear texture scaling option #2255

Merged
merged 1 commit into from
Jan 5, 2023

Conversation

olanti-p
Copy link
Contributor

@olanti-p olanti-p commented Dec 25, 2022

Summary

SUMMARY: Interface "Get rid of linear texture scaling option"

Purpose of change

Closes #2185
Closes #1888
Current issues with scaling options:

  1. Scaling mode and Scaling factor options are worded similarly and placed in same block, which makes it look like they're responsible for single feature (scaling game display), but de-facto scaling mode is for all texture scaling (tiles & display scaling) while scaling factor is for display scaling only.
  2. Scaling mode option implies that linear scaling is of the higher quality, which may be true when it comes to 3D games and moving and/or natural textures, but BN is a 2D game with static pixel art, any scaling except nearest turns the pixel art into blurry mess whenever you zoom in.

Describe the solution

  1. Add Display to Scaling factor option name to better reflect its purpose.
  2. Get rid of the footgun by completely removing the "scaling mode" option. There's no "linear" scaling anymore.

Describe alternatives you've considered

  1. Getting rid of Scaling factor too, usually OSes have per-screen DPI settings for this.
  2. Not only linear scaling turns pixel art into shit when zooming in, there's also the issue of tile bleeding (oddly-colored half-visible lines at tile edges, see linked issue). Normally it could be fixed by offsetting texture coords by a fraction of a pixel (human eye won't notice that the tile is 31.98 pixels wide, not 32, but that's enough for the renderer to not sample from nearby tiles), but SDL_RenderCopyEx we use for drawing is too simple to support fractional texture coords. Alternative solution is either to rewrite renderer (ha!), or just pad every tile with a 1 pixel wide border of same color either on tileset load or by external tool on tileset creation, but both options are way too much work to save linear scaling which is ill suited for our use case anyway. So, I got rid of it.
  3. Adding a new option (exclusive to opengl) to make textures use "linear" filtering when zooming out and "nearest" when zooming in. This could be a middle ground of sorts. The new option could keep good parts from both old scaling mods, but here's some issues:
    • I've no idea how to implement it for direct3d/metal/android, only win+linux and only for opengl. SDL does not support this "out of the box".
    • It'd need linking (and building against) opengl library (SDL uses it as backend, but does not expose it) on every build system we have

Testing

Works on Windows(msvc).

@github-actions github-actions bot added the src changes related to source code. label Dec 25, 2022
@olanti-p olanti-p changed the title Rework texture scaling options, add dynamic scaling Get rid of linear texture scaling option Dec 25, 2022
@Zireael07
Copy link
Contributor

Worth backporting to CDDA I think

@Coolthulhu Coolthulhu self-assigned this Jan 4, 2023
@Coolthulhu Coolthulhu merged commit b9da151 into cataclysmbnteam:upload Jan 5, 2023
@olanti-p olanti-p deleted the smart-tex-scaling branch August 17, 2023 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Zooming in causes ugly lines and blurriness Tile artifacts on anoid version
3 participants