slang-shaders/bezel/Mega_Bezel/shaders/dedither/dedither-gamma-prep-2-after.slang

74 lines
2.4 KiB
Plaintext
Raw Permalink Normal View History

2022-09-27 11:38:41 +10:00
#version 450
/*
Mega Bezel - Creates a graphic treatment for the game play area to give a retro feel
Copyright (C) 2019-2022 HyperspaceMadness - HyperspaceMadness@outlook.com
Incorporates much great feedback from the libretro forum, and thanks
to Hunterk who helped me get started
See more at the libretro forum
https://forums.libretro.com/t/hsm-mega-bezel-reflection-shader-feedback-and-updates
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2022-10-11 07:26:21 +11:00
#include "../base/common/helper-functions.inc"
2022-09-27 11:38:41 +10:00
layout(push_constant) uniform Push
{
vec4 SourceSize;
vec4 OriginalSize;
vec4 OutputSize;
uint FrameCount;
2023-01-26 04:59:48 +11:00
float SGPT_BLEND_OPTION;
2022-09-27 11:38:41 +10:00
float HSM_DEDITHER_BRIGHTNESS_BIAS;
} params;
2022-10-11 07:26:21 +11:00
layout(std140, set = 0, binding = 0) uniform UBO
{
mat4 MVP;
} global;
2023-01-26 04:59:48 +11:00
#pragma parameter HSM_SGENPT_EMPTY_LINE " " 0 0 0.001 0.001
#pragma parameter HSM_SGENPT_TITLE "[ --- HYLLIAN SGENPT-MIX DE-DITHERING --- ]:" 0 0 0.01 0.01
2022-09-27 11:38:41 +10:00
2023-01-26 04:59:48 +11:00
#pragma parameter SGPT_BLEND_OPTION " Mode: OFF | CHECKERBOARD | VERTICAL LINES | BOTH" 0.0 0.0 3.0 1.0
#define SGPT_BLEND_OPTION params.SGPT_BLEND_OPTION
2022-09-27 11:38:41 +10:00
#pragma parameter HSM_DEDITHER_BRIGHTNESS_BIAS " Transparency Brightness Bias" 100 10 300 5
#define HSM_DEDITHER_BRIGHTNESS_BIAS params.HSM_DEDITHER_BRIGHTNESS_BIAS * 0.013
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
void main()
{
gl_Position = global.MVP * Position;
vTexCoord = TexCoord;
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source;
void main()
{
FragColor = texture(Source, vTexCoord);
2023-01-26 04:59:48 +11:00
if (SGPT_BLEND_OPTION > 0.5)
2022-09-27 11:38:41 +10:00
FragColor = HSM_Delinearize(texture(Source, vTexCoord), HSM_DEDITHER_BRIGHTNESS_BIAS);
}