diff --git a/crt/shaders/slotmask.slang b/crt/shaders/slotmask.slang new file mode 100644 index 0000000..c8a743b --- /dev/null +++ b/crt/shaders/slotmask.slang @@ -0,0 +1,125 @@ +#version 450 + +/* + OSSC Slot Mask simulator + by DariusG @2023 + +*/ + +layout(push_constant) uniform Push +{ + float MASK_INTENSITY; + float InputGamma; + float OutputGamma; + float THRESH,size, msk_scale; +} params; + +// Parameter lines go here: + +#pragma parameter msk_scale "Mask Scale, to be equal to OSSC LINES" 4.0 4.0 5.0 1.0 +#define msk_scale params.msk_scale + +#pragma parameter MASK_INTENSITY "Mask Brightness" 0.2 0.0 1.0 0.05 +#define MASK_INTENSITY params.MASK_INTENSITY + +#pragma parameter size "Mask Size" 1.0 1.0 8.0 1.0 +#define size params.size + +#pragma parameter THRESH "Mask Threshold" 0.3 0.0 1.0 0.05 +#define THRESH params.THRESH + + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} global; + +#define SourceSize global.SourceSize + + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 vTexCoord; +layout(location = 1) out vec2 ps; + +void main() +{ + gl_Position = global.MVP * Position; + vTexCoord.xy = TexCoord.xy; +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 1) in vec2 ps; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 1) uniform sampler2D Source; + +vec3 mask(vec2 pos, vec3 col) +{ + vec3 msk = vec3 (MASK_INTENSITY); + float x,y; + vec2 p = pos*global.OutputSize.xy; + p = (p/size); + + +if (msk_scale == 4.0) +{ + x = fract(p.x/6.0); + y = fract(p.y/4.0); + if (x < 0.5){ + if (x<1.0/6.0 && y > 1.0/4.0) msk.b = 1.0; + else if (x<2.0/6.0 && x>1.0/6.0 && y < 3.0/4.0 ) msk.g = 1.0; + else if (x<3.0/6.0 && x>2.0/6.0 && y > 1.0/4.0 ) msk.r = 1.0; + } + + else if (x > 0.4999){ + if (x<4.0/6.0 && y < 3.0/4.0) msk.b = 1.0; + else if (x<5.0/6.0 && x>4.0/6.0 && y > 1.0/4.0 ) msk.g = 1.0; + else if (x<6.0/6.0 && x>5.0/6.0 && y < 3.0/4.0 ) msk.r = 1.0; + } +} + +if (msk_scale == 5.0) +{ + x = fract(p.x/6.0); + y = fract(p.y/5.0); + if (x < 0.5){ + if (x<1.0/6.0 && y > 1.0/5.0) msk.b = 1.0; + else if (x<2.0/6.0 && x>1.0/6.0 && y < 4.0/5.0 ) msk.g = 1.0; + else if (x<3.0/6.0 && x>2.0/6.0 && y > 1.0/5.0 ) msk.r = 1.0; + } + + else if (x > 0.4999){ + if (x<4.0/6.0 && y < 2.0/5.0 || x<4.0/6.0 && y >= 3.0/5.0) msk.b = 1.0; + else if (x<5.0/6.0 && x>4.0/6.0 && y < 3.0/5.0 || x<5.0/6.0 && x>4.0/6.0 && y >= 4.0/5.0 ) msk.g = 1.0; + else if (x<6.0/6.0 && x>5.0/6.0 && y < 2.0/5.0 || x<6.0/6.0 && x>5.0/6.0 && y >= 3.0/5.0 ) msk.r = 1.0; + } +} + + col *= msk; + + return col; +} + +void main() +{ + vec2 OGL2Pos = vTexCoord*SourceSize.xy; + float cent = floor(OGL2Pos.y)+0.5; + float ycoord = cent*SourceSize.w; + ycoord = mix(vTexCoord.y, ycoord,0.7); + + vec3 col = texture(Source,vec2(vTexCoord.x,ycoord)).rgb; + float l = dot(col,vec3(0.22,0.70,0.08)); + + col = col*col; + col = mix(mask(vTexCoord,col), col,l*THRESH); + col = sqrt(col); + + col *= mix(1.0,1.3,l); //brightboost + FragColor = vec4(col, 1.0); +} diff --git a/scanlines/ossc_slot.slangp b/scanlines/ossc_slot.slangp new file mode 100644 index 0000000..612661f --- /dev/null +++ b/scanlines/ossc_slot.slangp @@ -0,0 +1,23 @@ +shaders = "3" +feedback_pass = "0" +shader0 = "../misc/shaders/image-adjustment.slang" +filter_linear2 = "false" +scale_type_x0 = "source" +scale_x0 = "1.000000" +scale_type_y0 = "source" +scale_y0 = "1.000000" +shader1 = "../scanlines/shaders/ossc.slang" +filter_linear2 = "false" +scale_type_x1 = "viewport" +scale_x1 = "1.000000" +scale_type_y1 = "viewport" +scale_y1 = "1.000000" +shader2 = "../crt/shaders/slotmask.slang" +filter_linear2 = "true" +ia_saturation = "1.300000" +ia_black_level = "0.060000" +ia_bright_boost = "0.100000" +L1 = "0.500000" +L4 = "0.500000" +L5 = "0.600000" +HYBRID = "0.250000"