GSdx: Just some cleaning.

Reformatted fx files that were causing issues on certain text editors. They should now display correctly in those editors.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5897 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Asmodean.pcsx2 2014-02-11 04:27:32 +00:00
parent 7d96af950e
commit 0651e45460
3 changed files with 798 additions and 876 deletions

View File

@ -1,6 +1,6 @@
/*===============================================================================*\
|######################### [GSdx FX 2.00 Revised] ########################|
|########################### By Asmodean ##########################|
|######################## [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 ||
@ -14,9 +14,8 @@
|| ||
|#################################################################################|
\*===============================================================================*/
//NOTICE: This shader suite requires DirectX 10, or higher.
//If this file looks messy and/or text is misaligned: use another text editor instead of regular MS Notepad.
//Recommended: Notepad++ http://notepad-plus-plus.org/download/v6.5.3.html
//NOTICE: This shader suite requires DirectX 10 (Shader Model 4.0), or higher.
/*------------------------------------------------------------------------------
[DEFINITIONS & ON/OFF OPTIONS]
------------------------------------------------------------------------------*/
@ -50,32 +49,32 @@
[SHADER FX CONFIG OPTIONS]
------------------------------------------------------------------------------*/
//-[FXAA 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]
//-#[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]
//-#[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]
//-#[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]
//-#[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.200 //[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]
//-#[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.15 //[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
@ -85,31 +84,31 @@
#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]
//-#[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]
//-#[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]
//-#[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]
//-#[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]
//-#[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]
//-#[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.
@ -118,19 +117,19 @@
#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]
//-#[SCANLINE OPTIONS]
#define ScanlineType 0 //[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 0.50 //[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.18 //[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 2.00 //[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]
//-#[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.25 //[0.00 to 1.00] Strength of black edge occlusion. Increase for higher strength, decrease for lower.
#define VignetteSlope 12 //[2|4|8|10|12|16] How far away from the center the vignetting will start.
//-[DITHERING OPTIONS]
//-#[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]

View File

@ -1,6 +1,6 @@
/*===============================================================================*\
|######################### [GSdx FX 2.00 Revised] #########################|
|########################### By Asmodean ##########################|
|######################## [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 ||
@ -21,7 +21,6 @@
------------------------------------------------------------------------------*/
Texture2D Texture : register(t0);
SamplerState TextureSampler : register(s0);
SamplerState BloomSampler : register(s1);
@ -70,7 +69,7 @@ float TrueLuminance(float3 color)
if (b <= r) { minRGB = b; }
if (b <= g) { minRGB = b; }
float lumin = ((maxRGB + minRGB)/2);
float lumin = ((maxRGB + minRGB) / 2);
return lumin;
}
@ -116,20 +115,6 @@ float3 LinearToRGBGamma(float3 color, float gamma)
#define GammaCorrection(color, gamma) pow(color, gamma)
#define InverseGammaCorrection(color, gamma) pow(color, 1.0/gamma)
/*------------------------------------------------------------------------------
[VERTEX CODE SECTION]
------------------------------------------------------------------------------*/
VS_OUTPUT vs_main(VS_INPUT input)
{
VS_OUTPUT output;
output.p = input.p;
output.t = input.t;
return output;
}
/*------------------------------------------------------------------------------
[GAMMA PREPASS CODE SECTION]
------------------------------------------------------------------------------*/
@ -150,94 +135,58 @@ float4 PreGammaPass(float4 color, float2 uv0)
#if (UHQ_FXAA == 1)
#if (SHADER_MODEL >= 0x500)
#define FXAA_HLSL_5 1
#define FXAA_GATHER4_ALPHA 1
#define FXAA_HLSL_5 1
#define FXAA_GATHER4_ALPHA 1
#elif (SHADER_MODEL >= 0x400)
#define FXAA_HLSL_4 1
#define FXAA_GATHER4_ALPHA 0
#define FXAA_HLSL_4 1
#define FXAA_GATHER4_ALPHA 0
#endif
#if (FxaaQuality == 4)
#define FxaaEdgeThreshold 0.033
#define FxaaEdgeThresholdMin 0.0
#define FXAA_QUALITY__PS 14
#define FXAA_QUALITY__P0 1.0
#define FXAA_QUALITY__P1 1.0
#define FXAA_QUALITY__P2 1.0
#define FXAA_QUALITY__P3 1.0
#define FXAA_QUALITY__P4 1.0
#define FXAA_QUALITY__P5 1.5
#define FXAA_QUALITY__P6 2.0
#define FXAA_QUALITY__P7 2.0
#define FXAA_QUALITY__P8 2.0
#define FXAA_QUALITY__P9 2.0
#define FXAA_QUALITY__P10 4.0
#define FXAA_QUALITY__P11 8.0
#define FXAA_QUALITY__P12 8.0
#define FxaaEdgeThreshold 0.033
#define FxaaEdgeThresholdMin 0.0
#elif (FxaaQuality == 3)
#define FxaaEdgeThreshold 0.125
#define FxaaEdgeThresholdMin 0.0312
#define FXAA_QUALITY__PS 12
#define FXAA_QUALITY__P0 1.0
#define FXAA_QUALITY__P1 1.5
#define FXAA_QUALITY__P2 2.0
#define FXAA_QUALITY__P3 2.0
#define FXAA_QUALITY__P4 2.0
#define FXAA_QUALITY__P5 2.0
#define FXAA_QUALITY__P6 2.0
#define FXAA_QUALITY__P7 2.0
#define FXAA_QUALITY__P8 2.0
#define FXAA_QUALITY__P9 2.0
#define FXAA_QUALITY__P10 4.0
#define FXAA_QUALITY__P11 8.0
#define FxaaEdgeThreshold 0.125
#define FxaaEdgeThresholdMin 0.0312
#elif (FxaaQuality == 2)
#define FxaaEdgeThreshold 0.166
#define FxaaEdgeThresholdMin 0.0625
#define FXAA_QUALITY__PS 10
#define FXAA_QUALITY__P0 1.0
#define FXAA_QUALITY__P1 1.5
#define FXAA_QUALITY__P2 2.0
#define FXAA_QUALITY__P3 2.0
#define FXAA_QUALITY__P4 2.0
#define FXAA_QUALITY__P5 2.0
#define FXAA_QUALITY__P6 2.0
#define FXAA_QUALITY__P7 2.0
#define FXAA_QUALITY__P8 4.0
#define FXAA_QUALITY__P9 8.0
#define FxaaEdgeThreshold 0.166
#define FxaaEdgeThresholdMin 0.0625
#elif (FxaaQuality == 1)
#define FxaaEdgeThreshold 0.250
#define FxaaEdgeThresholdMin 0.0833
#define FXAA_QUALITY__PS 8
#define FXAA_QUALITY__P0 1.0
#define FXAA_QUALITY__P1 1.5
#define FXAA_QUALITY__P2 2.0
#define FXAA_QUALITY__P3 2.0
#define FXAA_QUALITY__P4 2.0
#define FXAA_QUALITY__P5 2.0
#define FXAA_QUALITY__P6 4.0
#define FXAA_QUALITY__P7 12.0
#define FxaaEdgeThreshold 0.250
#define FxaaEdgeThresholdMin 0.0833
#endif
#if (FXAA_HLSL_5 == 1)
struct FxaaTex { SamplerState smpl; Texture2D tex; };
#define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)
#define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)
#define FxaaTexAlpha4(t, p) t.tex.GatherAlpha(t.smpl, p)
#define FxaaTexOffAlpha4(t, p, o) t.tex.GatherAlpha(t.smpl, p, o)
#define FxaaDiscard clip(-1)
#define FxaaSat(x) saturate(x)
struct FxaaTex { SamplerState smpl; Texture2D tex; };
#define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)
#define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)
#define FxaaTexAlpha4(t, p) t.tex.GatherAlpha(t.smpl, p)
#define FxaaTexOffAlpha4(t, p, o) t.tex.GatherAlpha(t.smpl, p, o)
#define FxaaDiscard clip(-1)
#define FxaaSat(x) saturate(x)
#elif (FXAA_HLSL_4 == 1)
struct FxaaTex { SamplerState smpl; Texture2D tex; };
#define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)
#define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)
#define FxaaDiscard clip(-1)
#define FxaaSat(x) saturate(x)
struct FxaaTex { SamplerState smpl; Texture2D tex; };
#define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)
#define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)
#define FxaaDiscard clip(-1)
#define FxaaSat(x) saturate(x)
#endif
#define FXAA_QUALITY__P0 1.0
#define FXAA_QUALITY__P1 1.0
#define FXAA_QUALITY__P2 1.0
#define FXAA_QUALITY__P3 1.0
#define FXAA_QUALITY__P4 1.0
#define FXAA_QUALITY__P5 1.5
#define FXAA_QUALITY__P6 2.0
#define FXAA_QUALITY__P7 2.0
#define FXAA_QUALITY__P8 2.0
#define FXAA_QUALITY__P9 2.0
#define FXAA_QUALITY__P10 4.0
#define FXAA_QUALITY__P11 8.0
#define FXAA_QUALITY__P12 8.0
float FxaaLuma(float4 rgba)
{
rgba.w = RGBLuminance(rgba.xyz);
@ -263,8 +212,8 @@ float4 FxaaPixelShader(float2 pos, FxaaTex tex, float2 fxaaRcpFrame, float fxaaS
#define lumaNW luma4B.w
#define lumaN luma4B.z
#define lumaW luma4B.x
#else
#else
float4 rgbyM = FxaaTexTop(tex, posM);
rgbyM.w = RGBLuminance(rgbyM.xyz);
#define lumaM rgbyM.w
@ -281,6 +230,7 @@ float4 FxaaPixelShader(float2 pos, FxaaTex tex, float2 fxaaRcpFrame, float fxaaS
float minESM = min(lumaE, minSM);
float maxWN = max(lumaN, lumaW);
float minWN = min(lumaN, lumaW);
float rangeMax = max(maxWN, maxESM);
float rangeMin = min(minWN, minESM);
float range = rangeMax - rangeMin;
@ -289,8 +239,7 @@ float4 FxaaPixelShader(float2 pos, FxaaTex tex, float2 fxaaRcpFrame, float fxaaS
bool earlyExit = range < rangeMaxClamped;
#if (FxaaEarlyExit == 1)
if(earlyExit)
{ return rgbyM; }
if(earlyExit) { return rgbyM; }
#endif
#if (FXAA_GATHER4_ALPHA == 0)
@ -309,7 +258,6 @@ float4 FxaaPixelShader(float2 pos, FxaaTex tex, float2 fxaaRcpFrame, float fxaaS
float subpixNSWE = lumaNS + lumaWE;
float edgeHorz1 = (-2.0 * lumaM) + lumaNS;
float edgeVert1 = (-2.0 * lumaM) + lumaWE;
float lumaNESE = lumaNE + lumaSE;
float lumaNWNE = lumaNW + lumaNE;
float edgeHorz2 = (-2.0 * lumaE) + lumaNESE;
@ -328,7 +276,6 @@ float4 FxaaPixelShader(float2 pos, FxaaTex tex, float2 fxaaRcpFrame, float fxaaS
float lengthSign = fxaaRcpFrame.x;
bool horzSpan = edgeHorz >= edgeVert;
float subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;
if(!horzSpan) lumaN = lumaW;
if(!horzSpan) lumaS = lumaE;
if(horzSpan) lengthSign = fxaaRcpFrame.y;
@ -351,6 +298,7 @@ float4 FxaaPixelShader(float2 pos, FxaaTex tex, float2 fxaaRcpFrame, float fxaaS
offNP.y = ( horzSpan) ? 0.0 : fxaaRcpFrame.y;
if(!horzSpan) posB.x += lengthSign * 0.5;
if( horzSpan) posB.y += lengthSign * 0.5;
float2 posN;
posN.x = posB.x - offNP.x * FXAA_QUALITY__P0;
posN.y = posB.y - offNP.y * FXAA_QUALITY__P0;
@ -390,7 +338,6 @@ float4 FxaaPixelShader(float2 pos, FxaaTex tex, float2 fxaaRcpFrame, float fxaaS
if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P2;
if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P2;
#if (FXAA_QUALITY__PS > 3)
if(doneNP) {
if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
@ -404,7 +351,6 @@ float4 FxaaPixelShader(float2 pos, FxaaTex tex, float2 fxaaRcpFrame, float fxaaS
if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P3;
if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P3;
#if (FXAA_QUALITY__PS > 4)
if(doneNP) {
if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
@ -418,7 +364,6 @@ float4 FxaaPixelShader(float2 pos, FxaaTex tex, float2 fxaaRcpFrame, float fxaaS
if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P4;
if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P4;
#if (FXAA_QUALITY__PS > 5)
if(doneNP) {
if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
@ -432,7 +377,6 @@ float4 FxaaPixelShader(float2 pos, FxaaTex tex, float2 fxaaRcpFrame, float fxaaS
if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P5;
if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P5;
#if (FXAA_QUALITY__PS > 6)
if(doneNP) {
if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
@ -446,7 +390,6 @@ float4 FxaaPixelShader(float2 pos, FxaaTex tex, float2 fxaaRcpFrame, float fxaaS
if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P6;
if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P6;
#if (FXAA_QUALITY__PS > 7)
if(doneNP) {
if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
@ -460,7 +403,6 @@ float4 FxaaPixelShader(float2 pos, FxaaTex tex, float2 fxaaRcpFrame, float fxaaS
if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P7;
if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P7;
#if (FXAA_QUALITY__PS > 8)
if(doneNP) {
if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
@ -474,7 +416,6 @@ float4 FxaaPixelShader(float2 pos, FxaaTex tex, float2 fxaaRcpFrame, float fxaaS
if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P8;
if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P8;
#if (FXAA_QUALITY__PS > 9)
if(doneNP) {
if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
@ -488,7 +429,6 @@ float4 FxaaPixelShader(float2 pos, FxaaTex tex, float2 fxaaRcpFrame, float fxaaS
if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P9;
if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P9;
#if (FXAA_QUALITY__PS > 10)
if(doneNP) {
if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
@ -502,7 +442,6 @@ float4 FxaaPixelShader(float2 pos, FxaaTex tex, float2 fxaaRcpFrame, float fxaaS
if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P10;
if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P10;
#if (FXAA_QUALITY__PS > 11)
if(doneNP) {
if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
@ -516,7 +455,6 @@ float4 FxaaPixelShader(float2 pos, FxaaTex tex, float2 fxaaRcpFrame, float fxaaS
if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P11;
if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P11;
#if (FXAA_QUALITY__PS > 12)
if(doneNP) {
if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
@ -529,27 +467,8 @@ float4 FxaaPixelShader(float2 pos, FxaaTex tex, float2 fxaaRcpFrame, float fxaaS
doneNP = (!doneN) || (!doneP);
if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P12;
if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P12;
}
#endif
}
#endif
}
#endif
}
#endif
}
#endif
}
#endif
}
#endif
}
#endif
}
#endif
}
#endif
}
}}}}}}}}}}}
float dstN = posM.x - posN.x;
float dstP = posP.x - posM.x;
if(!horzSpan) dstN = posM.y - posN.y;
@ -582,7 +501,7 @@ float4 FxaaPass(float4 FxaaColor : COLOR0, float2 uv0 : TEXCOORD0) : SV_Target0
tex.smpl = TextureSampler;
Texture.GetDimensions(PixelSize.x, PixelSize.y);
FxaaColor = FxaaPixelShader(uv0, tex, 1.0/PixelSize.xy, FxaaSubpixMax, FxaaEdgeThreshold, FxaaEdgeThresholdMin);
FxaaColor = FxaaPixelShader(uv0, tex, 1.0 / PixelSize.xy, FxaaSubpixMax, FxaaEdgeThreshold, FxaaEdgeThresholdMin);
return FxaaColor;
}
@ -596,17 +515,17 @@ float BSpline(float x)
{
float f = x;
if(f < 0.0)
if (f < 0.0)
{
f = -f;
}
if(f >= 0.0 && f <= 1.0)
if (f >= 0.0 && f <= 1.0)
{
return (2.0 / 3.0) + (0.5) * (f* f * f) - (f*f);
}
else if(f > 1.0 && f <= 2.0)
else if (f > 1.0 && f <= 2.0)
{
return 1.0 / 6.0 * pow(( 2.0 - f ), 3.0);
return 1.0 / 6.0 * pow((2.0 - f), 3.0);
}
return 1.0;
}
@ -617,22 +536,22 @@ float CatMullRom(float x)
float c = 0.5;
float f = x;
if( f < 0.0 )
if (f < 0.0)
{
f = -f;
}
if( f < 1.0 )
if (f < 1.0)
{
return ((12.0 - 9.0 * b - 6.0 * c) * (f * f * f) +
(-18.0 + 12.0 * b + 6.0 * c) * (f * f) +
(6.0 - 2.0 * b) ) / 6.0;
(6.0 - 2.0 * b)) / 6.0;
}
else if( f >= 1.0 && f < 2.0 )
else if (f >= 1.0 && f < 2.0)
{
return (( -b - 6.0 * c) * (f * f * f)
return ((-b - 6.0 * c) * (f * f * f)
+ (6.0 * b + 30.0 * c) * (f *f) +
(- (12.0 * b) - 48.0 * c ) * f +
8.0 * b + 24.0 * c)/ 6.0;
(-(12.0 * b) - 48.0 * c) * f +
8.0 * b + 24.0 * c) / 6.0;
}
else
{
@ -644,15 +563,15 @@ float Bell(float x)
{
float f = (x / 2.0) * 1.5;
if(f > -1.5 && f < -0.5)
if (f > -1.5 && f < -0.5)
{
return(0.5 * pow(f + 1.5, 2.0));
}
else if(f > -0.5 && f < 0.5)
else if (f > -0.5 && f < 0.5)
{
return 3.0 / 4.0 - (f * f);
}
else if(( f > 0.5 && f < 1.5 ))
else if ((f > 0.5 && f < 1.5))
{
return(0.5 * pow(f - 1.5, 2.0));
}
@ -663,7 +582,7 @@ float Triangular(float x)
{
x = x / 2.0;
if(x < 0.0)
if (x < 0.0)
{
return (x + 1.0);
}
@ -711,7 +630,7 @@ float4 SampleBiLinear(SamplerState texSample, float2 uv0 : TEXCOORD0) : SV_Targe
// Take nearest two data in bottom row.
float4 SampleC = Texture.Sample(texSample, uvCoord + float2(0.0, texelSizeY));
float4 SampleD = Texture.Sample(texSample, uvCoord + float2(texelSizeX , texelSizeY));
float4 SampleD = Texture.Sample(texSample, uvCoord + float2(texelSizeX, texelSizeY));
float LX = frac(uv0.x * PixelSize.x); //Get Interpolation factor for X direction.
@ -754,12 +673,12 @@ float4 BiCubicFilter(SamplerState texSample, float2 uv0 : TEXCOORD0) : SV_Target
int nX = int(uv0.x * PixelSize.x);
int nY = int(uv0.y * PixelSize.y);
float2 uvCoord = float2( float(nX) / PixelSize.x + PixelOffset / PixelSize.x,
float(nY) / PixelSize.y + PixelOffset / PixelSize.y );
float2 uvCoord = float2(float(nX) / PixelSize.x + PixelOffset / PixelSize.x,
float(nY) / PixelSize.y + PixelOffset / PixelSize.y);
for(int m = -1; m <= 2; m++)
for (int m = -1; m <= 2; m++)
{
for(int n = -1; n <= 2; n++)
for (int n = -1; n <= 2; n++)
{
float4 Samples = Texture.Sample(texSample, uvCoord +
float2(texelSizeX * float(m), texelSizeY * float(n)));
@ -802,34 +721,34 @@ float4 GaussianPass(float4 color : COLOR0, float2 uv0 : TEXCOORD0) : SV_Target0
float4 gaussian = Texture.Sample(TextureSampler, uv0);
gaussian += Texture.Sample(TextureSampler, uv0 -dx2 +dy2);
gaussian += Texture.Sample(TextureSampler, uv0 -dx +dy2);
gaussian += Texture.Sample(TextureSampler, uv0 +dy2);
gaussian += Texture.Sample(TextureSampler, uv0 +dx +dy2);
gaussian += Texture.Sample(TextureSampler, uv0 +dx2 +dy2);
gaussian += Texture.Sample(TextureSampler, uv0 - dx2 + dy2);
gaussian += Texture.Sample(TextureSampler, uv0 - dx + dy2);
gaussian += Texture.Sample(TextureSampler, uv0 + dy2);
gaussian += Texture.Sample(TextureSampler, uv0 + dx + dy2);
gaussian += Texture.Sample(TextureSampler, uv0 + dx2 + dy2);
gaussian += Texture.Sample(TextureSampler, uv0 -dx2 +dy);
gaussian += Texture.Sample(TextureSampler, uv0 -dx +dy);
gaussian += Texture.Sample(TextureSampler, uv0 +dy);
gaussian += Texture.Sample(TextureSampler, uv0 +dx +dy);
gaussian += Texture.Sample(TextureSampler, uv0 +dx2 +dy);
gaussian += Texture.Sample(TextureSampler, uv0 - dx2 + dy);
gaussian += Texture.Sample(TextureSampler, uv0 - dx + dy);
gaussian += Texture.Sample(TextureSampler, uv0 + dy);
gaussian += Texture.Sample(TextureSampler, uv0 + dx + dy);
gaussian += Texture.Sample(TextureSampler, uv0 + dx2 + dy);
gaussian += Texture.Sample(TextureSampler, uv0 -dx2);
gaussian += Texture.Sample(TextureSampler, uv0 -dx);
gaussian += Texture.Sample(TextureSampler, uv0 +dx);
gaussian += Texture.Sample(TextureSampler, uv0 +dx2);
gaussian += Texture.Sample(TextureSampler, uv0 - dx2);
gaussian += Texture.Sample(TextureSampler, uv0 - dx);
gaussian += Texture.Sample(TextureSampler, uv0 + dx);
gaussian += Texture.Sample(TextureSampler, uv0 + dx2);
gaussian += Texture.Sample(TextureSampler, uv0 -dx2 -dy);
gaussian += Texture.Sample(TextureSampler, uv0 -dx -dy);
gaussian += Texture.Sample(TextureSampler, uv0 -dy);
gaussian += Texture.Sample(TextureSampler, uv0 +dx -dy);
gaussian += Texture.Sample(TextureSampler, uv0 +dx2 -dy);
gaussian += Texture.Sample(TextureSampler, uv0 - dx2 - dy);
gaussian += Texture.Sample(TextureSampler, uv0 - dx - dy);
gaussian += Texture.Sample(TextureSampler, uv0 - dy);
gaussian += Texture.Sample(TextureSampler, uv0 + dx - dy);
gaussian += Texture.Sample(TextureSampler, uv0 + dx2 - dy);
gaussian += Texture.Sample(TextureSampler, uv0 -dx2 -dy2);
gaussian += Texture.Sample(TextureSampler, uv0 -dx -dy2);
gaussian += Texture.Sample(TextureSampler, uv0 -dy2);
gaussian += Texture.Sample(TextureSampler, uv0 +dx -dy2);
gaussian += Texture.Sample(TextureSampler, uv0 +dx2 -dy2);
gaussian += Texture.Sample(TextureSampler, uv0 - dx2 - dy2);
gaussian += Texture.Sample(TextureSampler, uv0 - dx - dy2);
gaussian += Texture.Sample(TextureSampler, uv0 - dy2);
gaussian += Texture.Sample(TextureSampler, uv0 + dx - dy2);
gaussian += Texture.Sample(TextureSampler, uv0 + dx2 - dy2);
gaussian /= 25.0;
@ -882,9 +801,9 @@ float4 SampleBiCubic(SamplerState texSample, float2 uv0)
float2 uvCoord = float2(float(nX) / PixelSize.x, float(nY) / PixelSize.y);
for(int m = -1; m <= 2; m++)
for (int m = -1; m <= 2; m++)
{
for(int n = -1; n <= 2; n++)
for (int n = -1; n <= 2; n++)
{
float4 Samples = Texture.Sample(texSample, uvCoord +
float2(texelSizeX * float(m), texelSizeY * float(n)));
@ -928,15 +847,15 @@ float4 TexSharpenPass(float4 color : COLOR0, float2 uv0 : TEXCOORD0) : SV_Target
Texture.GetDimensions(PixelSize.x, PixelSize.y);
blurredColor = Texture.SampleLevel(TextureSampler, uv0 + float2(-px,py) * SharpenBias, 0.0).rgb; //North West
blurredColor += Texture.SampleLevel(TextureSampler, uv0 + float2(px,-py) * SharpenBias, 0.0).rgb; //South East
blurredColor += Texture.SampleLevel(TextureSampler, uv0 + float2(-px,-py) * SharpenBias, 0.0).rgb; //South West
blurredColor += Texture.SampleLevel(TextureSampler, uv0 + float2(px,py) * SharpenBias, 0.0).rgb; //North East
blurredColor = Texture.SampleLevel(TextureSampler, uv0 + float2(-px, py) * SharpenBias, 0.0).rgb; //North West
blurredColor += Texture.SampleLevel(TextureSampler, uv0 + float2(px, -py) * SharpenBias, 0.0).rgb; //South East
blurredColor += Texture.SampleLevel(TextureSampler, uv0 + float2(-px, -py) * SharpenBias, 0.0).rgb; //South West
blurredColor += Texture.SampleLevel(TextureSampler, uv0 + float2(px, py) * SharpenBias, 0.0).rgb; //North East
blurredColor += Texture.SampleLevel(TextureSampler, uv0 + float2(0.0,py) * SharpenBias, 0.0).rgb; //North
blurredColor += Texture.SampleLevel(TextureSampler, uv0 + float2(0.0,-py) * SharpenBias, 0.0).rgb; //South
blurredColor += Texture.SampleLevel(TextureSampler, uv0 + float2(-px,0.0) * SharpenBias, 0.0).rgb; //West
blurredColor += Texture.SampleLevel(TextureSampler, uv0 + float2(px,0.0) * SharpenBias, 0.0).rgb; //East
blurredColor += Texture.SampleLevel(TextureSampler, uv0 + float2(0.0, py) * SharpenBias, 0.0).rgb; //North
blurredColor += Texture.SampleLevel(TextureSampler, uv0 + float2(0.0, -py) * SharpenBias, 0.0).rgb; //South
blurredColor += Texture.SampleLevel(TextureSampler, uv0 + float2(-px, 0.0) * SharpenBias, 0.0).rgb; //West
blurredColor += Texture.SampleLevel(TextureSampler, uv0 + float2(px, 0.0) * SharpenBias, 0.0).rgb; //East
blurredColor /= 8.0;
@ -1024,34 +943,34 @@ float4 BloomPass(float4 color : COLOR0, float2 uv0 : TEXCOORD0) : SV_Target0
float4 bloomBlend = bloom * 0.22520613262190495;
bloomBlend += 0.002589001911021066 * Texture.Sample(BloomSampler, uv0 -dx2 +dy2);
bloomBlend += 0.010778807494659370 * Texture.Sample(BloomSampler, uv0 -dx +dy2);
bloomBlend += 0.024146616900339800 * Texture.Sample(BloomSampler, uv0 +dy2);
bloomBlend += 0.010778807494659370 * Texture.Sample(BloomSampler, uv0 +dx +dy2);
bloomBlend += 0.002589001911021066 * Texture.Sample(BloomSampler, uv0 +dx2 +dy2);
bloomBlend += 0.002589001911021066 * Texture.Sample(BloomSampler, uv0 - dx2 + dy2);
bloomBlend += 0.010778807494659370 * Texture.Sample(BloomSampler, uv0 - dx + dy2);
bloomBlend += 0.024146616900339800 * Texture.Sample(BloomSampler, uv0 + dy2);
bloomBlend += 0.010778807494659370 * Texture.Sample(BloomSampler, uv0 + dx + dy2);
bloomBlend += 0.002589001911021066 * Texture.Sample(BloomSampler, uv0 + dx2 + dy2);
bloomBlend += 0.010778807494659370 * Texture.Sample(BloomSampler, uv0 -dx2 +dy);
bloomBlend += 0.044875475183061630 * Texture.Sample(BloomSampler, uv0 -dx +dy);
bloomBlend += 0.100529757860782610 * Texture.Sample(BloomSampler, uv0 +dy);
bloomBlend += 0.044875475183061630 * Texture.Sample(BloomSampler, uv0 +dx +dy);
bloomBlend += 0.010778807494659370 * Texture.Sample(BloomSampler, uv0 +dx2 +dy);
bloomBlend += 0.010778807494659370 * Texture.Sample(BloomSampler, uv0 - dx2 + dy);
bloomBlend += 0.044875475183061630 * Texture.Sample(BloomSampler, uv0 - dx + dy);
bloomBlend += 0.100529757860782610 * Texture.Sample(BloomSampler, uv0 + dy);
bloomBlend += 0.044875475183061630 * Texture.Sample(BloomSampler, uv0 + dx + dy);
bloomBlend += 0.010778807494659370 * Texture.Sample(BloomSampler, uv0 + dx2 + dy);
bloomBlend += 0.024146616900339800 * Texture.Sample(BloomSampler, uv0 -dx2);
bloomBlend += 0.100529757860782610 * Texture.Sample(BloomSampler, uv0 -dx);
bloomBlend += 0.100529757860782610 * Texture.Sample(BloomSampler, uv0 +dx);
bloomBlend += 0.024146616900339800 * Texture.Sample(BloomSampler, uv0 +dx2);
bloomBlend += 0.024146616900339800 * Texture.Sample(BloomSampler, uv0 - dx2);
bloomBlend += 0.100529757860782610 * Texture.Sample(BloomSampler, uv0 - dx);
bloomBlend += 0.100529757860782610 * Texture.Sample(BloomSampler, uv0 + dx);
bloomBlend += 0.024146616900339800 * Texture.Sample(BloomSampler, uv0 + dx2);
bloomBlend += 0.010778807494659370 * Texture.Sample(BloomSampler, uv0 -dx2 -dy);
bloomBlend += 0.044875475183061630 * Texture.Sample(BloomSampler, uv0 -dx -dy);
bloomBlend += 0.100529757860782610 * Texture.Sample(BloomSampler, uv0 -dy);
bloomBlend += 0.044875475183061630 * Texture.Sample(BloomSampler, uv0 +dx -dy);
bloomBlend += 0.010778807494659370 * Texture.Sample(BloomSampler, uv0 +dx2 -dy);
bloomBlend += 0.010778807494659370 * Texture.Sample(BloomSampler, uv0 - dx2 - dy);
bloomBlend += 0.044875475183061630 * Texture.Sample(BloomSampler, uv0 - dx - dy);
bloomBlend += 0.100529757860782610 * Texture.Sample(BloomSampler, uv0 - dy);
bloomBlend += 0.044875475183061630 * Texture.Sample(BloomSampler, uv0 + dx - dy);
bloomBlend += 0.010778807494659370 * Texture.Sample(BloomSampler, uv0 + dx2 - dy);
bloomBlend += 0.002589001911021066 * Texture.Sample(BloomSampler, uv0 -dx2 -dy2);
bloomBlend += 0.010778807494659370 * Texture.Sample(BloomSampler, uv0 -dx -dy2);
bloomBlend += 0.024146616900339800 * Texture.Sample(BloomSampler, uv0 -dy2);
bloomBlend += 0.010778807494659370 * Texture.Sample(BloomSampler, uv0 +dx -dy2);
bloomBlend += 0.002589001911021066 * Texture.Sample(BloomSampler, uv0 +dx2 -dy2);
bloomBlend += 0.002589001911021066 * Texture.Sample(BloomSampler, uv0 - dx2 - dy2);
bloomBlend += 0.010778807494659370 * Texture.Sample(BloomSampler, uv0 - dx - dy2);
bloomBlend += 0.024146616900339800 * Texture.Sample(BloomSampler, uv0 - dy2);
bloomBlend += 0.010778807494659370 * Texture.Sample(BloomSampler, uv0 + dx - dy2);
bloomBlend += 0.002589001911021066 * Texture.Sample(BloomSampler, uv0 + dx2 - dy2);
bloomBlend = lerp(color, bloomBlend, BlendPower);
bloom.rgb = BloomType(color.rgb, bloomBlend.rgb);
@ -1073,11 +992,11 @@ float4 BloomPass(float4 color : COLOR0, float2 uv0 : TEXCOORD0) : SV_Target0
#endif
/*------------------------------------------------------------------------------
[COLOR CORRECTION/TONE MAPPING PASS CODE SECTION]
[COLOR CORRECTION/TONE MAPPING CODE SECTION]
------------------------------------------------------------------------------*/
#if (SCENE_TONEMAPPING == 1)
float YXYLuminance (float3 YXY)
float YXYLuminance(float3 YXY)
{
return (-0.9692660 * YXY.x)
+ (1.8760108 * YXY.y)
@ -1093,7 +1012,7 @@ float3 FilmicTonemap(float3 x)
float E = 0.02;
float F = 0.30;
return ((x*(A*x+C*B)+D*E) / (x*(A*x+B)+D*F))- E / F;
return ((x*(A*x + C*B) + D*E) / (x*(A*x + B) + D*F)) - E / F;
}
float3 ColorCorrection(float3 color)
@ -1102,19 +1021,19 @@ float3 ColorCorrection(float3 color)
float Y = 1.0 / (1.0 + exp(GreenCurve / 2.0));
float Z = 1.0 / (1.0 + exp(BlueCurve / 2.0));
color.r = (1.0 / (1.0 + exp(- RedCurve
* (color.r - 0.5))) - X) / (1.0 - 2.0 * X);
color.g = (1.0 / (1.0 + exp(- GreenCurve
* (color.g - 0.5))) - Y) / (1.0 - 2.0 * Y);
color.b = (1.0 / (1.0 + exp(- BlueCurve
* (color.b - 0.5))) - Z) / (1.0 - 2.0 * Z);
color.r = (1.0 / (1.0 + exp(-RedCurve *
(color.r - 0.5))) - X) / (1.0 - 2.0 * X);
color.g = (1.0 / (1.0 + exp(-GreenCurve *
(color.g - 0.5))) - Y) / (1.0 - 2.0 * Y);
color.b = (1.0 / (1.0 + exp(-BlueCurve *
(color.b - 0.5))) - Z) / (1.0 - 2.0 * Z);
return color;
}
float4 TonemapPass(float4 color : COLOR0, float2 uv0 : TEXCOORD0) : SV_Target0
{
float3 lumScale = 1.0/FilmicTonemap(Luminance);
float3 lumScale = 1.0 / FilmicTonemap(Luminance);
color.rgb = ColorCorrection(color.rgb);
color.rgb = FilmicTonemap(Exposure * color.rgb);
@ -1123,9 +1042,9 @@ float4 TonemapPass(float4 color : COLOR0, float2 uv0 : TEXCOORD0) : SV_Target0
const float3 lumCoeff = float3(0.2126729, 0.7151522, 0.0721750);
// RGB -> XYZ conversion
const float3x3 RGB2XYZ = {0.4124564, 0.3575761, 0.1804375,
const float3x3 RGB2XYZ = { 0.4124564, 0.3575761, 0.1804375,
0.2126729, 0.7151522, 0.0721750,
0.0193339, 0.1191920, 0.9503041};
0.0193339, 0.1191920, 0.9503041 };
float3 XYZ = mul(RGB2XYZ, color.rgb);
@ -1133,8 +1052,8 @@ float4 TonemapPass(float4 color : COLOR0, float2 uv0 : TEXCOORD0) : SV_Target0
float3 Yxy = lumCoeff;
Yxy.r = XYZ.g; // copy luminance Y
Yxy.g = XYZ.r / (XYZ.r + XYZ.g + XYZ.b ); // x = X / (X + Y + Z)
Yxy.b = XYZ.g / (XYZ.r + XYZ.g + XYZ.b ); // y = Y / (X + Y + Z)
Yxy.g = XYZ.r / (XYZ.r + XYZ.g + XYZ.b); // x = X / (X + Y + Z)
Yxy.b = XYZ.g / (XYZ.r + XYZ.g + XYZ.b); // y = Y / (X + Y + Z)
// (Lp) Map average luminance to the middlegrey zone by scaling pixel luminance
#if (TonemapType == 1)
@ -1147,17 +1066,17 @@ float4 TonemapPass(float4 color : COLOR0, float2 uv0 : TEXCOORD0) : SV_Target0
#endif
// (Ld) Scale all luminance within a displayable range of 0 to 1
Yxy.r = (Lp * (1.0 + Lp/(WhitePoint * WhitePoint)))/(1.0 + Lp);
Yxy.r = (Lp * (1.0 + Lp / (WhitePoint * WhitePoint))) / (1.0 + Lp);
// Yxy -> XYZ conversion
XYZ.r = Yxy.r * Yxy.g / Yxy. b; // X = Y * x / y
XYZ.r = Yxy.r * Yxy.g / Yxy.b; // X = Y * x / y
XYZ.g = Yxy.r; // copy luminance Y
XYZ.b = Yxy.r * (1.0 - Yxy.g - Yxy.b) / Yxy.b; // Z = Y * (1-x-y) / y
// XYZ -> RGB conversion
const float3x3 XYZ2RGB = {3.2404542, -1.5371385, -0.4985314,
const float3x3 XYZ2RGB = { 3.2404542, -1.5371385, -0.4985314,
-0.9692660, 1.8760108, 0.0415560,
0.0556434, -0.2040259, 1.0572252};
0.0556434, -0.2040259, 1.0572252 };
color.rgb = mul(XYZ2RGB, XYZ);
@ -1244,14 +1163,14 @@ static const float3 thresholds = float3(5.0, 8.0, 6.0);
float3 GetYUV(float3 rgb)
{
#if (LumaConversion == 1)
float3x3 RGB2YUV = {0.2126, 0.7152, 0.0722,
float3x3 RGB2YUV = { 0.2126, 0.7152, 0.0722,
-0.09991, -0.33609, 0.436,
0.615, -0.55861, -0.05639};
0.615, -0.55861, -0.05639 };
#else
float3x3 RGB2YUV = {0.299, 0.587, 0.114,
float3x3 RGB2YUV = { 0.299, 0.587, 0.114,
-0.14713, -0.28886f, 0.436,
0.615, -0.51499, -0.10001};
0.615, -0.51499, -0.10001 };
#endif
return mul(RGB2YUV, rgb);
@ -1260,14 +1179,14 @@ float3 GetYUV(float3 rgb)
float3 GetRGB(float3 yuv)
{
#if (LumaConversion == 1)
float3x3 YUV2RGB = {1.000, 0.000, 1.28033,
float3x3 YUV2RGB = { 1.000, 0.000, 1.28033,
1.000, -0.21482, -0.38059,
1.000, 2.12798, 0.000};
1.000, 2.12798, 0.000 };
#else
float3x3 YUV2RGB = {1.000, 0.000, 1.13983,
float3x3 YUV2RGB = { 1.000, 0.000, 1.13983,
1.000, -0.39465, -0.58060,
1.000, 2.03211, 0.000};
1.000, 2.03211, 0.000 };
#endif
return mul(YUV2RGB, yuv);
@ -1283,18 +1202,18 @@ float4 CelPass(float4 color : COLOR0, float2 uv0 : TEXCOORD0) : SV_Target0
float3 yuv;
float3 sum = color.rgb;
float2 pixel = float2(1.0/2560.0, 1.0/1440.0) * EdgeThickness;
float2 pixel = float2(1.0 / 2560.0, 1.0 / 1440.0) * EdgeThickness;
float2 c[NUM] = {
float2(-0.0078125,-0.0078125),
float2( 0.00 , -0.0078125),
float2( 0.0078125,-0.0078125),
float2(-0.0078125, -0.0078125),
float2(0.00, -0.0078125),
float2(0.0078125, -0.0078125),
float2(-0.0078125, 0.00),
float2( 0.00, 0.00),
float2( 0.0078125, 0.00),
float2(0.00, 0.00),
float2(0.0078125, 0.00),
float2(-0.0078125, 0.0078125),
float2( 0.00 , 0.0078125),
float2( 0.0078125, 0.0078125)};
float2(0.00, 0.0078125),
float2(0.0078125, 0.0078125) };
float3 col[NUM];
float lum[NUM];
@ -1314,9 +1233,13 @@ float4 CelPass(float4 color : COLOR0, float2 uv0 : TEXCOORD0) : SV_Target0
yuv = GetYUV(col[i]);
if (UseYuvLuma == 0)
{ yuv.r = saturate(round(yuv.r * lum[i]) / thresholds.r + lum[i]); }
{
yuv.r = saturate(round(yuv.r * lum[i]) / thresholds.r + lum[i]);
}
else
{ yuv.r = saturate(round(yuv.r * thresholds.r) / thresholds.r + lum[i] / (255.0 / 5.0)); }
{
yuv.r = saturate(round(yuv.r * thresholds.r) / thresholds.r + lum[i] / (255.0 / 5.0));
}
yuv = GetRGB(yuv);
@ -1357,7 +1280,7 @@ float RGBCVtoHUE(float3 RGB, float C, float V)
float3 Delta = (V - RGB) / C;
Delta.rgb -= Delta.brg;
Delta.rgb += float3(2,4,6);
Delta.rgb += float3(2, 4, 6);
Delta.brg = step(V, RGB) * Delta.brg;
float H;
@ -1387,7 +1310,7 @@ float3 HUEtoRGB(float H)
float G = 2 - abs(H * 6 - 2);
float B = 2 - abs(H * 6 - 4);
return saturate(float3(R,G,B));
return saturate(float3(R, G, B));
}
float3 HSVtoRGB(float3 HSV)
@ -1409,11 +1332,11 @@ float HueLerp(float h1, float h2, float v)
{
float d = abs(h1 - h2);
if(d <= 0.5)
if (d <= 0.5)
{
return lerp(h1, h2, v);
}
else if(h1 < h2)
else if (h1 < h2)
{
return frac(lerp((h1 + 1.0), h2, v));
}
@ -1441,7 +1364,7 @@ float4 ColorGrading(float4 color : COLOR0, float2 uv0 : TEXCOORD0) : SV_Target0
float3 HSVColor = colorHSV;
if(dist1 < dist2)
if (dist1 < dist2)
{
float c = descent * amount * (1.0 - pow((dist1 * 2.0), 1.0 / concentration));
HSVColor.x = HueLerp(colorHSV.x, huePoleA.x, c);
@ -1476,7 +1399,7 @@ float4 ScanlinesPass(float4 color : COLOR0, float2 uv0 : TEXCOORD0, float4 FragC
float pos0 = ((uv0.y + 1.0) * 170.0 * amount);
float pos1 = cos((frac(pos0 * ScanlineScale) - 0.5) * 3.1415926 * intensity) * 1.2;
color = lerp(float4(0,0,0,0), color, pos1);
color = lerp(float4(0, 0, 0, 0), color, pos1);
#else
float4 intensity;
@ -1496,9 +1419,9 @@ float4 ScanlinesPass(float4 color : COLOR0, float2 uv0 : TEXCOORD0, float4 FragC
intensity = smoothstep(0.2, ScanlineBrightness, color) + normalize(float4(color.xyz, RGBLuminance(color.xyz)));
}
float level = (4.0-uv0.x) * ScanlineIntensity;
float level = (4.0 - uv0.x) * ScanlineIntensity;
color = intensity * (0.5-level) + color * 1.1;
color = intensity * (0.5 - level) + color * 1.1;
#endif
return color;
@ -1539,7 +1462,7 @@ float4 DitherPass(float4 color : COLOR0, float2 uv0 : TEXCOORD0) : SV_Target
#if DitherMethod == 2 //random subpixel dithering
float seed = dot(uv0, float2(12.9898,78.233));
float seed = dot(uv0, float2(12.9898, 78.233));
float sine = sin(seed);
float noise = frac(sine * 43758.5453 + uv0.x);
@ -1551,8 +1474,8 @@ float4 DitherPass(float4 color : COLOR0, float2 uv0 : TEXCOORD0) : SV_Target
#else //Ordered dithering
float gridPosition = frac(dot(uv0,(PixelSize.xy / ditherSize)) + (0.5 / ditherSize));
float ditherShift = (0.75) * (1.0 / (pow(2,ditherBits) - 1.0));
float gridPosition = frac(dot(uv0, (PixelSize.xy / ditherSize)) + (0.5 / ditherSize));
float ditherShift = (0.75) * (1.0 / (pow(2, ditherBits) - 1.0));
float3 RGBShift = float3(ditherShift, -ditherShift, ditherShift);
RGBShift = lerp(2.0 * RGBShift, -2.0 * RGBShift, gridPosition);

View File

@ -114,38 +114,38 @@ float4 PreGammaPass(float4 color, float2 uv0)
------------------------------------------------------------------------------*/
#if (SHADER_MODEL >= 0x500)
#define FXAA_HLSL_5 1
#define FXAA_GATHER4_ALPHA 1
#define FXAA_HLSL_5 1
#define FXAA_GATHER4_ALPHA 1
#elif (SHADER_MODEL >= 0x400)
#define FXAA_HLSL_4 1
#define FXAA_GATHER4_ALPHA 0
#define FXAA_HLSL_4 1
#define FXAA_GATHER4_ALPHA 0
#else
#define FXAA_HLSL_3 1
#define FXAA_GATHER4_ALPHA 0
#define FXAA_HLSL_3 1
#define FXAA_GATHER4_ALPHA 0
#endif
#if (FXAA_HLSL_5 == 1)
struct FxaaTex { SamplerState smpl; Texture2D tex; };
#define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)
#define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)
#define FxaaTexAlpha4(t, p) t.tex.GatherAlpha(t.smpl, p)
#define FxaaTexOffAlpha4(t, p, o) t.tex.GatherAlpha(t.smpl, p, o)
#define FxaaDiscard clip(-1)
#define FxaaSat(x) saturate(x)
struct FxaaTex { SamplerState smpl; Texture2D tex; };
#define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)
#define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)
#define FxaaTexAlpha4(t, p) t.tex.GatherAlpha(t.smpl, p)
#define FxaaTexOffAlpha4(t, p, o) t.tex.GatherAlpha(t.smpl, p, o)
#define FxaaDiscard clip(-1)
#define FxaaSat(x) saturate(x)
#elif (FXAA_HLSL_4 == 1)
struct FxaaTex { SamplerState smpl; Texture2D tex; };
#define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)
#define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)
#define FxaaDiscard clip(-1)
#define FxaaSat(x) saturate(x)
struct FxaaTex { SamplerState smpl; Texture2D tex; };
#define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)
#define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)
#define FxaaDiscard clip(-1)
#define FxaaSat(x) saturate(x)
#elif (FXAA_HLSL_3 == 1)
#define FxaaTex sampler2D
#define int2 float2
#define FxaaSat(x) saturate(x)
#define FxaaTexTop(t, p) tex2Dlod(t, float4(p, 0.0, 0.0))
#define FxaaTexOff(t, p, o, r) tex2Dlod(t, float4(p + (o * r), 0, 0))
#define FxaaTex sampler2D
#define int2 float2
#define FxaaSat(x) saturate(x)
#define FxaaTexTop(t, p) tex2Dlod(t, float4(p, 0.0, 0.0))
#define FxaaTexOff(t, p, o, r) tex2Dlod(t, float4(p + (o * r), 0, 0))
#endif
#define FxaaEdgeThreshold 0.033