sm64pc / sm64ex

Fork of https://github.com/sm64-port/sm64-port with additional features.
1.56k stars 480 forks source link

Add CLI or config option for antialiasing (and texture filtering, etc.) #97

Open RandomDude4 opened 4 years ago

RandomDude4 commented 4 years ago

You can enable AA via Nvidia control panel with good results and without any issues.

Furthermore you can also enable "Antialiasing - Transparency": Supersampling. This is a great benefit in SM64 as you have many textures/sprites with transparency that require supersampling for proper AA.

Many gpu drivers (intel etc.) do not give you these options externally, hence it would be best if you could enable them in-game.

If there is a plan for an in-game menu it could be placed there, otherwise it could be CLI options or in the config.ini file.

RandomDude4 commented 4 years ago

Comparison: Left: AA and Transparency Supersampling set in Nvidia CP Right: Standard

(Click to open full size image) Clipboard Image

johnlorentzson commented 4 years ago

Adding (multisampling) anti-aliasing is literally just two lines of "code" (actually boilerplate statements), so it would be trivial to add AA. Doing it with command-line arguments, however, would be less than trivial if it is to be forward compatible, although it still wouldn't be hard.

halop commented 4 years ago

antialiasing in as an option would be great

RandomDude4 commented 4 years ago

I only have limited experience with opengl/vulkan. However I found the following commented code in sm64pc/src/pc/gfx/gfx_sdl2.c : //SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); //SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);

I uncommented these and multisampling AA is now enabled by default (without Nvidia CP)! Hence it is "just" a matter of toggling these with an option after compile.

Worth noticing, this is MSAA not SSAA, hence all textures still have aliasing in them. Since this game relies a lot on sprites, this means that a lot of things still lack AA. In newer games most objects are modeled with polygons, there MSAA works much better.

Is there an equivalent command for SDL_GL_MULTISAMPLEBUFFERS for SSAA? Or is it more easily done by doubling the resolution of the renderer and scaling the result back down?

Emill commented 4 years ago

Well the AA doesn't work perfectly. A lot of textures will at the sprite edge get incorrect pixels values that have wrapped, due to how that simple AA algorithm works. That's one reason it's disabled by default.

RandomDude4 commented 4 years ago

Well the AA doesn't work perfectly. A lot of textures will at the sprite edge get incorrect pixels values that have wrapped, due to how that simple AA algorithm works. That's one reason it's disabled by default.

Thanks for the info. I have not noticed it myself yet, but I have only made very limited testing.

Perhaps supersampling the entire window is better and easier to implement in that case:

What do you think?

fgsfdsfgs commented 4 years ago

Runtime texture filtering switch was added in 9ae444d. Don't forget to build with EXT_OPTIONS_MENU=1 and/or BETTERCAMERA=1 to get the menu in. Gotta figure out how to do antialiasing without any of the bullshit appearing in it before we add a switch for that. Maybe SSAA like suggested above is the better approach.