open-manifold / Open-Manifold

A free and open-source clone of Rhythm 'n' Face for PC.
Other
10 stars 1 forks source link

Use nearest-neighbor for upscaling small character.png images #19

Closed xen-osd closed 1 year ago

xen-osd commented 1 year ago

image It is particularly noticeable in the panda's eyes

xen-osd commented 1 year ago

image

SuperFromND commented 1 year ago

I tried this out as an experiment by using a method where, if the sprite was smaller than the "bounding box" that characters are drawn to, it uses nearest-neighbor, else it uses bilinear:

    // determine whether to use NN or bilinear scaling based on
    // whether the character sprite fits into the bounding box or not
    int greater_axis = fmax(char_crop.w, char_crop.h);

    if (greater_axis < char_coords.w) {
        SDL_SetTextureScaleMode(char_texture, SDL_ScaleModeNearest);
    } else {
        SDL_SetTextureScaleMode(char_texture, SDL_ScaleModeLinear);
    }

I wasn't really fond of the resulting look though (the game doesn't use integer scaling for this, so you get inconsistent pixel sizes and it just looks weird regardless):

image image

Perhaps this is something that could be added as an option instead, so the user can decide based on whatever looks better to them.

SalsaGal commented 1 year ago

Another option is that rather than an option per game, it could be an option per level?

SuperFromND commented 1 year ago

Yeah, this would probably make more sense as something per-level. I'm of perhaps adding a header to character.json to allow for this to be set there:

{"scale_mode": "nearest"}
{"scale_mode": "bilinear"}

Since level.json and now tile.json have one, it'd only make sense character.json has one too.

SuperFromND commented 1 year ago

The above header and scale_mode parameter have now been implemented! The parameters are named linear and nearest. Defaults to linear.

Still isn't scaled with integer scaling in nearest at the moment, but it should be good enough for now hopefully! <3 image