From 8007d2cf5ec0fe88d0bc60e1dd95767d58fdd653 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 4 Aug 2014 06:19:19 +0200 Subject: [PATCH] Add FXAA to Ryzom Client --- code/ryzom/client/client_default.cfg | 6 +++++ code/ryzom/client/client_default.cfg.in | 6 +++++ .../gamedev/interfaces_v3/game_config.xml | 15 +++++++++++- code/ryzom/client/src/client_cfg.cpp | 5 ++++ code/ryzom/client/src/client_cfg.h | 3 +++ code/ryzom/client/src/global.cpp | 23 +++++++++++-------- code/ryzom/client/src/global.h | 4 ++++ code/ryzom/client/src/init_main_loop.cpp | 5 ++++ code/ryzom/client/src/login.cpp | 1 + code/ryzom/client/src/main_loop.cpp | 4 +++- code/ryzom/client/src/main_loop_utilities.cpp | 17 ++++++++++++++ code/ryzom/client/src/release.cpp | 6 +++-- 12 files changed, 81 insertions(+), 14 deletions(-) diff --git a/code/ryzom/client/client_default.cfg b/code/ryzom/client/client_default.cfg index a27e69ee0..2846713fc 100644 --- a/code/ryzom/client/client_default.cfg +++ b/code/ryzom/client/client_default.cfg @@ -214,6 +214,12 @@ Shadows_ps1 = 1; Shadows_ps2 = 1; Shadows_ps3 = 1; +FXAA = 1; +FXAA_ps0 = 0; +FXAA_ps1 = 1; +FXAA_ps2 = 1; +FXAA_ps3 = 1; + Bloom = 0; Bloom_ps0 = 0; Bloom_ps1 = 1; diff --git a/code/ryzom/client/client_default.cfg.in b/code/ryzom/client/client_default.cfg.in index 030a4a2b2..ec699fe14 100644 --- a/code/ryzom/client/client_default.cfg.in +++ b/code/ryzom/client/client_default.cfg.in @@ -210,6 +210,12 @@ Shadows_ps1 = 1; Shadows_ps2 = 1; Shadows_ps3 = 1; +FXAA = 1; +FXAA_ps0 = 0; +FXAA_ps1 = 1; +FXAA_ps2 = 1; +FXAA_ps3 = 1; + Bloom = 0; Bloom_ps0 = 0; Bloom_ps1 = 1; diff --git a/code/ryzom/client/data/gamedev/interfaces_v3/game_config.xml b/code/ryzom/client/data/gamedev/interfaces_v3/game_config.xml index 5e9072b93..c2b62cebd 100644 --- a/code/ryzom/client/data/gamedev/interfaces_v3/game_config.xml +++ b/code/ryzom/client/data/gamedev/interfaces_v3/game_config.xml @@ -1230,8 +1230,15 @@ posref="BL TL" x="-20" y="-12" /> + + setDefaultContextHelp(CI18N::get("uiFxTooltipBloom")); + ClientCfg.writeBool("FXAA", false); ClientCfg.writeBool("Bloom", false); ClientCfg.writeBool("SquareBloom", false); ClientCfg.writeInt("DensityBloom", 0); diff --git a/code/ryzom/client/src/login.cpp b/code/ryzom/client/src/login.cpp index ff199eace..628cc7624 100644 --- a/code/ryzom/client/src/login.cpp +++ b/code/ryzom/client/src/login.cpp @@ -1990,6 +1990,7 @@ class CAHInitResLod : public IActionHandler CfgPresetList.push_back(pair("NbMaxSkeletonNotCLod", false)); CfgPresetList.push_back(pair("CharacterFarClip", true)); + CfgPresetList.push_back(pair("FXAA", false)); CfgPresetList.push_back(pair("Bloom", false)); CfgPresetList.push_back(pair("SquareBloom", false)); CfgPresetList.push_back(pair("DensityBloom", true)); diff --git a/code/ryzom/client/src/main_loop.cpp b/code/ryzom/client/src/main_loop.cpp index ad1cb403e..66fe7cc39 100644 --- a/code/ryzom/client/src/main_loop.cpp +++ b/code/ryzom/client/src/main_loop.cpp @@ -45,6 +45,7 @@ #include "nel/3d/stereo_hmd.h" #include "nel/3d/render_target_manager.h" #include "nel/3d/driver_user.h" +#include "nel/3d/fxaa.h" // game share #include "game_share/brick_types.h" #include "game_share/light_cycle.h" @@ -1630,7 +1631,7 @@ bool mainLoop() bool effectRender = false; CTextureUser *effectRenderTarget = NULL; bool haveEffects = Render && Driver->getPolygonMode() == UDriver::Filled - && ClientCfg.Bloom; + && (ClientCfg.Bloom || FXAA); bool defaultRenderTarget = false; if (haveEffects) { @@ -1733,6 +1734,7 @@ bool mainLoop() if (StereoDisplay) Driver->setViewport(NL3D::CViewport()); UCamera pCam = Scene->getCam(); Driver->setMatrixMode2D11(); + if (FXAA) FXAA->applyEffect(); if (ClientCfg.Bloom) CBloomEffect::instance().applyBloom(); Driver->setMatrixMode3D(pCam); if (StereoDisplay) Driver->setViewport(StereoDisplay->getCurrentViewport()); diff --git a/code/ryzom/client/src/main_loop_utilities.cpp b/code/ryzom/client/src/main_loop_utilities.cpp index 194810ea9..0fe52e53c 100644 --- a/code/ryzom/client/src/main_loop_utilities.cpp +++ b/code/ryzom/client/src/main_loop_utilities.cpp @@ -19,6 +19,7 @@ #include #include +#include #include "game_share/scenario_entry_points.h" @@ -218,6 +219,22 @@ void updateFromClientCfg() } } + //--------------------------------------------------- + if (ClientCfg.FXAA != LastClientCfg.FXAA) + { + if (ClientCfg.FXAA) + { + nlassert(!FXAA); + FXAA = new NL3D::CFXAA(Driver); + } + else + { + nlassert(FXAA); + delete FXAA; + FXAA = NULL; + } + } + // GRAPHICS - CHARACTERS //--------------------------------------------------- if (ClientCfg.SkinNbMaxPoly != LastClientCfg.SkinNbMaxPoly) diff --git a/code/ryzom/client/src/release.cpp b/code/ryzom/client/src/release.cpp index 3659d034d..5affddd04 100644 --- a/code/ryzom/client/src/release.cpp +++ b/code/ryzom/client/src/release.cpp @@ -497,7 +497,8 @@ void releaseOutGame() // Remove the Actions listener from the Events Server. EventsListener.removeFromServer(CInputHandlerManager::getInstance()->FilteredEventServer); - // Release Bloom + // Release effects + delete FXAA; FXAA = NULL; CBloomEffect::releaseInstance(); // Release Scene, textcontexts, materials, ... @@ -591,7 +592,8 @@ void release() Driver->deleteTextContext(TextContext); TextContext = NULL; - // Release Bloom + // Release effects + delete FXAA; FXAA = NULL; CBloomEffect::releaseInstance(); // Release Scene, textcontexts, materials, ...