Commit dd999448 authored by Jonatas Esteves's avatar Jonatas Esteves
Browse files

SMAA: Expose more quality settings

- Expose all the configuration settings used by the quality presets to allow fine-tuning of edge detection.
- Changed default edge detection technique from luma to color since in my tests that always yields better results.
- Increased quality to ultra in default preset.
- Deleted the duplication of the fragment shader part of the lib, as I figured out how to include the lib twice with different defines for the vertex and fragment passes. That is necessary probably because discard cannot be used in vertex shaders in RetroArch, indicated in a comment in the lib as a possible restriction in some compilers.
- Include license headers to make clear that all my contributions are released on the public domain under the terms of the Unlicense. Anyone can do whatever they want with this.
parent 788f73b9
......@@ -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
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