gonetz / GLideN64

A new generation, open-source graphics plugin for N64 emulators.
Other
774 stars 180 forks source link

"Render 2D elements in N64 resolution" Scaling Method #1788

Open ghost opened 6 years ago

ghost commented 6 years ago

For "Render 2D elements in N64 resolution", is it possible to control the scaling method used after they're rendered? For example, if I'm running the emulator at 960x720, is it possible to use this option (as it fixes misalignments in some cases) and then have any 2D elements that are rendered this way point-scaled (nearest neighbor resized) to the output resolution, rather than bilinear resized?

Games like "Mischief Makers" would likely benefit visually at higher resolutions from having this as an option, but if it's not something that's compatible then I understand and this can be closed.

AmbientMalice commented 6 years ago

What "render 2D elements at N64 resolution" does is merge textures into a single texture and then apply bilinear filtering to that single texture, instead of filtering each strip individually, which causes alignment problems. See here http://gliden64.blogspot.com/2015/11/improved-2d-and-other-fixes.html

gonetz commented 6 years ago

Yes, "render 2D elements at N64 resolution" merges narrow textures into a single texture and then put that large single texture on its place with bilinear filtering. It is possible to use any other filtering. Point-scaled would be useless though - it is simpler to disable texture filtering at all, result will be the same.

ghost commented 6 years ago

Thank you both for the explanations.

it is simpler to disable texture filtering at all, result will be the same. The game is mostly 2D and uses a combination of filtered and non-filtered textures. I've attached three screenshots as examples (with "Render 2D elements in N64 resolution" enabled):

Screenshot 1 Screenshot 2 Screenshot 3

In the first screenshot, some of the characters are filtered and some aren't. In the second, all of the characters are filtered but their hats are not, making them look out of place. These are both common occurrence throughout the game, as filtering methods often varies between characters and items. At native resolution they all look the same, but when the resolution is increased they begin to look out of place.

In the last screenshot, some characters are filtered and some aren't (like in the first), but the ground texture is also notably filtered, which brings me to my problem: disabling all filtering gives the intended result for the characters, but turns the ground into a pixelated mess in the third. I was hoping that perhaps being able to disable bilinear filtering on "Render 2D elements in N64 resolution" would allow the characters to appear sharp and unfiltered, whilst still allowing the ground look the way it currently does.

Papermanzero commented 6 years ago

This is related to that issue. Donkey Kong 64 title screen is also rendered without filtering. https://github.com/gonetz/GLideN64/issues/483

gonetz commented 6 years ago

I was hoping that perhaps being able to disable bilinear filtering on "Render 2D elements in N64 resolution" would allow the characters to appear sharp and unfiltered, whilst still allowing the ground look the way it currently does.

It is possible to distinguish 2D and 3D graphics and force disable filtering for 2D elements. It can be done without using "Render 2D elements in N64 resolution" technique.

ghost commented 6 years ago

It is possible to distinguish 2D and 3D graphics and force disable filtering for 2D elements. It can be done without using "Render 2D elements in N64 resolution" technique.

I wasn't aware of that. It sounds like much better idea and would still resolve my issue / request.

ghost commented 6 years ago

I ran into a few other instances where "Render 2D elements in N64 resolution" resolves a problem but the filtering introduces another recently.

@gonetz has there been any more consideration to this idea?

gonetz commented 6 years ago

Not yet

ghost commented 6 years ago

That's alright, thanks for the update!

gonetz commented 6 years ago

Btw, you can help me with filter choice. We can use bilinear, becubic etc
Can you take screen shot in native resolution and scale it up to screen resolution in some graphics editor using various smoothing filters? What can give noticeably better result than currently used belinear filter?

ghost commented 6 years ago

a b c d e f g h i j k l

ghost commented 6 years ago

"Render 2D elements at N64 resolution" fixes some problems in the game, but it would be nice to have the image looking sharp at a high resolution while using this option. Disabling filtering altogether can also fix the problem but breaks the boss backgrounds.

Forcing "nearest neighbour" would be a good option to have, so that the 2D elements can appear sharp at the higher resolutions without breaking the backgrounds. Currently some things are filtered and some aren't (as seen below) and it would be nice to have everything looking the same: Screenshot 2

For the scaling methods I posted above my thoughts are that xBRZ and HQx do the same job, but xBRZ does it better. Spline and Lanczos also give similar results to each other. Sinc has a lot of artifacts around the edges. Bilinear and Bicubic both seem to be safe bets as well.

The only necessary options (to ensure elements don't look inconsistent, like in the above screenshot) would be the filtering options the N64 already provides, to match filtering. Maybe a choice between those (nearest neighbour and bilinear) and some kind of automatic option would be a good idea. Other methods can be added to the list if people want them.

gonetz commented 6 years ago

Imo, any of these filtering methods can be used in "use native resolution" mode to upscale native-res image into screen-resolution. It is matter of user preferences. I just need to implement possibility to select post-processing filter.

As for "Render 2D elements in N64 resolution", it is applied only if game renders 2D with biliner filtering, because biliner works incorrect on original textures in high resolution. If game does not use filtering, such 2D elements rendered in screen resolution. Thus, nothing much to control there. Of course, I can use xBRZ to upscale 2D geometry prepared by "Render 2D elements in N64 resolution" method , but as you understand it will look inconsistent.

ghost commented 6 years ago

It is possible to distinguish 2D and 3D graphics and force disable filtering for 2D elements.

Could this still be implemented as well?

Papermanzero commented 5 years ago

I would in general propose 3 options for filtering system

Beside the setting for the system, another setting concerning the filter method would be helpful:

With those two settings everyone can set the prefered filtering.

oddMLan commented 4 years ago

duplicate of #574

gonetz commented 4 years ago

duplicate of #574

Not exactly.

574 is to add "force point sampling" option.

This one is how to improve result of "Render 2D elements in N64 resolution"

gizmo98 commented 4 years ago

Point sampled rotated sprites in mischief maker look better if texture anti-aliasing is used. There are no jaggies around the sprite. Sprite fits better in background.

Examples: https://www.shadertoy.com/view/XtB3zw https://www.shadertoy.com/view/ldsSRX

Test branch: https://github.com/gonetz/GLideN64/compare/master...gizmo98:better-point-sampling?expand=1

mischief_makers-005 mischief_makers-000 mischief_makers-004

gonetz commented 4 years ago

@gizmo98 Please give me some explanation of what is "texture anti-aliasing" and what it gives us. Could you make some comparison screen shot? I can't see what is improved on your screen shots.

gizmo98 commented 4 years ago

@gonetz Please check out shader toy examples. Mischief maker uses rotated sprites for hats and other things which are point sampled.

gonetz commented 4 years ago

Please check out shader toy examples.

I checked them but I don't understand what is the point. Something is rotating and what?

Mischief maker uses rotated sprites for hats and other things which are point sampled.

Ok. Could you make comparison screen shot to show these sprites with and without texture anti-aliasing?

Sorry for my stupidity, but I just don't understand where to look at.

gizmo98 commented 4 years ago

Just two Mischief Makers examples (200% zoom):

Point sampled sprite. Jaggies look restless if hat is moving and rotating. Without AA

Sprite "which should be" point sampled but uses so called "texture anti aliasing". Texels are quite good visible but you cannot see jaggies between them. PointSampleAA

Minecraft textures also look point sampled but you cannot see jaggies between "blocky" texels. I will take some screenshots if i have time.

oddMLan commented 4 years ago

@gizmo98 there is already code for what you're attempting to do. hybrid filter works the same way. it preserves the blocky "point-sampled" look of the texture while smoothing out the texels that dont quite snap to the grid. you could reuse it for this purpose, however it causes slowdowns in some mobile devices. right now it is only being applied to final screen picture; in the experimental_filtering branch it was applied to point sampled textures as well. however this caused many issues in some games hence it was dropped. check #2116 to see what those were.

gizmo98 commented 4 years ago

@oddMLan Thanks for the info. I have not played around to much with hybrid filter until now.

oddMLan commented 4 years ago

On closer inspection, it might be not the same thing. @gizmo98 could you compile the experimental_filtering branch and see if it helps this game? You may also disable the opacity check for greater effect. Finally, color bleeding would help with artifacts like these: image But I didn't implement the commit for that. Should be easy to add it back from the color bleeding code for testing purposes.