Add FXAA to Ryzom Client

This commit is contained in:
kaetemi 2014-08-04 06:19:19 +02:00
parent 24a3d1aaad
commit 8007d2cf5e
12 changed files with 81 additions and 14 deletions

View file

@ -214,6 +214,12 @@ Shadows_ps1 = 1;
Shadows_ps2 = 1; Shadows_ps2 = 1;
Shadows_ps3 = 1; Shadows_ps3 = 1;
FXAA = 1;
FXAA_ps0 = 0;
FXAA_ps1 = 1;
FXAA_ps2 = 1;
FXAA_ps3 = 1;
Bloom = 0; Bloom = 0;
Bloom_ps0 = 0; Bloom_ps0 = 0;
Bloom_ps1 = 1; Bloom_ps1 = 1;

View file

@ -210,6 +210,12 @@ Shadows_ps1 = 1;
Shadows_ps2 = 1; Shadows_ps2 = 1;
Shadows_ps3 = 1; Shadows_ps3 = 1;
FXAA = 1;
FXAA_ps0 = 0;
FXAA_ps1 = 1;
FXAA_ps2 = 1;
FXAA_ps3 = 1;
Bloom = 0; Bloom = 0;
Bloom_ps0 = 0; Bloom_ps0 = 0;
Bloom_ps1 = 1; Bloom_ps1 = 1;

View file

@ -1230,8 +1230,15 @@
posref="BL TL" posref="BL TL"
x="-20" x="-20"
y="-12" /> y="-12" />
<instance template="tgcw_checkbox"
id="fxaa"
text="uiFXAA"
posparent="shadow"
posref="BL TL"
x="0"
y="-12" />
<group id="bloom_gr" <group id="bloom_gr"
posparent="shadow" posparent="fxaa"
sizeparent="parent" sizeparent="parent"
sizeref="w" sizeref="w"
h="100" h="100"
@ -3133,6 +3140,12 @@
realtime="true" realtime="true"
link="Shadows" link="Shadows"
preset="UI:TEMP:PRESET_FX" /> preset="UI:TEMP:PRESET_FX" />
<param ui="fx:fxaa:c"
type="cfg"
widget="boolbut"
realtime="true"
link="FXAA"
preset="UI:TEMP:PRESET_FX" />
<param ui="fx:bloom_gr:bloom:c" <param ui="fx:bloom_gr:bloom:c"
type="cfg" type="cfg"
widget="boolbut" widget="boolbut"

View file

@ -389,6 +389,8 @@ CClientConfig::CClientConfig()
Fog = true; // Fog is on by default Fog = true; // Fog is on by default
WaitVBL = false; WaitVBL = false;
FXAA = true;
Bloom = true; Bloom = true;
SquareBloom = true; SquareBloom = true;
DensityBloom = 255.f; DensityBloom = 255.f;
@ -980,6 +982,9 @@ void CClientConfig::setValues()
READ_BOOL_FV(SquareBloom) READ_BOOL_FV(SquareBloom)
READ_FLOAT_FV(DensityBloom) READ_FLOAT_FV(DensityBloom)
// FXAA
READ_BOOL_FV(FXAA)
// ScreenAspectRatio. // ScreenAspectRatio.
READ_FLOAT_FV(ScreenAspectRatio) READ_FLOAT_FV(ScreenAspectRatio)
// FoV. // FoV.

View file

@ -263,6 +263,9 @@ struct CClientConfig
float GlobalWindPower; float GlobalWindPower;
CVector GlobalWindDirection; CVector GlobalWindDirection;
// FXAA
bool FXAA;
// Is bloom effect activated // Is bloom effect activated
bool Bloom; bool Bloom;
bool SquareBloom; bool SquareBloom;

View file

@ -25,21 +25,24 @@ using namespace NLMISC;
// *************************************************************************** // ***************************************************************************
// Main System // Main System
NL3D::UDriver *Driver = 0; // The main 3D Driver NL3D::UDriver *Driver = NULL; // The main 3D Driver
NL3D::IStereoDisplay *StereoDisplay = NULL; // Stereo display NL3D::IStereoDisplay *StereoDisplay = NULL; // Stereo display
NL3D::IStereoHMD *StereoHMD = NULL; // Head mount display NL3D::IStereoHMD *StereoHMD = NULL; // Head mount display
CSoundManager *SoundMngr = 0; // the sound manager CSoundManager *SoundMngr = NULL; // the sound manager
NL3D::UMaterial GenericMat; // Generic Material NL3D::UMaterial GenericMat; // Generic Material
NL3D::UTextContext *TextContext = 0; // Context for all the text in the client. NL3D::UTextContext *TextContext = NULL; // Context for all the text in the client.
// Effects
NL3D::CFXAA *FXAA = NULL;
// Main 3D Objects // Main 3D Objects
NL3D::UScene *Scene = 0; NL3D::UScene *Scene = NULL;
NL3D::UScene *SceneRoot = 0; NL3D::UScene *SceneRoot = NULL;
NL3D::UInstanceGroup *BackgroundIG = 0; NL3D::UInstanceGroup *BackgroundIG = NULL;
NL3D::ULandscape *Landscape = 0; NL3D::ULandscape *Landscape = NULL;
NL3D::UCloudScape *CloudScape = 0; NL3D::UCloudScape *CloudScape = NULL;
NL3D::UCamera MainCam; NL3D::UCamera MainCam;
NL3D::UVisualCollisionManager *CollisionManager = 0; NL3D::UVisualCollisionManager *CollisionManager = NULL;
#ifdef USE_WATER_ENV_MAP #ifdef USE_WATER_ENV_MAP
CWaterEnvMapRdr WaterEnvMapRdr; CWaterEnvMapRdr WaterEnvMapRdr;
NL3D::UWaterEnvMap *WaterEnvMap = NULL; NL3D::UWaterEnvMap *WaterEnvMap = NULL;
@ -58,7 +61,7 @@ NLMISC::CMatrix InvMainSceneViewMatrix; // Matrix to transform from camera s
// Misc // Misc
bool InitCloudScape = true; // tells that the cloud scape must be reinitialized bool InitCloudScape = true; // tells that the cloud scape must be reinitialized
CEntityAnimationManager *EAM = 0; CEntityAnimationManager *EAM = NULL;
CProgress ProgressBar; CProgress ProgressBar;
TBackground LoadingBackground = StartBackground; TBackground LoadingBackground = StartBackground;
string LoadingMusic; string LoadingMusic;

View file

@ -42,6 +42,7 @@ namespace NL3D
class UWaterEnvMap; class UWaterEnvMap;
class IStereoDisplay; class IStereoDisplay;
class IStereoHMD; class IStereoHMD;
class CFXAA;
} }
class CEntityAnimationManager; class CEntityAnimationManager;
@ -85,6 +86,9 @@ extern CSoundManager *SoundMngr; // the sound manager
extern NL3D::UMaterial GenericMat; // Generic Material extern NL3D::UMaterial GenericMat; // Generic Material
extern NL3D::UTextContext *TextContext; // Context for all the text in the client. extern NL3D::UTextContext *TextContext; // Context for all the text in the client.
// Effects
extern NL3D::CFXAA *FXAA;
// Main 3D Objects // Main 3D Objects
extern NL3D::UScene *Scene; extern NL3D::UScene *Scene;
extern NL3D::UScene *SceneRoot; extern NL3D::UScene *SceneRoot;

View file

@ -41,6 +41,7 @@
#include "nel/3d/u_shape_bank.h" #include "nel/3d/u_shape_bank.h"
#include "nel/3d/u_water_env_map.h" #include "nel/3d/u_water_env_map.h"
#include "nel/3d/material.h" #include "nel/3d/material.h"
#include "nel/3d/fxaa.h"
// Sound // Sound
#include "nel/sound/u_audio_mixer.h" #include "nel/sound/u_audio_mixer.h"
// Client // Client
@ -566,6 +567,9 @@ void initMainLoop()
if(Scene == 0) if(Scene == 0)
nlerror("initMainLoop : Cannot create a Scene."); nlerror("initMainLoop : Cannot create a Scene.");
// create effects
if (ClientCfg.FXAA && !FXAA) FXAA = new NL3D::CFXAA(Driver);
// use this scene for bloom effect // use this scene for bloom effect
CBloomEffect::getInstance().setScene(Scene); CBloomEffect::getInstance().setScene(Scene);
@ -1575,6 +1579,7 @@ void initBloomConfigUI()
if(group) if(group)
group->setDefaultContextHelp(CI18N::get("uiFxTooltipBloom")); group->setDefaultContextHelp(CI18N::get("uiFxTooltipBloom"));
ClientCfg.writeBool("FXAA", false);
ClientCfg.writeBool("Bloom", false); ClientCfg.writeBool("Bloom", false);
ClientCfg.writeBool("SquareBloom", false); ClientCfg.writeBool("SquareBloom", false);
ClientCfg.writeInt("DensityBloom", 0); ClientCfg.writeInt("DensityBloom", 0);

View file

@ -1990,6 +1990,7 @@ class CAHInitResLod : public IActionHandler
CfgPresetList.push_back(pair<string,bool>("NbMaxSkeletonNotCLod", false)); CfgPresetList.push_back(pair<string,bool>("NbMaxSkeletonNotCLod", false));
CfgPresetList.push_back(pair<string,bool>("CharacterFarClip", true)); CfgPresetList.push_back(pair<string,bool>("CharacterFarClip", true));
CfgPresetList.push_back(pair<string,bool>("FXAA", false));
CfgPresetList.push_back(pair<string,bool>("Bloom", false)); CfgPresetList.push_back(pair<string,bool>("Bloom", false));
CfgPresetList.push_back(pair<string,bool>("SquareBloom", false)); CfgPresetList.push_back(pair<string,bool>("SquareBloom", false));
CfgPresetList.push_back(pair<string,bool>("DensityBloom", true)); CfgPresetList.push_back(pair<string,bool>("DensityBloom", true));

View file

@ -45,6 +45,7 @@
#include "nel/3d/stereo_hmd.h" #include "nel/3d/stereo_hmd.h"
#include "nel/3d/render_target_manager.h" #include "nel/3d/render_target_manager.h"
#include "nel/3d/driver_user.h" #include "nel/3d/driver_user.h"
#include "nel/3d/fxaa.h"
// game share // game share
#include "game_share/brick_types.h" #include "game_share/brick_types.h"
#include "game_share/light_cycle.h" #include "game_share/light_cycle.h"
@ -1630,7 +1631,7 @@ bool mainLoop()
bool effectRender = false; bool effectRender = false;
CTextureUser *effectRenderTarget = NULL; CTextureUser *effectRenderTarget = NULL;
bool haveEffects = Render && Driver->getPolygonMode() == UDriver::Filled bool haveEffects = Render && Driver->getPolygonMode() == UDriver::Filled
&& ClientCfg.Bloom; && (ClientCfg.Bloom || FXAA);
bool defaultRenderTarget = false; bool defaultRenderTarget = false;
if (haveEffects) if (haveEffects)
{ {
@ -1733,6 +1734,7 @@ bool mainLoop()
if (StereoDisplay) Driver->setViewport(NL3D::CViewport()); if (StereoDisplay) Driver->setViewport(NL3D::CViewport());
UCamera pCam = Scene->getCam(); UCamera pCam = Scene->getCam();
Driver->setMatrixMode2D11(); Driver->setMatrixMode2D11();
if (FXAA) FXAA->applyEffect();
if (ClientCfg.Bloom) CBloomEffect::instance().applyBloom(); if (ClientCfg.Bloom) CBloomEffect::instance().applyBloom();
Driver->setMatrixMode3D(pCam); Driver->setMatrixMode3D(pCam);
if (StereoDisplay) Driver->setViewport(StereoDisplay->getCurrentViewport()); if (StereoDisplay) Driver->setViewport(StereoDisplay->getCurrentViewport());

View file

@ -19,6 +19,7 @@
#include <nel/3d/u_driver.h> #include <nel/3d/u_driver.h>
#include <nel/3d/u_cloud_scape.h> #include <nel/3d/u_cloud_scape.h>
#include <nel/3d/fxaa.h>
#include "game_share/scenario_entry_points.h" #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 // GRAPHICS - CHARACTERS
//--------------------------------------------------- //---------------------------------------------------
if (ClientCfg.SkinNbMaxPoly != LastClientCfg.SkinNbMaxPoly) if (ClientCfg.SkinNbMaxPoly != LastClientCfg.SkinNbMaxPoly)

View file

@ -497,7 +497,8 @@ void releaseOutGame()
// Remove the Actions listener from the Events Server. // Remove the Actions listener from the Events Server.
EventsListener.removeFromServer(CInputHandlerManager::getInstance()->FilteredEventServer); EventsListener.removeFromServer(CInputHandlerManager::getInstance()->FilteredEventServer);
// Release Bloom // Release effects
delete FXAA; FXAA = NULL;
CBloomEffect::releaseInstance(); CBloomEffect::releaseInstance();
// Release Scene, textcontexts, materials, ... // Release Scene, textcontexts, materials, ...
@ -591,7 +592,8 @@ void release()
Driver->deleteTextContext(TextContext); Driver->deleteTextContext(TextContext);
TextContext = NULL; TextContext = NULL;
// Release Bloom // Release effects
delete FXAA; FXAA = NULL;
CBloomEffect::releaseInstance(); CBloomEffect::releaseInstance();
// Release Scene, textcontexts, materials, ... // Release Scene, textcontexts, materials, ...