Unverified Commit 38de4161 authored by hizzlekizzle's avatar hizzlekizzle Committed by GitHub
Browse files

Merge pull request #192 from jntesteves/feature/fsr-lfga

SMAA and FSR: The 2nd Runner
parents 788f73b9 b0b12b6a
Pipeline #51794 passed with stage
in 21 seconds
......@@ -614,7 +614,7 @@ layout(push_constant) uniform Push
### Samplers
Which samplers are used for textures are specified by the preset format.
The sampler remains constant throughout the frame, there is currently no way to select samplers on a frame-by-frame basic.
The sampler remains constant throughout the frame, there is currently no way to select samplers on a frame-by-frame basis.
This is mostly to make it possible to use the spec in GLES2 as GLES2 has no concept of separate samplers and images.
### sRGB
......
This diff is collapsed.
#version 450
// SPDX-License-Identifier: Unlicense
#pragma name SMAA_Pass0
//-----------------------------------------------------------------------------
// Edge Detection Shaders (First Pass)
#pragma parameter SMAA_EDT "SMAA Edge Detection: Luma | Color" 0.0 0.0 1.0 1.0
#pragma parameter SMAA_EDT "SMAA Edge Detection: Luma | Color" 1.0 0.0 1.0 1.0
#pragma parameter SMAA_THRESHOLD "SMAA Threshold" 0.05 0.01 0.5 0.01
#pragma parameter SMAA_MAX_SEARCH_STEPS "SMAA Max Search Steps" 32.0 4.0 112.0 1.0
#pragma parameter SMAA_MAX_SEARCH_STEPS_DIAG "SMAA Max Search Steps Diagonal" 16.0 4.0 20.0 1.0
#pragma parameter SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR "SMAA Local Contrast Adapt. Factor" 2.0 1.0 4.0 0.1
layout(push_constant) uniform Push {
vec4 SourceSize;
......@@ -11,6 +16,10 @@ layout(push_constant) uniform Push {
vec4 OutputSize;
uint FrameCount;
float SMAA_EDT;
float SMAA_THRESHOLD;
float SMAA_MAX_SEARCH_STEPS;
float SMAA_MAX_SEARCH_STEPS_DIAG;
float SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR;
} params;
layout(std140, set = 0, binding = 0) uniform UBO {
......@@ -19,8 +28,15 @@ layout(std140, set = 0, binding = 0) uniform UBO {
#define SMAA_RT_METRICS vec4(params.SourceSize.z, params.SourceSize.w, params.SourceSize.x, params.SourceSize.y)
#define SMAA_GLSL_4
#define SMAA_INCLUDE_PS 0
#include "SMAA.hlsl"
float THRESHOLD = params.SMAA_THRESHOLD;
float MAX_SEARCH_STEPS = params.SMAA_MAX_SEARCH_STEPS;
float MAX_SEARCH_STEPS_DIAG = params.SMAA_MAX_SEARCH_STEPS_DIAG;
float LOCAL_CONTRAST_ADAPTATION_FACTOR = params.SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR;
#define SMAA_THRESHOLD THRESHOLD
#define SMAA_MAX_SEARCH_STEPS MAX_SEARCH_STEPS
#define SMAA_MAX_SEARCH_STEPS_DIAG MAX_SEARCH_STEPS_DIAG
#define SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR LOCAL_CONTRAST_ADAPTATION_FACTOR
#pragma stage vertex
layout(location = 0) in vec4 Position;
......@@ -28,6 +44,9 @@ layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
layout(location = 1) out vec4 offset[3];
#define SMAA_INCLUDE_PS 0
#include "SMAA.hlsl"
void main() {
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
......@@ -40,7 +59,8 @@ layout(location = 1) in vec4 offset[3];
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source;
#include "SMAA.frag"
#define SMAA_INCLUDE_VS 0
#include "SMAA.hlsl"
void main() {
if (params.SMAA_EDT == 0.0) {
......
#version 450
// SPDX-License-Identifier: Unlicense
#pragma name SMAA_Pass1
//-----------------------------------------------------------------------------
// Blending Weight Calculation Shader (Second Pass)
#pragma parameter SMAA_THRESHOLD "SMAA Threshold" 0.05 0.01 0.5 0.01
#pragma parameter SMAA_MAX_SEARCH_STEPS "SMAA Max Search Steps" 32.0 4.0 112.0 1.0
#pragma parameter SMAA_MAX_SEARCH_STEPS_DIAG "SMAA Max Search Steps Diagonal" 16.0 4.0 20.0 1.0
#pragma parameter SMAA_CORNER_ROUNDING "SMAA Corner Rounding" 25.0 0.0 100.0 1.0
layout(push_constant) uniform Push {
vec4 SourceSize;
vec4 OriginalSize;
vec4 OutputSize;
uint FrameCount;
float SMAA_THRESHOLD;
float SMAA_MAX_SEARCH_STEPS;
float SMAA_MAX_SEARCH_STEPS_DIAG;
float SMAA_CORNER_ROUNDING;
} params;
layout(std140, set = 0, binding = 0) uniform UBO {
......@@ -16,8 +26,15 @@ layout(std140, set = 0, binding = 0) uniform UBO {
#define SMAA_RT_METRICS vec4(params.SourceSize.z, params.SourceSize.w, params.SourceSize.x, params.SourceSize.y)
#define SMAA_GLSL_4
#define SMAA_INCLUDE_PS 0
#include "SMAA.hlsl"
float THRESHOLD = params.SMAA_THRESHOLD;
float MAX_SEARCH_STEPS = params.SMAA_MAX_SEARCH_STEPS;
float MAX_SEARCH_STEPS_DIAG = params.SMAA_MAX_SEARCH_STEPS_DIAG;
float CORNER_ROUNDING = params.SMAA_CORNER_ROUNDING;
#define SMAA_THRESHOLD THRESHOLD
#define SMAA_MAX_SEARCH_STEPS MAX_SEARCH_STEPS
#define SMAA_MAX_SEARCH_STEPS_DIAG MAX_SEARCH_STEPS_DIAG
#define SMAA_CORNER_ROUNDING CORNER_ROUNDING
#pragma stage vertex
layout(location = 0) in vec4 Position;
......@@ -26,6 +43,9 @@ layout(location = 0) out vec2 vTexCoord;
layout(location = 1) out vec2 pixcoord;
layout(location = 2) out vec4 offset[3];
#define SMAA_INCLUDE_PS 0
#include "SMAA.hlsl"
void main() {
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
......@@ -41,7 +61,8 @@ layout(set = 0, binding = 2) uniform sampler2D Source;
layout(set = 0, binding = 3) uniform sampler2D areaTex;
layout(set = 0, binding = 4) uniform sampler2D searchTex;
#include "SMAA.frag"
#define SMAA_INCLUDE_VS 0
#include "SMAA.hlsl"
void main() {
vec4 subsampleIndices = vec4(0.0);
......
#version 450
// SPDX-License-Identifier: Unlicense
#pragma name SMAA_Pass2
//-----------------------------------------------------------------------------
// Neighborhood Blending Shader (Third Pass)
......@@ -16,8 +17,6 @@ layout(std140, set = 0, binding = 0) uniform UBO {
#define SMAA_RT_METRICS vec4(params.SourceSize.z, params.SourceSize.w, params.SourceSize.x, params.SourceSize.y)
#define SMAA_GLSL_4
#define SMAA_INCLUDE_PS 0
#include "SMAA.hlsl"
#pragma stage vertex
layout(location = 0) in vec4 Position;
......@@ -25,6 +24,9 @@ layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
layout(location = 1) out vec4 offset;
#define SMAA_INCLUDE_PS 0
#include "SMAA.hlsl"
void main() {
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
......@@ -38,7 +40,8 @@ layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source;
layout(set = 0, binding = 3) uniform sampler2D SMAA_Input;
#include "SMAA.frag"
#define SMAA_INCLUDE_VS 0
#include "SMAA.hlsl"
void main() {
FragColor = SMAANeighborhoodBlendingPS(vTexCoord, offset, SMAA_Input, Source);
......
......@@ -30,8 +30,13 @@ filter_linear4 = false
scale_type4 = source
scale4 = 1.0
parameters = "SMAA_EDT;SHARPEN;CONTR;DETAILS"
parameters = "SMAA_EDT;SMAA_THRESHOLD;SMAA_MAX_SEARCH_STEPS;SMAA_MAX_SEARCH_STEPS_DIAG;SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR;SMAA_CORNER_ROUNDING;SHARPEN;CONTR;DETAILS"
SMAA_EDT = 1.0
SMAA_THRESHOLD = 0.05
SMAA_MAX_SEARCH_STEPS = 40
SMAA_MAX_SEARCH_STEPS_DIAG = 20
SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR = 2.5
SMAA_CORNER_ROUNDING = 50.0
SHARPEN = 0.9
CONTR = 0.01
CONTR = 0.0
DETAILS = 0.2
......@@ -25,5 +25,10 @@ textures = "areaTex;searchTex"
areaTex = shaders/smaa/AreaTex.png
searchTex = shaders/smaa/SearchTex.png
parameters = "SMAA_EDT"
SMAA_EDT = 0.0
parameters = "SMAA_EDT;SMAA_THRESHOLD;SMAA_MAX_SEARCH_STEPS;SMAA_MAX_SEARCH_STEPS_DIAG;SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR;SMAA_CORNER_ROUNDING"
SMAA_EDT = 1.0
SMAA_THRESHOLD = 0.05
SMAA_MAX_SEARCH_STEPS = 32
SMAA_MAX_SEARCH_STEPS_DIAG = 16
SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR = 2.0
SMAA_CORNER_ROUNDING = 25.0
......@@ -10,6 +10,8 @@ filter_linear1 = true
scale_type1 = source
scale1 = 1.0
parameters = "FSR_SHARPENING;FSR_FILMGRAIN"
parameters = "FSR_SHARPENING;FSR_FILMGRAIN;FSR_GRAINCOLOR;FSR_GRAINPDF"
FSR_SHARPENING = 0.3
FSR_FILMGRAIN = 0.10
FSR_FILMGRAIN = 0.3
FSR_GRAINCOLOR = 1.0
FSR_GRAINPDF = 0.3
#version 450
// SPDX-License-Identifier: Unlicense
#pragma name FSR_EASU
// FSR - [EASU] EDGE ADAPTIVE SPATIAL UPSAMPLING
......@@ -40,15 +41,9 @@ layout(set = 0, binding = 2) uniform sampler2D Source;
#define FSR_EASU_F 1
AU4 con0, con1, con2, con3;
AF4 FsrEasuRF(AF2 p) {
return textureGather(Source, p, 0);
}
AF4 FsrEasuGF(AF2 p) {
return textureGather(Source, p, 1);
}
AF4 FsrEasuBF(AF2 p) {
return textureGather(Source, p, 2);
}
AF4 FsrEasuRF(AF2 p) { return textureGather(Source, p, 0); }
AF4 FsrEasuGF(AF2 p) { return textureGather(Source, p, 1); }
AF4 FsrEasuBF(AF2 p) { return textureGather(Source, p, 2); }
#include "ffx_fsr1.h"
......
#version 450
// SPDX-License-Identifier: Unlicense
#pragma name FSR_RCAS
// FSR - [RCAS] ROBUST CONTRAST ADAPTIVE SHARPENING
......@@ -8,7 +9,9 @@
// scale1 = 1.0
#pragma parameter FSR_SHARPENING "FSR RCAS Sharpening Amount (Lower = Sharper)" 0.2 0.0 2.0 0.1
#pragma parameter FSR_FILMGRAIN "FSR LFGA Film Grain Intensity" 0.10 0.0 1.0 0.02
#pragma parameter FSR_FILMGRAIN "FSR LFGA Film Grain Intensity" 0.3 0.0 2.0 0.02
#pragma parameter FSR_GRAINCOLOR "FSR LFGA Film Grain Color: Gray | RGB" 1.0 0.0 1.0 1.0
#pragma parameter FSR_GRAINPDF "FSR LFGA Grain PDF Curve (0.5 = Triangular, Lower = Gaussian)" 0.3 0.1 0.5 0.05
layout(push_constant) uniform Push {
vec4 SourceSize;
......@@ -17,6 +20,8 @@ layout(push_constant) uniform Push {
uint FrameCount;
float FSR_SHARPENING;
float FSR_FILMGRAIN;
float FSR_GRAINCOLOR;
float FSR_GRAINPDF;
} params;
layout(std140, set = 0, binding = 0) uniform UBO {
......@@ -45,14 +50,31 @@ layout(set = 0, binding = 2) uniform sampler2D Source;
#define FSR_RCAS_F 1
AU4 con0;
AF4 FsrRcasLoadF(ASU2 p) {
return AF4(texelFetch(Source, ASU2(p), 0));
}
AF4 FsrRcasLoadF(ASU2 p) { return AF4(texelFetch(Source, p, 0)); }
void FsrRcasInputF(inout AF1 r, inout AF1 g, inout AF1 b) {}
#include "ffx_fsr1.h"
// prng: A simple but effective pseudo-random number generator [0;1[
float prng(vec2 uv, float time) {
return fract(sin(dot(uv + fract(time), vec2(12.9898, 78.233))) * 43758.5453);
}
// pdf: [-0.5;0.5[
// Removes noise modulation effect by reshaping the uniform/rectangular noise
// distribution (RPDF) into a Triangular (TPDF) or Gaussian Probability Density
// Function (GPDF).
// shape = 1.0: Rectangular
// shape = 0.5: Triangular
// shape < 0.5: Gaussian (0.2~0.4)
float pdf(float noise, float shape) {
float orig = noise * 2.0 - 1.0;
noise = pow(abs(orig), shape);
noise *= sign(orig);
noise -= sign(orig);
return noise * 0.5;
}
void main() {
FsrRcasCon(con0, params.FSR_SHARPENING);
......@@ -62,8 +84,17 @@ void main() {
// FSR - [LFGA] LINEAR FILM GRAIN APPLICATOR
if (params.FSR_FILMGRAIN > 0.0) {
AF1 noise = fract(10000 * sin(((vTexCoord.x + vTexCoord.y * A_2PI) * params.FrameCount)));
FsrLfgaF(Gamma2Color, AF3_(noise - 0.5), params.FSR_FILMGRAIN);
if (params.FSR_GRAINCOLOR == 0.0) {
float noise = pdf(prng(vTexCoord, params.FrameCount * 0.11), params.FSR_GRAINPDF);
FsrLfgaF(Gamma2Color, vec3(noise), params.FSR_FILMGRAIN);
} else {
vec3 rgbNoise = vec3(
pdf(prng(vTexCoord, params.FrameCount * 0.11), params.FSR_GRAINPDF),
pdf(prng(vTexCoord, params.FrameCount * 0.13), params.FSR_GRAINPDF),
pdf(prng(vTexCoord, params.FrameCount * 0.17), params.FSR_GRAINPDF)
);
FsrLfgaF(Gamma2Color, rgbNoise, params.FSR_FILMGRAIN);
}
}
FragColor = vec4(Gamma2Color, 1.0);
......
......@@ -35,7 +35,14 @@ filter_linear5 = true
scale_type5 = source
scale5 = 1.0
parameters = "SMAA_EDT;FSR_SHARPENING;FSR_FILMGRAIN"
parameters = "SMAA_EDT;SMAA_THRESHOLD;SMAA_MAX_SEARCH_STEPS;SMAA_MAX_SEARCH_STEPS_DIAG;SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR;SMAA_CORNER_ROUNDING;FSR_SHARPENING;FSR_FILMGRAIN;FSR_GRAINCOLOR;FSR_GRAINPDF"
SMAA_EDT = 1.0
SMAA_THRESHOLD = 0.05
SMAA_MAX_SEARCH_STEPS = 40
SMAA_MAX_SEARCH_STEPS_DIAG = 20
SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR = 2.5
SMAA_CORNER_ROUNDING = 50.0
FSR_SHARPENING = 0.1
FSR_FILMGRAIN = 0.12
FSR_FILMGRAIN = 0.3
FSR_GRAINCOLOR = 1.0
FSR_GRAINPDF = 0.3
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment