Page MenuHomeWildfire Games

Adds anti-aliasing option
ClosedPublic

Authored by vladislavbelov on Jan 5 2020, 6:12 PM.

Details

Reviewers
None
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Commits
rP23484: Adds anti-aliasing option with FXAA algorithm.
Summary

Currently only FXAA is added to simplify the patch. But it's possible to add MLAA/SMAA with some render path modifications and expensive MSAA (but it requires some proper GL loader).

Test Plan
  1. Apply the patch and compile the game
  2. Make sure that everything works with/without AA

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

vladislavbelov created this revision.Jan 5 2020, 6:12 PM
vladislavbelov retitled this revision from Adds Anti-Aliasing to Adds anti-aliasing option.
Vulcan added a comment.Jan 5 2020, 6:15 PM

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/955/display/redirect

Vulcan added a comment.Jan 5 2020, 6:18 PM

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/51/display/redirect

Vulcan added a comment.Jan 5 2020, 6:20 PM

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...

source/renderer/scripting/JSInterface_Renderer.h
|   1| /*·Copyright·(C)·2019·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2019"

source/renderer/scripting/JSInterface_Renderer.h
|  27| namespace·JSI_Renderer
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'namespaceJSI_Renderer{' is invalid C code. Use --std or --language to configure the language.

source/renderer/PostprocManager.h
|   1| /*·Copyright·(C)·2019·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2019"

source/renderer/PostprocManager.h
|  26| class·CPostprocManager
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'classCPostprocManager{' is invalid C code. Use --std or --language to configure the language.

source/renderer/scripting/JSInterface_Renderer.cpp
|   1| /*·Copyright·(C)·2019·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2019"

source/renderer/PostprocManager.cpp
|   1| /*·Copyright·(C)·2019·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2019"
Executing section JS...
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1473/display/redirect

nani awarded a token.Jan 5 2020, 7:20 PM

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/959/display/redirect

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/55/display/redirect

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...

source/renderer/PostprocManager.h
|  26| class·CPostprocManager
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'classCPostprocManager{' is invalid C code. Use --std or --language to configure the language.

source/renderer/scripting/JSInterface_Renderer.h
|  27| namespace·JSI_Renderer
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'namespaceJSI_Renderer{' is invalid C code. Use --std or --language to configure the language.
Executing section JS...
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1477/display/redirect

nani added a subscriber: nani.EditedJan 8 2020, 10:39 PM

Adding a extra optional sharpening pass in fxaa.xml should improve the output image.

I propose this simple box sharpening one that I use in my mod that improves the image quality.

sharpen.fs

#version 120

uniform sampler2D renderedTex;
uniform float width;
uniform float height;

varying vec2 v_tex;

vec3 sharpen(sampler2D tex, vec2 v_tex, float factor) {

  vec3 centerColor = texture2D(tex, v_tex).rgb;

  vec2 inv = vec2(1.0 / width, 1.0 / height);
  vec3 col = vec3(0.0);

  col -= texture2D(tex, v_tex + vec2(-1.0, -1.0) * inv).rgb;
  col -= texture2D(tex, v_tex + vec2(-1.0, 1.0) * inv).rgb;
  col += 5.0 * centerColor;
  col -= texture2D(tex, v_tex + vec2(1.0, -1.0) * inv).rgb;
  col -= texture2D(tex, v_tex + vec2(1.0, 1.0) * inv).rgb;

  return mix(centerColor, col, factor);
}

void main(void) { gl_FragColor.rgb = sharpen(renderedTex, v_tex, 0.1); }
In D2537#106528, @nani wrote:

Adding a extra optional sharpening pass in fxaa.xml should improve the output image.
I propose this simple box sharpening one that I use in my mod that improves the image quality.

I think it'd be useful to attach a side-by-side comparison image.

nani added a comment.EditedJan 9 2020, 10:53 AM

factor: 0.0

factor: 0.1 (best imo)

factor: 0.2

factor: 0.8

The factor can be made a slider option if time comes to shove.

nani added a comment.Jan 9 2020, 11:04 AM

Also, the diff seems to have failed to upload correctly for :

binaries/data/mods/public/shaders/glsl/fxaa.fs (624 lines)
binaries/data/mods/public/shaders/glsl/fxaa.xml (13 lines)
binaries/data/mods/public/shaders/glsl/hdr.vs (13 lines)

had to manually add the missing glsl for it to work.

Stan added a subscriber: Stan.EditedJan 9 2020, 11:37 AM

I'm not sure but I think you inverted 0.1 and 0.0, the latter seems sharper. I also agree it's an improvement.

nani added a comment.Jan 9 2020, 12:09 PM
In D2537#106599, @Stan wrote:

I'm not sure but I think you inverted 0.1 and 0.0, the latter seems sharper. I also agree it's an improvement.

Fixed

Stan added a comment.Jan 9 2020, 12:19 PM

Thanks. I'd say 0.1 or 0.2. Could be config option?

I would suggest to split the anti-aliasing and the sharpening filter in two seperat options in the settings. Also I like the idea to have a slider that everyone could take is favor settings. As I know AMD has made his new Radeon Image Sharpening filter free open source, I would recommend to have a look on it. The quality is very impressive.

As I know AMD has made his new Radeon Image Sharpening filter free open source, I would recommend to have a look on it.

https://github.com/GPUOpen-Effects/FidelityFX/tree/master/FFX_CAS

I had read that someone had already implemented it for OpenGl in Reshade.

Vulcan added a comment.Feb 5 2020, 9:48 PM

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...

source/renderer/scripting/JSInterface_Renderer.h
|  27| namespace·JSI_Renderer
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'namespaceJSI_Renderer{' is invalid C code. Use --std or --language to configure the language.

source/renderer/PostprocManager.h
|  26| class·CPostprocManager
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'classCPostprocManager{' is invalid C code. Use --std or --language to configure the language.
Executing section JS...
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1719/display/redirect

This revision was not accepted when it landed; it landed in state Needs Review.Feb 5 2020, 10:53 PM
This revision was automatically updated to reflect the committed changes.
Owners added a subscriber: Restricted Owners Package.Feb 5 2020, 10:53 PM