From 4d12bed8bc405027eb325729de66d63393e3976a Mon Sep 17 00:00:00 2001 From: metallic77 <43163462+metallic77@users.noreply.github.com> Date: Wed, 10 May 2023 16:54:16 +0300 Subject: [PATCH] add ossc like shader (#421) * add ossc-like shader --- scanlines/ossc.slangp | 4 + scanlines/shaders/ossc.slang | 146 +++++++++++++++++++++++++++++++++++ 2 files changed, 150 insertions(+) create mode 100644 scanlines/ossc.slangp create mode 100644 scanlines/shaders/ossc.slang diff --git a/scanlines/ossc.slangp b/scanlines/ossc.slangp new file mode 100644 index 00000000..1f4cbdb3 --- /dev/null +++ b/scanlines/ossc.slangp @@ -0,0 +1,4 @@ +shaders = 1 + +shader0 = shaders/ossc.slang +scale_type0 = viewport diff --git a/scanlines/shaders/ossc.slang b/scanlines/shaders/ossc.slang new file mode 100644 index 00000000..18858f37 --- /dev/null +++ b/scanlines/shaders/ossc.slang @@ -0,0 +1,146 @@ +#version 450 + + +// An OSSC-like shader +// By DariusG @May/2023 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; + float OVERSCAN,ASPECTx,ASPECTy, LINES, L1, L2,L3,L4,L5,TATE, HYBRID; +} params; + +#pragma parameter LINES "Lines" 4.0 2.0 5.0 1.0 +#define LINES params.LINES + +#pragma parameter TATE "TATE mode" 0.0 0.0 1.0 1.0 +#define TATE params.TATE + +#pragma parameter L1 "Line 1 Scanline Strength %" 0.25 0.0 1.0 0.01 +#define L1 params.L1 + +#pragma parameter L2 "Line 2 Scanline Strength %" 0.0 0.0 1.0 0.01 +#define L2 params.L2 + +#pragma parameter L3 "Line 3 Scanline Strength %" 0.0 0.0 1.0 0.01 +#define L3 params.L3 + +#pragma parameter L4 "Line 4 Scanline Strength %" 0.4 0.0 1.0 0.01 +#define L4 params.L4 + +#pragma parameter L5 "Line 5 Scanline Strength %" 0.5 0.0 1.0 0.01 +#define L5 params.L5 + +#pragma parameter HYBRID "Scanline Hybrid Blend % (depend on pixel overlayed)" 0.0 0.0 1.0 0.01 +#define HYBRID params.HYBRID + +#pragma parameter OVERSCAN "Overscan" 0.0 0.0 1.0 1.0 +#define OVERSCAN params.OVERSCAN + +#pragma parameter something "--Set Retroarch Aspect to FULL--" 0.0 0.0 0.0 0.0 + +#pragma parameter ASPECTx "Aspect Ratio X" 4.0 1.0 32.0 1.0 +#define ASPECTx params.ASPECTx + +#pragma parameter ASPECTy "Aspect Ratio Y" 3.0 1.0 32.0 1.0 +#define ASPECTy params.ASPECTy + +#define OutputSize params.OutputSize +#define SourceSize params.SourceSize +#define OriginalSize params.OriginalSize + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; + +} global; + +#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; + +vec2 Overscan(vec2 pos, float dx, float dy){ + pos=pos*2.0-1.0; + pos*=vec2(dx/(ASPECTx/ASPECTy/OutputSize.x*OutputSize.y),dy); + return pos*0.5 + 0.5; +} + +float scanline5(float y, float lm) +{ + float l = 1.0/LINES; + float m = fract(y*l); + if (m