Last patch regarding FXAA and external shader loading, I hope :)
Changes are here: http://forums.pcsx2.net/Thread-Custom-Shaders-for-GSdx?pid=343285#pid343285
I've included bin\shader.fx and the settings file bin\GSdx_FX_Settings.ini.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5817 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
ramapcsx2.code 2014-01-17 10:17:24 +00:00
parent 8900a72115
commit f8264bce2c
16 changed files with 2430 additions and 1753 deletions

134
bin/GSdx_FX_Settings.ini Normal file
View File

@ -0,0 +1,134 @@
/*===============================================================================*\
|######################### [GSdx FX 2.00 Revised] ########################|
|########################### By Asmodean ##########################|
|| ||
|| This program is free software; you can redistribute it and/or ||
|| modify it under the terms of the GNU General Public License ||
|| as published by the Free Software Foundation; either version 2 ||
|| of the License, or (at your option) any later version. ||
|| ||
|| This program is distributed in the hope that it will be useful, ||
|| but WITHOUT ANY WARRANTY; without even the implied warranty of ||
|| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ||
|| GNU General Public License for more details. (c)2014 ||
|| ||
|#################################################################################|
\*===============================================================================*/
/*------------------------------------------------------------------------------
[DEFINITIONS & ON/OFF OPTIONS]
------------------------------------------------------------------------------*/
//---------------------------#[CHOOSE EFFECTS]#--------------------------------\\
//-#[ANTIALIASING TECHNIQUES] [1=ON|0=OFF] #READ: For best results: Use post antialiasing OR FS filtering. Not both. Postfix [2D/3D] after descriptions indicates if it's typically better for 2D, or 3D.
#define UHQ_FXAA 0 //#High Quality Fast Approximate Anti Aliasing. Adapted for GSdx from Timothy Lottes FXAA 3.11. If using GSdx's internal FXAA, this will act as a second pass, for increased quality & coverage. [3D]
//-#[FS FILTERING TECHNIQUES] [1=ON|0=OFF] #READ: For best results: Only enable one type of filtering at one time. Use post antialiasing OR FS filtering, not both.
#define BILINEAR_FILTERING 0 //#BiLinear Fullscreen Texture Filtering. BiLinear filtering - light to medium filtering of textures. [2D]
#define BICUBIC_FILTERING 0 //#BiCubic Fullscreen Texture Filtering. BiCubic filtering - medium to strong filtering of textures. [2D]
#define GAUSSIAN_FILTERING 0 //#Gaussian Fullscreen Texture Filtering. BiLinear filtering - strong to extra strong filtering of textures. [2D]
//-#[LIGHTING & COLOUR] [1=ON|0=OFF] #READ: These can all be turned on & off independently of each other. [For High Dynamic Range(HDR) - use Bloom, Tonemapping, & Gamma Correction together]
#define BLENDED_BLOOM 1 //#High Quality Bloom, using blend techniques. Blooms naturally, per environment. [For best results: use bloom, tone mapping, & gamma together].
#define SCENE_TONEMAPPING 1 //#Scene Tonemapping & RGB Colour Correction. [For best results: use bloom, tone mapping, & gamma together].
#define GAMMA_CORRECTION 1 //#RGB Post Gamma Correction Curve. [For best results: use bloom, tone mapping, & gamma together].
#define S_CURVE_CONTRAST 1 //#S-Curve Scene Contrast Enhancement. Naturally adjusts contrast using S-curves.
#define TEXTURE_SHARPENING 1 //#HQ Luma-Based Texture Sharpen, looks similar to a negative mip LOD Bias, enhances texture fidelity.
#define PIXEL_VIBRANCE 0 //#Pixel Vibrance. Intelligently adjusts pixel vibrance depending on original saturation.
#define COLOR_GRADING 0 //#Post-Complement Colour Grading. Alters individual colour components on a scene, to enhance selected colour tones.
#define CEL_SHADING 0 //#Cel Shaded toon look, simulates the look of animation/toon. Typically best suited for animated-style games. (cel edges interfere with post AA.)
//-#[TV EMU TECHNIQUES] [1=ON|0=OFF] #READ: These can all be turned on & off independently of each other. These effects are typically used to simulated older TVs/CRT etc.
#define SCANLINES 0 //#Scanlines to simulate the look of a CRT TV. Typically best suited for 2D/sprite games.
#define VIGNETTE 0 //#Darkens the edges of the screen, to make it look more like it was shot with a camera lens.
#define DITHERING 0 //#Subpixel Dithering to simulate more colors than your monitor can display. Smoothes gradiants, this can reduce color banding.
/*------------------------------------------------------------------------------
[SHADER FX CONFIG OPTIONS]
------------------------------------------------------------------------------*/
//-[FXAA OPTIONS]
#define FxaaSubpixMax 0.25 //[0.00 to 1.00] Amount of subpixel aliasing removal. Higher values: more subpixel antialiasing(softer). Lower values: less subpixel antialiasing(sharper). 0.00: Edge only antialiasing (no blurring)
#define FxaaQuality 4 //[1|2|3|4] Overall Fxaa quality preset (pixel coverage). 1: Low, 2: Medium, 3: High, 4: Ultra. I use these labels lightly, as even the 'low coverage' preset is in fact, still pretty high quality.
#define FxaaEarlyExit 1 //[0 or 1] Use Fxaa early exit pathing. This basically tells the algorithm to offset only luma-edge detected pixels. When disabled, the entire scene is antialiased(FSAA). 0 is off, 1 is on.
//-[BILINEAR OPTIONS]
#define FilterStrength 1.00 //[0.10 to 1.50] Bilinear filtering strength. Controls the overall strength of the filtering.
#define OffsetAmount 0.0 //[0.0 to 1.5] Pixel offset amount. If you want to use an st offset, 0.5 is generally recommended. 0.0 is off.
//-[BICUBIC OPTIONS]
#define Interpolation Triangular //[CatMullRom, Bell, BSpline, Triangular, Cubic] Type of interpolation to use. From left to right is lighter<-->stronger filtering. Try them out, and use what you prefer.
#define BicubicStrength 0.75 //[0.10 to 1.50] Bicubic filtering strength. Controls the overall strength of the filtering.
#define PixelOffset 0.0 //[0.0 to 1.5] Pixel offset amount. If you want to use an st offset, 0.5 is generally recommended. 0.0 is off.
//-[GAUSSIAN OPTIONS]
#define FilterAmount 1.00 //[0.10 to 1.50] Gaussian filtering strength. Controls the overall strength of the filtering.
#define GaussianSpread 0.75 //[0.50 to 4.00] The filtering spread & offset levels. Controls the sampling spread of the filtering.
//-[BLOOM OPTIONS]
#define BloomType BlendBloom //[BlendBloom, BlendScreen, BlendOverlay, BlendAddLight] The type of blend for the bloom (Default: BlendScreen). If using BlendOverlay set ToneAmount to 2.20, or it may be too dark.
#define BloomPower 0.250 //[0.000 to 2.000] Strength of the bloom. You may need to readjust for each blend type.
#define BlendPower 1.000 //[0.000 to 1.500] Strength of the bloom blend. Lower for less blending, higher for more. Default is 1.000.
#define BlendSpread 4.000 //[0.000 to 8.000] Width of the bloom glow spread. Scales with BloomPower. Raising SharpenClamp affects this. 0.000 = off.
#define BloomMixType 1 //[1|2|3] The interpolation mix type between the base colour, and bloom. (Default is 1) BloomPower/BlendSpread may need re-adjusting depending on type.
//-[TONEMAP OPTIONS]
#define TonemapType 1 //[1 or 2] Type of tone mapping. 1 is Natural(default), 2 is Filmic(cinematic) You might want to increase/decrease ToneAmount to compensate for diff types.
#define ToneAmount 2.02 //[1.00 to 4.00] Tonemapping & Gamma curve (Tonemapping/Shadow correction). Lower values for darker tones, Higher values for lighter tones. Default: 2.20
#define Luminance 1.00 //[0.10 to 2.00] Luminance Average (luminance correction) Higher values to decrease luminance average, lower values to increase luminance. Adjust by small amounts, eg: increments of 0.1
#define Exposure 1.00 //[0.10 to 2.00] White Correction (brightness) Higher values = more Exposure, lower = less Exposure. Adjust by small amounts, eg: increments of 0.1
#define WhitePoint 1.00 //[0.10 to 2.00] Whitepoint Avg (lum correction) Adjust by small amounts, eg: increments of 0.01. Generally it's best left at 1.00.
#define RedCurve 1.00 //[1.00 to 8.00] Red channel component of the RGB correction curve. Use this to reduce/correct the red colour component. Higher values equals more red reduction. 1.00 is default.
#define GreenCurve 1.00 //[1.00 to 8.00] Green channel component of the RGB correction curve. Use this to reduce/correct the green colour component. Higher values equals more green reduction. 1.00 is default.
#define BlueCurve 1.00 //[1.00 to 8.00] Blue channel component of the RGB correction curve. Use this to reduce/correct the blue colour component. Higher values equals more blue reduction. 1.00 is default.
//-[CONTRAST OPTIONS]
#define CurveType 0 //[0|1|2] Choose what to apply contrast to. 0 = Luma, 1 = Chroma, 2 = both Luma and Chroma. Default is 0 (Luma)
#define CurvesContrast 0.50 //[0.00 to 2.00] The amount of contrast you want. Controls the overall strength of the texture sharpening.
//-[SHARPEN OPTIONS]
#define SharpeningType 2 //[1 or 2] The type of sharpening to use. Type 1 is the original High Pass Gaussian, and type 2 is a new Bicubic Sampling type.
#define SharpenStrength 0.75 //[0.10 to 2.00] Strength of the texture sharpening effect. This is the maximum strength that will be used. The clamp below limits the minimum, and maximum that is allowed per pixel.
#define SharpenClamp 0.015 //[0.005 to 0.500] Reduces the clamping/limiting on the maximum amount of sharpening each pixel recieves. Raise this to reduce the clamping.
#define SharpenBias 1.50 //[1.00 to 4.00] Sharpening edge bias. Lower values for clean subtle sharpen, and higher values for a deeper textured sharpen. For SharpeningType 2, best stay under ~2.00, or it may look odd.
#define DebugSharpen 0 //[0 or 1] Visualize the sharpening effect. Useful for fine-tuning.
//-[VIBRANCE OPTIONS]
#define Vibrance 0.10 //[-1.00 to 1.00] Intelligently saturates (or desaturates with negative values) pixels depending on their original saturation. 0.00 is original vibrance.
//-[GAMMA OPTIONS]
#define Gamma 2.2 //Lower values for more Gamma toning(darker), higher Values for brighter (2.2 correction is generally recommended)
//-[GRADING OPTIONS]
#define RedGrading 1.02 //[0.0 to 3.0] Red colour grading coefficient. Adjust to influence the red channel coefficients of the grading, and highlight tones.
#define GreenGrading 0.96 //[0.0 to 3.0] Green colour grading coefficient. Adjust to influence the Green channel coefficients of the grading, and highlight tones.
#define BlueGrading 0.88 //[0.0 to 3.0] Blue colour grading coefficient. Adjust to influence the Blue channel coefficients of the grading, and highlight tones.
#define GradingStrength 0.40 //[0.00 to 1.00] The overall max strength of the colour grading effect. Raise to increase, lower to decrease the amount.
#define Correlation 0.50 //[0.10 to 1.00] Correlation between the base colour, and the grading influence. Lower = more of the scene is graded, Higher = less of the scene is graded.
//-[TOON OPTIONS]
#define EdgeStrength 1.40 //[0.00 to 4.00] Strength of the cel edge outline effect. 0.00 = no outlines.
#define EdgeFilter 0.60 //[0.10 to 2.00] Raise this to filter out fainter cel edges. You might need to increase the power to compensate, when raising this.
#define EdgeThickness 1.25 //[0.50 to 4.00] Thickness of the cel edges. Decrease for thinner outlining, Increase for thicker outlining. 1.00 is default.
#define PaletteType 2 //[1|2|3] The colour palette to use. 1 is Original, 2 is Animated Shading, 3 is Water Painting (Default is 2: Animated Shading). Below options don't affect palette 1.
#define UseYuvLuma 0 //[0 or 1] Uses YUV luma calculations, or base colour luma calculations. 0 is base luma, 1 is Yuv luma. Color luma can be more accurate. Yuv luma can be better for a shaded look.
#define LumaConversion 1 //[0 or 1] Uses BT.601, or BT.709, RGB<-YUV->RGB conversions. Some games prefer 601, but most prefer 709. BT.709 is typically recommended.
#define ColorRounding 0 //[0 or 1] Uses rounding methods on colors. This can emphasise shaded toon colors. Looks good in some games, and odd in others. Try it in-game and see.
//-[SCANLINE OPTIONS]
#define ScanlineType 3 //[0|1|2|3] The type & orientation of the scanlines. 0 is x(horizontal), 1 is y(vertical), 2 is both(xy), ScanlineType 3 is a different algorithm, to work around PCSX2's IR scaling.
#define ScanlineScale 1.00 //[0.20 to 2.00] The scaling & thickness of the scanlines. Changing this can help with PCSX2 IR scaling problems. Defaults: 0.50 for ScanlineType 0|1|2, (1.20 for ScanlineType 3, use 1.0 with low IR (lower than 3x)).
#define ScanlineIntensity 0.50 //[0.10 to 1.00] The intensity of the scanlines. Defaults: 0.20 for ScanlineType 0|1|2, 0.50 for ScanlineType 3.
#define ScanlineBrightness 1.50 //[0.50 to 2.00] The brightness of the scanlines. Defaults: 1.75 for ScanlineType 0|1|2, 1.50 for ScanlineType 3.
//-[VIGNETTE OPTIONS]
#define VignetteRatio 1.77 //[0.15 to 6.00] Sets the espect ratio of the vignette. 1.77 for 16:9, 1.60 for 16:10, 1.33 for 4:3, 1.00 for 1:1.
#define VignetteRadius 1.00 //[0.50 to 3.00] Radius of the vignette effect. Lower values for stronger radial effect from center
#define VignetteAmount 0.15 //[0.00 to 2.00] Strength of black edge occlusion. Increase for higher strength, decrease for lower.
#define VignetteSlope 8 //[2|4|8|12|16] How far away from the center the vignetting will start.
//-[DITHERING OPTIONS]
#define DitherMethod 2 //[1 or 2] 1 is Ordering dithering(faster, lower quality), 2 is Random dithering (better dithering, but not as fast)
//-[END OF USER OPTIONS]

1658
bin/shader.fx Normal file

File diff suppressed because it is too large Load Diff

View File

@ -37,6 +37,7 @@ GPURenderer::GPURenderer(GSDevice* dev)
m_aspectratio = theApp.GetConfig("AspectRatio", 1);
m_vsync = !!theApp.GetConfig("vsync", 0);
m_fxaa = !!theApp.GetConfig("fxaa", 0);
m_shaderfx = !!theApp.GetConfig("shaderfx", 0);
m_scale = m_mem.GetScale();
m_shadeboost = !!theApp.GetConfig("ShadeBoost", 0);
@ -125,6 +126,11 @@ bool GPURenderer::Merge()
m_dev->ShadeBoost();
}
if (m_shaderfx)
{
m_dev->ExternalFX();
}
if(m_fxaa)
{
m_dev->FXAA();
@ -252,6 +258,9 @@ LRESULT GPURenderer::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
case VK_PRIOR:
m_fxaa = !m_fxaa;
return 0;
case VK_HOME:
m_shaderfx = !m_shaderfx;
return 0;
}
}

View File

@ -38,6 +38,7 @@ protected:
int m_dither;
int m_aspectratio;
bool m_vsync;
bool m_shaderfx;
bool m_fxaa;
bool m_shadeboost;
GSVector2i m_scale;

View File

@ -31,6 +31,7 @@ GSDevice::GSDevice()
, m_merge(NULL)
, m_weavebob(NULL)
, m_blend(NULL)
, m_shaderfx(NULL)
, m_fxaa(NULL)
, m_shadeboost(NULL)
, m_1x1(NULL)
@ -48,6 +49,7 @@ GSDevice::~GSDevice()
delete m_merge;
delete m_weavebob;
delete m_blend;
delete m_shaderfx;
delete m_fxaa;
delete m_shadeboost;
delete m_1x1;
@ -70,6 +72,7 @@ bool GSDevice::Reset(int w, int h)
delete m_merge;
delete m_weavebob;
delete m_blend;
delete m_shaderfx;
delete m_fxaa;
delete m_shadeboost;
delete m_1x1;
@ -78,6 +81,7 @@ bool GSDevice::Reset(int w, int h)
m_merge = NULL;
m_weavebob = NULL;
m_blend = NULL;
m_shaderfx = NULL;
m_fxaa = NULL;
m_shadeboost = NULL;
m_1x1 = NULL;
@ -299,6 +303,26 @@ void GSDevice::Interlace(const GSVector2i& ds, int field, int mode, float yoffse
}
}
void GSDevice::ExternalFX()
{
GSVector2i s = m_current->GetSize();
if (m_shaderfx == NULL || m_shaderfx->GetSize() != s)
{
delete m_shaderfx;
m_shaderfx = CreateRenderTarget(s.x, s.y, false);
}
if (m_shaderfx != NULL)
{
GSVector4 sr(0, 0, 1, 1);
GSVector4 dr(0, 0, s.x, s.y);
StretchRect(m_current, sr, m_shaderfx, dr, 7, false);
DoExternalFX(m_shaderfx, m_current);
}
}
void GSDevice::FXAA()
{
GSVector2i s = m_current->GetSize();
@ -306,7 +330,6 @@ void GSDevice::FXAA()
if(m_fxaa == NULL || m_fxaa->GetSize() != s)
{
delete m_fxaa;
m_fxaa = CreateRenderTarget(s.x, s.y, false);
}
@ -316,7 +339,6 @@ void GSDevice::FXAA()
GSVector4 dr(0, 0, s.x, s.y);
StretchRect(m_current, sr, m_fxaa, dr, 7, false);
DoFXAA(m_fxaa, m_current);
}
}

View File

@ -46,6 +46,15 @@ public:
InterlaceConstantBuffer() {memset(this, 0, sizeof(*this));}
};
class ExternalFXConstantBuffer
{
public:
GSVector4 rcpFrame;
GSVector4 rcpFrameOpt;
ExternalFXConstantBuffer() { memset(this, 0, sizeof(*this)); }
};
class FXAAConstantBuffer
{
public:
@ -78,6 +87,7 @@ protected:
GSTexture* m_merge;
GSTexture* m_weavebob;
GSTexture* m_blend;
GSTexture* m_shaderfx;
GSTexture* m_fxaa;
GSTexture* m_shadeboost;
GSTexture* m_1x1;
@ -93,6 +103,7 @@ protected:
virtual void DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool linear, float yoffset) = 0;
virtual void DoFXAA(GSTexture* st, GSTexture* dt) {}
virtual void DoShadeBoost(GSTexture* st, GSTexture* dt) {}
virtual void DoExternalFX(GSTexture* st, GSTexture* dt) {}
public:
GSDevice();
@ -150,6 +161,7 @@ public:
void Interlace(const GSVector2i& ds, int field, int mode, float yoffset);
void FXAA();
void ShadeBoost();
void ExternalFX();
bool ResizeTexture(GSTexture** t, int w, int h);

View File

@ -264,7 +264,19 @@ bool GSDevice11::Create(GSWnd* wnd)
CompileShader(IDR_SHADEBOOST_FX, "ps_main", macro, &m_shadeboost.ps);
// fxaa
// External fx shader
memset(&bd, 0, sizeof(bd));
bd.ByteWidth = sizeof(ExternalFXConstantBuffer);
bd.Usage = D3D11_USAGE_DEFAULT;
bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
hr = m_dev->CreateBuffer(&bd, NULL, &m_shaderfx.cb);
ExShader_Compiled = false;
// Fxaa
memset(&bd, 0, sizeof(bd));
@ -275,23 +287,6 @@ bool GSDevice11::Create(GSWnd* wnd)
hr = m_dev->CreateBuffer(&bd, NULL, &m_fxaa.cb);
FFXA_Compiled = false;
/*
if (Use_FXAA_Shader)
{
#if EXTERNAL_SHADER_LOADING
try {
CompileShader("shader.fx", "ps_main", NULL, &m_fxaa.ps);
}
catch (GSDXRecoverableError) {
CompileShader(IDR_FXAA_FX, "ps_main", NULL, &m_fxaa.ps);
}
#else
// internal shader
CompileShader(IDR_FXAA_FX, "ps_main", NULL, &m_fxaa.ps);
#endif
FFXA_Compiled = true;
}*/
//
memset(&rd, 0, sizeof(rd));
@ -740,23 +735,53 @@ void GSDevice11::DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool line
StretchRect(st, sr, dt, dr, m_interlace.ps[shader], m_interlace.cb, linear);
}
//Included an init function for this also. Just to be safe.
void GSDevice11::InitExternalFX()
{
if (!ExShader_Compiled)
{
try {
CompileShader("shader.fx", "ps_main", NULL, &m_shaderfx.ps);
}
catch (GSDXRecoverableError) {
CompileShader(IDR_FXAA_FX, "ps_recover", NULL, &m_fxaa.ps);
}
ExShader_Compiled = true;
}
}
void GSDevice11::DoExternalFX(GSTexture* st, GSTexture* dt)
{
GSVector2i s = dt->GetSize();
GSVector4 sr(0, 0, 1, 1);
GSVector4 dr(0, 0, s.x, s.y);
ExternalFXConstantBuffer cb;
InitExternalFX();
cb.rcpFrame = GSVector4(1.0f / s.x, 1.0f / s.y, 0.0f, 0.0f);
cb.rcpFrameOpt = GSVector4::zero();
m_ctx->UpdateSubresource(m_shaderfx.cb, 0, NULL, &cb, 0, 0);
StretchRect(st, sr, dt, dr, m_shaderfx.ps, m_shaderfx.cb, true);
}
// This shouldn't be necessary, we have some bug corrupting memory
// and for some reason isolating this code makes the plugin not crash
void GSDevice11::InitFXAA()
{
if (!FFXA_Compiled)
{
#if EXTERNAL_SHADER_LOADING
try {
CompileShader("shader.fx", "ps_main", NULL, &m_fxaa.ps);
}
catch (GSDXRecoverableError) {
CompileShader(IDR_FXAA_FX, "ps_main", NULL, &m_fxaa.ps);
}
#else
try {
CompileShader(IDR_FXAA_FX, "ps_main", NULL, &m_fxaa.ps);
#endif
FFXA_Compiled = true;
}
catch (GSDXRecoverableError) {
CompileShader(IDR_FXAA_FX, "ps_recover", NULL, &m_fxaa.ps);
}
FFXA_Compiled = true;
}
}
@ -770,6 +795,7 @@ void GSDevice11::DoFXAA(GSTexture* st, GSTexture* dt)
FXAAConstantBuffer cb;
InitFXAA();
cb.rcpFrame = GSVector4(1.0f / s.x, 1.0f / s.y, 0.0f, 0.0f);
cb.rcpFrameOpt = GSVector4::zero();

View File

@ -38,7 +38,9 @@ class GSDevice11 : public GSDeviceDX
void DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool linear, float yoffset = 0);
void DoFXAA(GSTexture* st, GSTexture* dt);
void DoShadeBoost(GSTexture* st, GSTexture* dt);
void DoExternalFX(GSTexture* st, GSTexture* dt);
void InitExternalFX();
void InitFXAA(); // Bug workaround! Stack corruption? Heap corruption? No idea
//
@ -85,6 +87,7 @@ public: // TODO
bool UserHacks_NVIDIAHack;
bool FFXA_Compiled;
bool ExShader_Compiled;
struct
{
@ -110,6 +113,12 @@ public: // TODO
CComPtr<ID3D11Buffer> cb;
} m_interlace;
struct
{
CComPtr<ID3D11PixelShader> ps;
CComPtr<ID3D11Buffer> cb;
} m_shaderfx;
struct
{
CComPtr<ID3D11PixelShader> ps;

View File

@ -359,6 +359,7 @@ bool GSDevice9::Create(GSWnd* wnd)
CompileShader(IDR_SHADEBOOST_FX, "ps_main", macro, &m_shadeboost.ps);
ExShader_Compiled = false;
FFXA_Compiled = false;
/*
// fxaa
@ -934,6 +935,34 @@ void GSDevice9::DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool linea
StretchRect(st, sr, dt, dr, m_interlace.ps[shader], (const float*)&cb, 1, linear);
}
void GSDevice9::DoExternalFX(GSTexture* st, GSTexture* dt)
{
GSVector2i s = dt->GetSize();
GSVector4 sr(0, 0, 1, 1);
GSVector4 dr(0, 0, s.x, s.y);
ExternalFXConstantBuffer cb;
if (!ExShader_Compiled)
{
try {
CompileShader("shader.fx", "ps_main", NULL, &m_shaderfx.ps);
}
catch (GSDXRecoverableError) {
CompileShader(IDR_FXAA_FX, "ps_recover", NULL, &m_fxaa.ps);
}
ExShader_Compiled = true;
}
cb.rcpFrame = GSVector4(1.0f / s.x, 1.0f / s.y, 0.0f, 0.0f);
cb.rcpFrameOpt = GSVector4::zero();
StretchRect(st, sr, dt, dr, m_shaderfx.ps, (const float*)&cb, 2, true);
}
void GSDevice9::DoFXAA(GSTexture* st, GSTexture* dt)
{
GSVector2i s = dt->GetSize();
@ -945,17 +974,13 @@ void GSDevice9::DoFXAA(GSTexture* st, GSTexture* dt)
if (!FFXA_Compiled)
{
#if EXTERNAL_SHADER_LOADING
try {
CompileShader("shader.fx", "ps_main", NULL, &m_fxaa.ps);
}
catch (GSDXRecoverableError) {
CompileShader(IDR_FXAA_FX, "ps_main", NULL, &m_fxaa.ps);
}
#else
CompileShader(IDR_FXAA_FX, "ps_main", NULL, &m_fxaa.ps);
#endif
FFXA_Compiled = true;
try {
CompileShader(IDR_FXAA_FX, "ps_main", NULL, &m_fxaa.ps);
}
catch (GSDXRecoverableError) {
CompileShader(IDR_FXAA_FX, "ps_recover", NULL, &m_fxaa.ps);
}
FFXA_Compiled = true;
}
cb.rcpFrame = GSVector4(1.0f / s.x, 1.0f / s.y, 0.0f, 0.0f);

View File

@ -73,6 +73,7 @@ class GSDevice9 : public GSDeviceDX
void DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool linear, float yoffset = 0);
void DoFXAA(GSTexture* st, GSTexture* dt);
void DoShadeBoost(GSTexture* st, GSTexture* dt);
void DoExternalFX(GSTexture* st, GSTexture* dt);
//
@ -114,6 +115,7 @@ class GSDevice9 : public GSDeviceDX
public: // TODO
bool FFXA_Compiled;
bool ExShader_Compiled;
struct
{
@ -137,6 +139,11 @@ public: // TODO
CComPtr<IDirect3DPixelShader9> ps[4];
} m_interlace;
struct
{
CComPtr<IDirect3DPixelShader9> ps;
} m_shaderfx;
struct
{
CComPtr<IDirect3DPixelShader9> ps;

View File

@ -41,6 +41,7 @@ GSRenderer::GSRenderer()
m_aa1 = !!theApp.GetConfig("aa1", 0);
m_mipmap = !!theApp.GetConfig("mipmap", 1);
m_fxaa = !!theApp.GetConfig("fxaa", 0);
m_shaderfx = !!theApp.GetConfig("shaderfx", 0);
m_shadeboost = !!theApp.GetConfig("ShadeBoost", 0);
}
@ -279,6 +280,11 @@ bool GSRenderer::Merge(int field)
m_dev->ShadeBoost();
}
if (m_shaderfx)
{
m_dev->ExternalFX();
}
if(m_fxaa)
{
m_dev->FXAA();
@ -566,7 +572,11 @@ void GSRenderer::KeyEvent(GSKeyEventData* e)
return;
case VK_PRIOR:
m_fxaa = !m_fxaa;
printf("GSdx: Post-processing shader is now %s.\n", m_fxaa ? "enabled" : "disabled");
printf("GSdx: FXAA anti-aliasing is now %s.\n", m_fxaa ? "enabled" : "disabled");
return;
case VK_HOME:
m_shaderfx = !m_shaderfx;
printf("GSdx: External post-processing is now %s.\n", m_shaderfx ? "enabled" : "disabled");
return;
}

View File

@ -47,6 +47,7 @@ protected:
bool m_aa1;
bool m_mipmap;
bool m_framelimit;
bool m_shaderfx;
bool m_fxaa;
bool m_shadeboost;

View File

@ -164,6 +164,9 @@ void GSSettingsDlg::OnInit()
// FXAA shader
CheckDlgButton(m_hWnd, IDC_FXAA, theApp.GetConfig("Fxaa", 0));
// External FX shader
CheckDlgButton(m_hWnd, IDC_SHADER_FX, theApp.GetConfig("shaderfx", 0));
// Hacks
CheckDlgButton(m_hWnd, IDC_HACKS_ENABLED, theApp.GetConfig("UserHacks", 0));
@ -274,6 +277,9 @@ bool GSSettingsDlg::OnCommand(HWND hWnd, UINT id, UINT code)
// FXAA shader
theApp.SetConfig("Fxaa", (int)IsDlgButtonChecked(m_hWnd, IDC_FXAA));
// External FX Shader
theApp.SetConfig("shaderfx", (int)IsDlgButtonChecked(m_hWnd, IDC_SHADER_FX));
theApp.SetConfig("UserHacks", (int)IsDlgButtonChecked(m_hWnd, IDC_HACKS_ENABLED));
}
break;

View File

@ -179,7 +179,8 @@ BEGIN
PUSHBUTTON "Configure...",IDC_HACKSBUTTON,88,275,87,14
LTEXT "Adapter:",IDC_STATIC,7,58,30,8
COMBOBOX IDC_ADAPTER,71,56,111,125,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "FXAA shader",IDC_FXAA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,221,55,10
CONTROL "Enable FXAA", IDC_FXAA, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 10, 187, 80, 10
CONTROL "Enable FX shader", IDC_SHADER_FX, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 92, 187, 80, 10
END
IDD_CAPTURE DIALOGEX 0, 0, 279, 71
@ -265,7 +266,8 @@ BEGIN
PUSHBUTTON "Configure...",IDC_HACKSBUTTON,95,242,75,14
LTEXT "Adapter:",IDC_STATIC,6,57,30,8
COMBOBOX IDC_ADAPTER,70,55,111,118,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "FXAA shader",IDC_FXAA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,188,55,10
CONTROL "Enable FXAA", IDC_FXAA, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 10, 187, 80, 10
CONTROL "Enable FX shader", IDC_SHADER_FX, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 92, 187, 80, 10
END

File diff suppressed because it is too large Load Diff

View File

@ -68,6 +68,7 @@
#define IDC_TCOFFSETY2 2085
#define IDC_FXAA 2086
#define IDC_CHECK_NVIDIA_HACK 2087
#define IDC_SHADER_FX 2088
#define IDC_COLORSPACE 3000
#define IDR_CONVERT_FX 10000
#define IDR_TFX_FX 10001
@ -87,7 +88,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 10012
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 2087
#define _APS_NEXT_CONTROL_VALUE 2089
#define _APS_NEXT_SYMED_VALUE 5000
#endif
#endif