examples: Fix FXAA not working in OpenGL
This commit is contained in:
parent
4b86d67517
commit
06e2dea1fa
|
|
@ -96,7 +96,7 @@ uniform float _300_EdgeThresholdMin<
|
||||||
> = 8.33;
|
> = 8.33;
|
||||||
|
|
||||||
// ======================================== //
|
// ======================================== //
|
||||||
// Functionality
|
// FXAA Functionality
|
||||||
// ======================================== //
|
// ======================================== //
|
||||||
// This is a bit of a mess, but it is necessary to get things to work. We're
|
// This is a bit of a mess, but it is necessary to get things to work. We're
|
||||||
// dealing with multiple unusual restrictions here, all of which are from
|
// dealing with multiple unusual restrictions here, all of which are from
|
||||||
|
|
@ -121,42 +121,66 @@ uniform float _300_EdgeThresholdMin<
|
||||||
#define FxaaTex texture2d
|
#define FxaaTex texture2d
|
||||||
#ifdef GS_DEVICE_OPENGL
|
#ifdef GS_DEVICE_OPENGL
|
||||||
#define FxaaSat(x) clamp(x, 0., 1.)
|
#define FxaaSat(x) clamp(x, 0., 1.)
|
||||||
#define FxaaTexTop(t, p) textureLod(t, p, 0.0)
|
#define FxaaTexTop(t, p) textureLod(t, p, 0.0)
|
||||||
#define FxaaTexOff(t, p, o, r) textureLodOffset(t, p, 0.0, o)
|
#define FxaaTexOff(t, p, o, r) textureLodOffset(t, p, 0.0, o)
|
||||||
#else
|
#else
|
||||||
#define FxaaSat(x) saturate(x)
|
#define FxaaSat(x) saturate(x)
|
||||||
#define FxaaTexTop(t, p) t.SampleLevel(PointClampSampler, p, 0.0)
|
#define FxaaTexTop(t, p) t.SampleLevel(PointClampSampler, p, 0.0)
|
||||||
#define FxaaTexOff(t, p, o, r) t.SampleLevel(PointClampSampler, p, 0.0, o)
|
#define FxaaTexOff(t, p, o, r) t.SampleLevel(PointClampSampler, p, 0.0, o)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Actual Functionality starts here.
|
// Actual Functionality starts here.
|
||||||
FxaaUInt quality_stages() {
|
FxaaUInt quality_stages() {
|
||||||
FxaaUInt stages = FxaaUInt(_000_QualityPreset) % 10;
|
FxaaUInt stages = FxaaUInt(_000_QualityPreset) % 10u;
|
||||||
return (3 + stages);
|
return 3u + stages;
|
||||||
}
|
}
|
||||||
|
|
||||||
FxaaFloat quality_value(in FxaaUInt stage) {
|
FxaaFloat quality_value(in FxaaUInt stage) {
|
||||||
const FxaaFloat preset_00[12] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
#ifdef GS_DEVICE_OPENGL
|
||||||
|
const FxaaFloat preset_00[12u] = FxaaFloat[12u]( 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
// 1.x
|
// 1.x
|
||||||
const FxaaFloat preset_10[12] = { 1.5, 3.0, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
const FxaaFloat preset_10[12u] = FxaaFloat[12u]( 1.5f, 3.0f, 12.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
const FxaaFloat preset_11[12] = { 1.0, 1.5, 3.0, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
const FxaaFloat preset_11[12u] = FxaaFloat[12u]( 1.0f, 1.5f, 3.0f, 12.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
const FxaaFloat preset_12[12] = { 1.0, 1.5, 2.0, 4.0, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
const FxaaFloat preset_12[12u] = FxaaFloat[12u]( 1.0f, 1.5f, 2.0f, 4.0f, 12.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
const FxaaFloat preset_13[12] = { 1.0, 1.5, 2.0, 2.0, 4.0, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
const FxaaFloat preset_13[12u] = FxaaFloat[12u]( 1.0f, 1.5f, 2.0f, 2.0f, 4.0f, 12.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
const FxaaFloat preset_14[12] = { 1.0, 1.5, 2.0, 2.0, 2.0, 4.0, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
const FxaaFloat preset_14[12u] = FxaaFloat[12u]( 1.0f, 1.5f, 2.0f, 2.0f, 2.0f, 4.0f, 12.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
const FxaaFloat preset_15[12] = { 1.0, 1.5, 2.0, 2.0, 2.0, 2.0, 4.0, 12.0, 0.0, 0.0, 0.0, 0.0};
|
const FxaaFloat preset_15[12u] = FxaaFloat[12u]( 1.0f, 1.5f, 2.0f, 2.0f, 2.0f, 2.0f, 4.0f, 12.0f, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
// 2.x
|
// 2.x
|
||||||
const FxaaFloat preset_20[12] = { 1.5, 2.0, 8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
const FxaaFloat preset_20[12u] = FxaaFloat[12u]( 1.5f, 2.0f, 8.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
const FxaaFloat preset_21[12] = { 1.0, 1.5, 2.0, 8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
const FxaaFloat preset_21[12u] = FxaaFloat[12u]( 1.0f, 1.5f, 2.0f, 8.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
const FxaaFloat preset_22[12] = { 1.0, 1.5, 2.0, 2.0, 8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
const FxaaFloat preset_22[12u] = FxaaFloat[12u]( 1.0f, 1.5f, 2.0f, 2.0f, 8.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
const FxaaFloat preset_23[12] = { 1.0, 1.5, 2.0, 2.0, 2.0, 8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
const FxaaFloat preset_23[12u] = FxaaFloat[12u]( 1.0f, 1.5f, 2.0f, 2.0f, 2.0f, 8.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
const FxaaFloat preset_24[12] = { 1.0, 1.5, 2.0, 2.0, 2.0, 3.0, 8.0, 0.0, 0.0, 0.0, 0.0, 0.0};
|
const FxaaFloat preset_24[12u] = FxaaFloat[12u]( 1.0f, 1.5f, 2.0f, 2.0f, 2.0f, 3.0f, 8.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
const FxaaFloat preset_25[12] = { 1.0, 1.5, 2.0, 2.0, 2.0, 2.0, 4.0, 8.0, 0.0, 0.0, 0.0, 0.0};
|
const FxaaFloat preset_25[12u] = FxaaFloat[12u]( 1.0f, 1.5f, 2.0f, 2.0f, 2.0f, 2.0f, 4.0f, 8.0f, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
const FxaaFloat preset_26[12] = { 1.0, 1.5, 2.0, 2.0, 2.0, 2.0, 2.0, 4.0, 8.0, 0.0, 0.0, 0.0};
|
const FxaaFloat preset_26[12u] = FxaaFloat[12u]( 1.0f, 1.5f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 4.0f, 8.0f, 0.0f, 0.0f, 0.0f);
|
||||||
const FxaaFloat preset_27[12] = { 1.0, 1.5, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 4.0, 8.0, 0.0, 0.0};
|
const FxaaFloat preset_27[12u] = FxaaFloat[12u]( 1.0f, 1.5f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 4.0f, 8.0f, 0.0f, 0.0f);
|
||||||
const FxaaFloat preset_28[12] = { 1.0, 1.5, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 4.0, 8.0, 0.0};
|
const FxaaFloat preset_28[12u] = FxaaFloat[12u]( 1.0f, 1.5f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 4.0f, 8.0f, 0.0f);
|
||||||
const FxaaFloat preset_29[12] = { 1.0, 1.5, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 4.0, 8.0};
|
const FxaaFloat preset_29[12u] = FxaaFloat[12u]( 1.0f, 1.5f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 4.0f, 8.0f);
|
||||||
// 3.x
|
// 3.x
|
||||||
const FxaaFloat preset_39[12] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.5, 2.0, 2.0, 2.0, 2.0, 4.0, 8.0};
|
const FxaaFloat preset_39[12u] = FxaaFloat[12u]( 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.5f, 2.0f, 2.0f, 2.0f, 2.0f, 4.0f, 8.0f);
|
||||||
|
#else
|
||||||
|
const FxaaFloat preset_00[12u] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
|
||||||
|
// 1.x
|
||||||
|
const FxaaFloat preset_10[12u] = { 1.5f, 3.0f, 12.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
|
||||||
|
const FxaaFloat preset_11[12u] = { 1.0f, 1.5f, 3.0f, 12.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
|
||||||
|
const FxaaFloat preset_12[12u] = { 1.0f, 1.5f, 2.0f, 4.0f, 12.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
|
||||||
|
const FxaaFloat preset_13[12u] = { 1.0f, 1.5f, 2.0f, 2.0f, 4.0f, 12.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
|
||||||
|
const FxaaFloat preset_14[12u] = { 1.0f, 1.5f, 2.0f, 2.0f, 2.0f, 4.0f, 12.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
|
||||||
|
const FxaaFloat preset_15[12u] = { 1.0f, 1.5f, 2.0f, 2.0f, 2.0f, 2.0f, 4.0f, 12.0f, 0.0f, 0.0f, 0.0f, 0.0f};
|
||||||
|
// 2.x
|
||||||
|
const FxaaFloat preset_20[12u] = { 1.5f, 2.0f, 8.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
|
||||||
|
const FxaaFloat preset_21[12u] = { 1.0f, 1.5f, 2.0f, 8.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
|
||||||
|
const FxaaFloat preset_22[12u] = { 1.0f, 1.5f, 2.0f, 2.0f, 8.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
|
||||||
|
const FxaaFloat preset_23[12u] = { 1.0f, 1.5f, 2.0f, 2.0f, 2.0f, 8.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
|
||||||
|
const FxaaFloat preset_24[12u] = { 1.0f, 1.5f, 2.0f, 2.0f, 2.0f, 3.0f, 8.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
|
||||||
|
const FxaaFloat preset_25[12u] = { 1.0f, 1.5f, 2.0f, 2.0f, 2.0f, 2.0f, 4.0f, 8.0f, 0.0f, 0.0f, 0.0f, 0.0f};
|
||||||
|
const FxaaFloat preset_26[12u] = { 1.0f, 1.5f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 4.0f, 8.0f, 0.0f, 0.0f, 0.0f};
|
||||||
|
const FxaaFloat preset_27[12u] = { 1.0f, 1.5f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 4.0f, 8.0f, 0.0f, 0.0f};
|
||||||
|
const FxaaFloat preset_28[12u] = { 1.0f, 1.5f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 4.0f, 8.0f, 0.0f};
|
||||||
|
const FxaaFloat preset_29[12u] = { 1.0f, 1.5f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 4.0f, 8.0f};
|
||||||
|
// 3.x
|
||||||
|
const FxaaFloat preset_39[12u] = { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.5f, 2.0f, 2.0f, 2.0f, 2.0f, 4.0f, 8.0f};
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (_000_QualityPreset) {
|
switch (_000_QualityPreset) {
|
||||||
case 10: return preset_10[stage];
|
case 10: return preset_10[stage];
|
||||||
|
|
@ -209,239 +233,239 @@ FxaaBool FxaaStep(in FxaaTex tex,
|
||||||
}
|
}
|
||||||
|
|
||||||
FxaaFloat4 FxaaPixelShader(
|
FxaaFloat4 FxaaPixelShader(
|
||||||
//
|
//
|
||||||
// Use noperspective interpolation here (turn off perspective interpolation).
|
// Use noperspective interpolation here (turn off perspective interpolation).
|
||||||
// {xy} = center of pixel
|
// {xy} = center of pixel
|
||||||
FxaaFloat2 pos,
|
FxaaFloat2 pos,
|
||||||
//
|
//
|
||||||
// Input color texture.
|
// Input color texture.
|
||||||
// {rgb_} = color in linear or perceptual color space
|
// {rgb_} = color in linear or perceptual color space
|
||||||
// if (FXAA_GREEN_AS_LUMA == 0)
|
// if (FXAA_GREEN_AS_LUMA == 0)
|
||||||
// {___a} = luma in perceptual color space (not linear)
|
// {___a} = luma in perceptual color space (not linear)
|
||||||
FxaaTex tex,
|
FxaaTex tex,
|
||||||
//
|
//
|
||||||
// Only used on FXAA Quality.
|
// Only used on FXAA Quality.
|
||||||
// This must be from a constant/uniform.
|
// This must be from a constant/uniform.
|
||||||
// {x_} = 1.0/screenWidthInPixels
|
// {x_} = 1.0/screenWidthInPixels
|
||||||
// {_y} = 1.0/screenHeightInPixels
|
// {_y} = 1.0/screenHeightInPixels
|
||||||
FxaaFloat2 fxaaQualityRcpFrame,
|
FxaaFloat2 fxaaQualityRcpFrame,
|
||||||
//
|
//
|
||||||
// Only used on FXAA Quality.
|
// Only used on FXAA Quality.
|
||||||
// This used to be the FXAA_QUALITY__SUBPIX define.
|
// This used to be the FXAA_QUALITY__SUBPIX define.
|
||||||
// It is here now to allow easier tuning.
|
// It is here now to allow easier tuning.
|
||||||
// Choose the amount of sub-pixel aliasing removal.
|
// Choose the amount of sub-pixel aliasing removal.
|
||||||
// This can effect sharpness.
|
// This can effect sharpness.
|
||||||
// 1.00 - upper limit (softer)
|
// 1.00 - upper limit (softer)
|
||||||
// 0.75 - default amount of filtering
|
// 0.75 - default amount of filtering
|
||||||
// 0.50 - lower limit (sharper, less sub-pixel aliasing removal)
|
// 0.50 - lower limit (sharper, less sub-pixel aliasing removal)
|
||||||
// 0.25 - almost off
|
// 0.25 - almost off
|
||||||
// 0.00 - completely off
|
// 0.00 - completely off
|
||||||
FxaaFloat fxaaQualitySubpix,
|
FxaaFloat fxaaQualitySubpix,
|
||||||
//
|
//
|
||||||
// Only used on FXAA Quality.
|
// Only used on FXAA Quality.
|
||||||
// This used to be the FXAA_QUALITY__EDGE_THRESHOLD define.
|
// This used to be the FXAA_QUALITY__EDGE_THRESHOLD define.
|
||||||
// It is here now to allow easier tuning.
|
// It is here now to allow easier tuning.
|
||||||
// The minimum amount of local contrast required to apply algorithm.
|
// The minimum amount of local contrast required to apply algorithm.
|
||||||
// 0.333 - too little (faster)
|
// 0.333 - too little (faster)
|
||||||
// 0.250 - low quality
|
// 0.250 - low quality
|
||||||
// 0.166 - default
|
// 0.166 - default
|
||||||
// 0.125 - high quality
|
// 0.125 - high quality
|
||||||
// 0.063 - overkill (slower)
|
// 0.063 - overkill (slower)
|
||||||
FxaaFloat fxaaQualityEdgeThreshold,
|
FxaaFloat fxaaQualityEdgeThreshold,
|
||||||
//
|
//
|
||||||
// Only used on FXAA Quality.
|
// Only used on FXAA Quality.
|
||||||
// This used to be the FXAA_QUALITY__EDGE_THRESHOLD_MIN define.
|
// This used to be the FXAA_QUALITY__EDGE_THRESHOLD_MIN define.
|
||||||
// It is here now to allow easier tuning.
|
// It is here now to allow easier tuning.
|
||||||
// Trims the algorithm from processing darks.
|
// Trims the algorithm from processing darks.
|
||||||
// 0.0833 - upper limit (default, the start of visible unfiltered edges)
|
// 0.0833 - upper limit (default, the start of visible unfiltered edges)
|
||||||
// 0.0625 - high quality (faster)
|
// 0.0625 - high quality (faster)
|
||||||
// 0.0312 - visible limit (slower)
|
// 0.0312 - visible limit (slower)
|
||||||
// Special notes when using FXAA_GREEN_AS_LUMA,
|
// Special notes when using FXAA_GREEN_AS_LUMA,
|
||||||
// Likely want to set this to zero.
|
// Likely want to set this to zero.
|
||||||
// As colors that are mostly not-green
|
// As colors that are mostly not-green
|
||||||
// will appear very dark in the green channel!
|
// will appear very dark in the green channel!
|
||||||
// Tune by looking at mostly non-green content,
|
// Tune by looking at mostly non-green content,
|
||||||
// then start at zero and increase until aliasing is a problem.
|
// then start at zero and increase until aliasing is a problem.
|
||||||
FxaaFloat fxaaQualityEdgeThresholdMin
|
FxaaFloat fxaaQualityEdgeThresholdMin
|
||||||
) {
|
) {
|
||||||
// ======================================== // Similar to 3.11
|
// ======================================== // Similar to 3.11
|
||||||
FxaaFloat2 posM;
|
FxaaFloat2 posM;
|
||||||
posM.x = pos.x;
|
posM.x = pos.x;
|
||||||
posM.y = pos.y;
|
posM.y = pos.y;
|
||||||
#ifdef FXAA_GATHER4_ALPHA
|
#ifdef FXAA_GATHER4_ALPHA
|
||||||
#ifdef FXAA_DISCARD
|
#ifdef FXAA_DISCARD
|
||||||
FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);
|
FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);
|
||||||
#ifndef FXAA_GREEN_AS_LUMA
|
#ifndef FXAA_GREEN_AS_LUMA
|
||||||
#define lumaM rgbyM.w
|
#define lumaM rgbyM.w
|
||||||
#else
|
#else
|
||||||
#define lumaM rgbyM.y
|
#define lumaM rgbyM.y
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifndef FXAA_GREEN_AS_LUMA
|
#ifndef FXAA_GREEN_AS_LUMA
|
||||||
FxaaFloat4 luma4A = FxaaTexAlpha4(tex, posM);
|
FxaaFloat4 luma4A = FxaaTexAlpha4(tex, posM);
|
||||||
FxaaFloat4 luma4B = FxaaTexOffAlpha4(tex, posM, FxaaInt2(-1, -1));
|
FxaaFloat4 luma4B = FxaaTexOffAlpha4(tex, posM, FxaaInt2(-1, -1));
|
||||||
#else
|
#else
|
||||||
FxaaFloat4 luma4A = FxaaTexGreen4(tex, posM);
|
FxaaFloat4 luma4A = FxaaTexGreen4(tex, posM);
|
||||||
FxaaFloat4 luma4B = FxaaTexOffGreen4(tex, posM, FxaaInt2(-1, -1));
|
FxaaFloat4 luma4B = FxaaTexOffGreen4(tex, posM, FxaaInt2(-1, -1));
|
||||||
#endif
|
#endif
|
||||||
#ifdef FXAA_DISCARD
|
#ifdef FXAA_DISCARD
|
||||||
#define lumaM luma4A.w
|
#define lumaM luma4A.w
|
||||||
#endif
|
#endif
|
||||||
#define lumaE luma4A.z
|
#define lumaE luma4A.z
|
||||||
#define lumaS luma4A.x
|
#define lumaS luma4A.x
|
||||||
#define lumaSE luma4A.y
|
#define lumaSE luma4A.y
|
||||||
#define lumaNW luma4B.w
|
#define lumaNW luma4B.w
|
||||||
#define lumaN luma4B.z
|
#define lumaN luma4B.z
|
||||||
#define lumaW luma4B.x
|
#define lumaW luma4B.x
|
||||||
#else
|
#else
|
||||||
FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);
|
FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);
|
||||||
#ifndef FXAA_GREEN_AS_LUMA
|
#ifndef FXAA_GREEN_AS_LUMA
|
||||||
#define lumaM rgbyM.w
|
#define lumaM rgbyM.w
|
||||||
#else
|
#else
|
||||||
#define lumaM rgbyM.y
|
#define lumaM rgbyM.y
|
||||||
#endif
|
#endif
|
||||||
FxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0, 1), fxaaQualityRcpFrame.xy));
|
FxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0, 1), fxaaQualityRcpFrame.xy));
|
||||||
FxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 0), fxaaQualityRcpFrame.xy));
|
FxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 0), fxaaQualityRcpFrame.xy));
|
||||||
FxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0,-1), fxaaQualityRcpFrame.xy));
|
FxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0,-1), fxaaQualityRcpFrame.xy));
|
||||||
FxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 0), fxaaQualityRcpFrame.xy));
|
FxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 0), fxaaQualityRcpFrame.xy));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ======================================== // Matches 3.11
|
// ======================================== // Matches 3.11
|
||||||
FxaaFloat maxSM = max(lumaS, lumaM);
|
FxaaFloat maxSM = max(lumaS, lumaM);
|
||||||
FxaaFloat minSM = min(lumaS, lumaM);
|
FxaaFloat minSM = min(lumaS, lumaM);
|
||||||
FxaaFloat maxESM = max(lumaE, maxSM);
|
FxaaFloat maxESM = max(lumaE, maxSM);
|
||||||
FxaaFloat minESM = min(lumaE, minSM);
|
FxaaFloat minESM = min(lumaE, minSM);
|
||||||
FxaaFloat maxWN = max(lumaN, lumaW);
|
FxaaFloat maxWN = max(lumaN, lumaW);
|
||||||
FxaaFloat minWN = min(lumaN, lumaW);
|
FxaaFloat minWN = min(lumaN, lumaW);
|
||||||
FxaaFloat rangeMax = max(maxWN, maxESM);
|
FxaaFloat rangeMax = max(maxWN, maxESM);
|
||||||
FxaaFloat rangeMin = min(minWN, minESM);
|
FxaaFloat rangeMin = min(minWN, minESM);
|
||||||
FxaaFloat rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;
|
FxaaFloat rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;
|
||||||
FxaaFloat range = rangeMax - rangeMin;
|
FxaaFloat range = rangeMax - rangeMin;
|
||||||
FxaaFloat rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);
|
FxaaFloat rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);
|
||||||
FxaaBool earlyExit = range < rangeMaxClamped;
|
FxaaBool earlyExit = range < rangeMaxClamped;
|
||||||
|
|
||||||
// ======================================== // Similar to 3.11
|
// ======================================== // Similar to 3.11
|
||||||
if(earlyExit) {
|
if(earlyExit) {
|
||||||
#ifdef FXAA_DISCARD
|
#ifdef FXAA_DISCARD
|
||||||
FxaaDiscard;
|
FxaaDiscard;
|
||||||
#else
|
#else
|
||||||
return rgbyM;
|
return rgbyM;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======================================== // Similar to 3.11
|
// ======================================== // Similar to 3.11
|
||||||
#ifndef FXAA_GATHER4_ALPHA
|
#ifndef FXAA_GATHER4_ALPHA
|
||||||
FxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1,-1), fxaaQualityRcpFrame.xy));
|
FxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1,-1), fxaaQualityRcpFrame.xy));
|
||||||
FxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 1), fxaaQualityRcpFrame.xy));
|
FxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 1), fxaaQualityRcpFrame.xy));
|
||||||
FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1,-1), fxaaQualityRcpFrame.xy));
|
FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1,-1), fxaaQualityRcpFrame.xy));
|
||||||
FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));
|
FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));
|
||||||
#else
|
#else
|
||||||
FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1, -1), fxaaQualityRcpFrame.xy));
|
FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1, -1), fxaaQualityRcpFrame.xy));
|
||||||
FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));
|
FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ======================================== // Matches 3.11
|
// ======================================== // Matches 3.11
|
||||||
FxaaFloat lumaNS = lumaN + lumaS;
|
FxaaFloat lumaNS = lumaN + lumaS;
|
||||||
FxaaFloat lumaWE = lumaW + lumaE;
|
FxaaFloat lumaWE = lumaW + lumaE;
|
||||||
FxaaFloat subpixRcpRange = 1.0/range;
|
FxaaFloat subpixRcpRange = 1.0/range;
|
||||||
FxaaFloat subpixNSWE = lumaNS + lumaWE;
|
FxaaFloat subpixNSWE = lumaNS + lumaWE;
|
||||||
FxaaFloat edgeHorz1 = (-2.0 * lumaM) + lumaNS;
|
FxaaFloat edgeHorz1 = (-2.0 * lumaM) + lumaNS;
|
||||||
FxaaFloat edgeVert1 = (-2.0 * lumaM) + lumaWE;
|
FxaaFloat edgeVert1 = (-2.0 * lumaM) + lumaWE;
|
||||||
|
|
||||||
// ======================================== // Matches 3.11
|
// ======================================== // Matches 3.11
|
||||||
FxaaFloat lumaNESE = lumaNE + lumaSE;
|
FxaaFloat lumaNESE = lumaNE + lumaSE;
|
||||||
FxaaFloat lumaNWNE = lumaNW + lumaNE;
|
FxaaFloat lumaNWNE = lumaNW + lumaNE;
|
||||||
FxaaFloat edgeHorz2 = (-2.0 * lumaE) + lumaNESE;
|
FxaaFloat edgeHorz2 = (-2.0 * lumaE) + lumaNESE;
|
||||||
FxaaFloat edgeVert2 = (-2.0 * lumaN) + lumaNWNE;
|
FxaaFloat edgeVert2 = (-2.0 * lumaN) + lumaNWNE;
|
||||||
|
|
||||||
// ======================================== // Matches 3.11
|
// ======================================== // Matches 3.11
|
||||||
FxaaFloat lumaNWSW = lumaNW + lumaSW;
|
FxaaFloat lumaNWSW = lumaNW + lumaSW;
|
||||||
FxaaFloat lumaSWSE = lumaSW + lumaSE;
|
FxaaFloat lumaSWSE = lumaSW + lumaSE;
|
||||||
FxaaFloat edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);
|
FxaaFloat edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);
|
||||||
FxaaFloat edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);
|
FxaaFloat edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);
|
||||||
FxaaFloat edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;
|
FxaaFloat edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;
|
||||||
FxaaFloat edgeVert3 = (-2.0 * lumaS) + lumaSWSE;
|
FxaaFloat edgeVert3 = (-2.0 * lumaS) + lumaSWSE;
|
||||||
FxaaFloat edgeHorz = abs(edgeHorz3) + edgeHorz4;
|
FxaaFloat edgeHorz = abs(edgeHorz3) + edgeHorz4;
|
||||||
FxaaFloat edgeVert = abs(edgeVert3) + edgeVert4;
|
FxaaFloat edgeVert = abs(edgeVert3) + edgeVert4;
|
||||||
|
|
||||||
// ======================================== // Matches 3.11
|
// ======================================== // Matches 3.11
|
||||||
FxaaFloat subpixNWSWNESE = lumaNWSW + lumaNESE;
|
FxaaFloat subpixNWSWNESE = lumaNWSW + lumaNESE;
|
||||||
FxaaFloat lengthSign = fxaaQualityRcpFrame.x;
|
FxaaFloat lengthSign = fxaaQualityRcpFrame.x;
|
||||||
FxaaBool horzSpan = edgeHorz >= edgeVert;
|
FxaaBool horzSpan = edgeHorz >= edgeVert;
|
||||||
FxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;
|
FxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;
|
||||||
|
|
||||||
// ======================================== // Matches 3.11
|
// ======================================== // Matches 3.11
|
||||||
if(!horzSpan) lumaN = lumaW;
|
if(!horzSpan) lumaN = lumaW;
|
||||||
if(!horzSpan) lumaS = lumaE;
|
if(!horzSpan) lumaS = lumaE;
|
||||||
if(horzSpan) lengthSign = fxaaQualityRcpFrame.y;
|
if(horzSpan) lengthSign = fxaaQualityRcpFrame.y;
|
||||||
FxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM;
|
FxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM;
|
||||||
|
|
||||||
// ======================================== // Matches 3.11
|
// ======================================== // Matches 3.11
|
||||||
FxaaFloat gradientN = lumaN - lumaM;
|
FxaaFloat gradientN = lumaN - lumaM;
|
||||||
FxaaFloat gradientS = lumaS - lumaM;
|
FxaaFloat gradientS = lumaS - lumaM;
|
||||||
FxaaFloat lumaNN = lumaN + lumaM;
|
FxaaFloat lumaNN = lumaN + lumaM;
|
||||||
FxaaFloat lumaSS = lumaS + lumaM;
|
FxaaFloat lumaSS = lumaS + lumaM;
|
||||||
FxaaBool pairN = abs(gradientN) >= abs(gradientS);
|
FxaaBool pairN = abs(gradientN) >= abs(gradientS);
|
||||||
FxaaFloat gradient = max(abs(gradientN), abs(gradientS));
|
FxaaFloat gradient = max(abs(gradientN), abs(gradientS));
|
||||||
if(pairN) lengthSign = -lengthSign;
|
if(pairN) lengthSign = -lengthSign;
|
||||||
FxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);
|
FxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);
|
||||||
|
|
||||||
// ======================================== // Matches 3.11
|
// ======================================== // Matches 3.11
|
||||||
FxaaFloat2 posB;
|
FxaaFloat2 posB;
|
||||||
posB.x = posM.x;
|
posB.x = posM.x;
|
||||||
posB.y = posM.y;
|
posB.y = posM.y;
|
||||||
FxaaFloat2 offNP;
|
FxaaFloat2 offNP;
|
||||||
offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;
|
offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;
|
||||||
offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;
|
offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;
|
||||||
if(!horzSpan) posB.x += lengthSign * 0.5;
|
if(!horzSpan) posB.x += lengthSign * 0.5;
|
||||||
if( horzSpan) posB.y += lengthSign * 0.5;
|
if( horzSpan) posB.y += lengthSign * 0.5;
|
||||||
|
|
||||||
// ======================================== // Custom (but still copied from 3.11)
|
// ======================================== // Custom (but still copied from 3.11)
|
||||||
FxaaFloat subpixD = ((-2.0)*subpixC) + 3.0;
|
FxaaFloat subpixD = ((-2.0)*subpixC) + 3.0;
|
||||||
FxaaFloat subpixE = subpixC * subpixC;
|
FxaaFloat subpixE = subpixC * subpixC;
|
||||||
|
|
||||||
// ======================================== // Matches 3.11
|
// ======================================== // Matches 3.11
|
||||||
if(!pairN) lumaNN = lumaSS;
|
if(!pairN) lumaNN = lumaSS;
|
||||||
FxaaFloat gradientScaled = gradient * 1.0/4.0;
|
FxaaFloat gradientScaled = gradient * 1.0/4.0;
|
||||||
FxaaFloat lumaMM = lumaM - lumaNN * 0.5;
|
FxaaFloat lumaMM = lumaM - lumaNN * 0.5;
|
||||||
FxaaFloat subpixF = subpixD * subpixE;
|
FxaaFloat subpixF = subpixD * subpixE;
|
||||||
FxaaBool lumaMLTZero = lumaMM < 0.0;
|
FxaaBool lumaMLTZero = lumaMM < 0.0;
|
||||||
|
|
||||||
// ======================================== // Custom
|
// ======================================== // Custom
|
||||||
uint stages = quality_stages();
|
uint stages = quality_stages();
|
||||||
FxaaBool doneN = false;
|
FxaaBool doneN = false;
|
||||||
FxaaFloat2 posN = posB;
|
FxaaFloat2 posN = posB;
|
||||||
FxaaFloat lumaEndN = 0;
|
FxaaFloat lumaEndN = 0;
|
||||||
FxaaBool doneP = false;
|
FxaaBool doneP = false;
|
||||||
FxaaFloat2 posP = posB;
|
FxaaFloat2 posP = posB;
|
||||||
FxaaFloat lumaEndP = 0;
|
FxaaFloat lumaEndP = 0;
|
||||||
FxaaBool doneNP = false;
|
FxaaBool doneNP = false;
|
||||||
|
|
||||||
FxaaStep(tex, doneN, posN, lumaEndN, doneP, posP, lumaEndP, doneNP, offNP, lumaNN, gradientScaled, quality_value(0));
|
FxaaStep(tex, doneN, posN, lumaEndN, doneP, posP, lumaEndP, doneNP, offNP, lumaNN, gradientScaled, quality_value(0u));
|
||||||
if ((stages >= 1) && doneNP) {
|
if ((stages >= 1u) && doneNP) {
|
||||||
FxaaStep(tex, doneN, posN, lumaEndN, doneP, posP, lumaEndP, doneNP, offNP, lumaNN, gradientScaled, quality_value(1));
|
FxaaStep(tex, doneN, posN, lumaEndN, doneP, posP, lumaEndP, doneNP, offNP, lumaNN, gradientScaled, quality_value(1u));
|
||||||
if ((stages >= 2) && doneNP) {
|
if ((stages >= 2u) && doneNP) {
|
||||||
FxaaStep(tex, doneN, posN, lumaEndN, doneP, posP, lumaEndP, doneNP, offNP, lumaNN, gradientScaled, quality_value(2));
|
FxaaStep(tex, doneN, posN, lumaEndN, doneP, posP, lumaEndP, doneNP, offNP, lumaNN, gradientScaled, quality_value(2u));
|
||||||
if ((stages >= 3) && doneNP) {
|
if ((stages >= 3u) && doneNP) {
|
||||||
FxaaStep(tex, doneN, posN, lumaEndN, doneP, posP, lumaEndP, doneNP, offNP, lumaNN, gradientScaled, quality_value(3));
|
FxaaStep(tex, doneN, posN, lumaEndN, doneP, posP, lumaEndP, doneNP, offNP, lumaNN, gradientScaled, quality_value(3u));
|
||||||
if ((stages >= 4) && doneNP) {
|
if ((stages >= 4u) && doneNP) {
|
||||||
FxaaStep(tex, doneN, posN, lumaEndN, doneP, posP, lumaEndP, doneNP, offNP, lumaNN, gradientScaled, quality_value(4));
|
FxaaStep(tex, doneN, posN, lumaEndN, doneP, posP, lumaEndP, doneNP, offNP, lumaNN, gradientScaled, quality_value(4u));
|
||||||
if ((stages >= 5) && doneNP) {
|
if ((stages >= 5u) && doneNP) {
|
||||||
FxaaStep(tex, doneN, posN, lumaEndN, doneP, posP, lumaEndP, doneNP, offNP, lumaNN, gradientScaled, quality_value(5));
|
FxaaStep(tex, doneN, posN, lumaEndN, doneP, posP, lumaEndP, doneNP, offNP, lumaNN, gradientScaled, quality_value(5u));
|
||||||
if ((stages >= 6) && doneNP) {
|
if ((stages >= 6u) && doneNP) {
|
||||||
FxaaStep(tex, doneN, posN, lumaEndN, doneP, posP, lumaEndP, doneNP, offNP, lumaNN, gradientScaled, quality_value(6));
|
FxaaStep(tex, doneN, posN, lumaEndN, doneP, posP, lumaEndP, doneNP, offNP, lumaNN, gradientScaled, quality_value(6u));
|
||||||
if ((stages >= 7) && doneNP) {
|
if ((stages >= 7u) && doneNP) {
|
||||||
FxaaStep(tex, doneN, posN, lumaEndN, doneP, posP, lumaEndP, doneNP, offNP, lumaNN, gradientScaled, quality_value(7));
|
FxaaStep(tex, doneN, posN, lumaEndN, doneP, posP, lumaEndP, doneNP, offNP, lumaNN, gradientScaled, quality_value(7u));
|
||||||
if ((stages >= 8) && doneNP) {
|
if ((stages >= 8u) && doneNP) {
|
||||||
FxaaStep(tex, doneN, posN, lumaEndN, doneP, posP, lumaEndP, doneNP, offNP, lumaNN, gradientScaled, quality_value(8));
|
FxaaStep(tex, doneN, posN, lumaEndN, doneP, posP, lumaEndP, doneNP, offNP, lumaNN, gradientScaled, quality_value(8u));
|
||||||
if ((stages >= 9) && doneNP) {
|
if ((stages >= 9u) && doneNP) {
|
||||||
FxaaStep(tex, doneN, posN, lumaEndN, doneP, posP, lumaEndP, doneNP, offNP, lumaNN, gradientScaled, quality_value(9));
|
FxaaStep(tex, doneN, posN, lumaEndN, doneP, posP, lumaEndP, doneNP, offNP, lumaNN, gradientScaled, quality_value(9u));
|
||||||
if ((stages >= 10) && doneNP) {
|
if ((stages >= 10u) && doneNP) {
|
||||||
FxaaStep(tex, doneN, posN, lumaEndN, doneP, posP, lumaEndP, doneNP, offNP, lumaNN, gradientScaled, quality_value(0));
|
FxaaStep(tex, doneN, posN, lumaEndN, doneP, posP, lumaEndP, doneNP, offNP, lumaNN, gradientScaled, quality_value(10u));
|
||||||
if ((stages >= 11) && doneNP) {
|
if ((stages >= 11u) && doneNP) {
|
||||||
FxaaStep(tex, doneN, posN, lumaEndN, doneP, posP, lumaEndP, doneNP, offNP, lumaNN, gradientScaled, quality_value(11));
|
FxaaStep(tex, doneN, posN, lumaEndN, doneP, posP, lumaEndP, doneNP, offNP, lumaNN, gradientScaled, quality_value(11u));
|
||||||
// Present in FXAA 3.11, but not actually defined anywhere.
|
// Present in FXAA 3.11, but not actually defined anywhere.
|
||||||
// if ((stages >= 12) && doneNP) {
|
// if ((stages >= 12u) && doneNP) {
|
||||||
// FxaaStep(tex, doneN, posN, lumaEndN, doneP, posP, lumaEndP, doneNP, offNP, lumaNN, gradientScaled, quality_value(12));
|
// FxaaStep(tex, doneN, posN, lumaEndN, doneP, posP, lumaEndP, doneNP, offNP, lumaNN, gradientScaled, quality_value(12));
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
@ -457,35 +481,35 @@ FxaaFloat4 FxaaPixelShader(
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======================================== // Matches 3.11
|
// ======================================== // Matches 3.11
|
||||||
FxaaFloat dstN = posM.x - posN.x;
|
FxaaFloat dstN = posM.x - posN.x;
|
||||||
FxaaFloat dstP = posP.x - posM.x;
|
FxaaFloat dstP = posP.x - posM.x;
|
||||||
if(!horzSpan) dstN = posM.y - posN.y;
|
if(!horzSpan) dstN = posM.y - posN.y;
|
||||||
if(!horzSpan) dstP = posP.y - posM.y;
|
if(!horzSpan) dstP = posP.y - posM.y;
|
||||||
|
|
||||||
// ======================================== // Matches 3.11
|
// ======================================== // Matches 3.11
|
||||||
FxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;
|
FxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;
|
||||||
FxaaFloat spanLength = (dstP + dstN);
|
FxaaFloat spanLength = (dstP + dstN);
|
||||||
FxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;
|
FxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;
|
||||||
FxaaFloat spanLengthRcp = 1.0/spanLength;
|
FxaaFloat spanLengthRcp = 1.0/spanLength;
|
||||||
|
|
||||||
// ======================================== // Matches 3.11
|
// ======================================== // Matches 3.11
|
||||||
FxaaBool directionN = dstN < dstP;
|
FxaaBool directionN = dstN < dstP;
|
||||||
FxaaFloat dst = min(dstN, dstP);
|
FxaaFloat dst = min(dstN, dstP);
|
||||||
FxaaBool goodSpan = directionN ? goodSpanN : goodSpanP;
|
FxaaBool goodSpan = directionN ? goodSpanN : goodSpanP;
|
||||||
FxaaFloat subpixG = subpixF * subpixF;
|
FxaaFloat subpixG = subpixF * subpixF;
|
||||||
FxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5;
|
FxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5;
|
||||||
FxaaFloat subpixH = subpixG * fxaaQualitySubpix;
|
FxaaFloat subpixH = subpixG * fxaaQualitySubpix;
|
||||||
|
|
||||||
// ======================================== // Similar to 3.11
|
// ======================================== // Similar to 3.11
|
||||||
FxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0;
|
FxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0;
|
||||||
FxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH);
|
FxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH);
|
||||||
if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;
|
if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;
|
||||||
if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;
|
if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;
|
||||||
#ifdef FXAA_DISCARD
|
#ifdef FXAA_DISCARD
|
||||||
return FxaaTexTop(tex, posM);
|
return FxaaTexTop(tex, posM);
|
||||||
#else
|
#else
|
||||||
return FxaaFloat4(FxaaTexTop(tex, posM).xyz, lumaM);
|
return FxaaFloat4(FxaaTexTop(tex, posM).xyz, lumaM);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======================================== //
|
// ======================================== //
|
||||||
|
|
@ -495,7 +519,7 @@ FxaaFloat4 FxaaPixelShader(
|
||||||
|
|
||||||
FxaaFloat4 ProcessPixelShader(VertexInformation vtx) : TARGET {
|
FxaaFloat4 ProcessPixelShader(VertexInformation vtx) : TARGET {
|
||||||
return FxaaPixelShader(
|
return FxaaPixelShader(
|
||||||
vtx.texcoord0.xy,
|
vtx.texcoord0.xy + (ViewSize.zw * .5),
|
||||||
InputA,
|
InputA,
|
||||||
ViewSize.zw,
|
ViewSize.zw,
|
||||||
_100_SubpixelAliasingRemoval,
|
_100_SubpixelAliasingRemoval,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue