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).
Details
- Reviewers
- None
- Group Reviewers
Restricted Owners Package (Owns No Changed Paths) - Commits
- rP23484: Adds anti-aliasing option with FXAA algorithm.
- Apply the patch and compile the game
- Make sure that everything works with/without AA
Diff Detail
- Repository
- rP 0 A.D. Public Repository
- Lint
Lint Skipped - Unit
Unit Tests Skipped - Build Status
Buildable 11063 Build 19625: Vulcan Build Jenkins Build 19624: Vulcan Build (macOS) Jenkins Build 19623: Vulcan Build (Windows) Jenkins
Event Timeline
Successful build - Chance fights ever on the side of the prudent.
Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/955/display/redirect
Successful build - Chance fights ever on the side of the prudent.
Link to build: https://jenkins.wildfiregames.com/job/macos-differential/51/display/redirect
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
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
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); }
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.
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.
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.
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.
https://github.com/GPUOpen-Effects/FidelityFX/tree/master/FFX_CAS
I had read that someone had already implemented it for OpenGl in Reshade.
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