From bf78706305ccac802c89f9663e88871773b55830 Mon Sep 17 00:00:00 2001 From: hunterk Date: Tue, 9 Jan 2018 11:20:52 -0600 Subject: [PATCH] add crt-potato --- crt/crt-potato-cool.slangp | 12 ++ crt/crt-potato-warm.slangp | 12 ++ .../crt-potato/resources/crt-potato-thick.png | Bin 0 -> 2821 bytes .../crt-potato/resources/crt-potato-thin.png | Bin 0 -> 2821 bytes .../crt-potato/shader-files/crt-potato.glsl | 141 ++++++++++++++++++ .../crt-potato/shader-files/crt-potato.slang | 76 ++++++++++ 6 files changed, 241 insertions(+) create mode 100644 crt/crt-potato-cool.slangp create mode 100644 crt/crt-potato-warm.slangp create mode 100644 crt/shaders/crt-potato/resources/crt-potato-thick.png create mode 100644 crt/shaders/crt-potato/resources/crt-potato-thin.png create mode 100644 crt/shaders/crt-potato/shader-files/crt-potato.glsl create mode 100644 crt/shaders/crt-potato/shader-files/crt-potato.slang diff --git a/crt/crt-potato-cool.slangp b/crt/crt-potato-cool.slangp new file mode 100644 index 0000000..8813468 --- /dev/null +++ b/crt/crt-potato-cool.slangp @@ -0,0 +1,12 @@ +shaders = 1 + +shader0 = shaders/crt-potato/shader-files/crt-potato.slang +filter_linear0 = false +scale_type0 = viewport +scale0 = 1.0 +alias0 = "PASS0" + +textures = MASK +MASK = shaders/crt-potato/resources/crt-potato-thin.png +MASK_linear = false +MASK_wrap_mode = "repeat" \ No newline at end of file diff --git a/crt/crt-potato-warm.slangp b/crt/crt-potato-warm.slangp new file mode 100644 index 0000000..e14202c --- /dev/null +++ b/crt/crt-potato-warm.slangp @@ -0,0 +1,12 @@ +shaders = 1 + +shader0 = shaders/crt-potato/shader-files/crt-potato.slang +filter_linear0 = false +scale_type0 = viewport +scale0 = 1.0 +alias0 = "PASS0" + +textures = MASK +MASK = shaders/crt-potato/resources/crt-potato-thick.png +MASK_linear = false +MASK_wrap_mode = "repeat" \ No newline at end of file diff --git a/crt/shaders/crt-potato/resources/crt-potato-thick.png b/crt/shaders/crt-potato/resources/crt-potato-thick.png new file mode 100644 index 0000000000000000000000000000000000000000..686578af20208b4d2604328038b6fc816321cdef GIT binary patch literal 2821 zcmV+g3;OhlP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQI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r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0000mNkl. // +// // +/////////////////////////////////////////////////////////////////////////// + +#if defined(VERTEX) +//////////////////////////////////////////////////////////////////////////////// +// Vertex shader // +//////////////////////////////////////////////////////////////////////////////// + +#if __VERSION__ >= 130 +#define COMPAT_VARYING out +#define COMPAT_ATTRIBUTE in +#define COMPAT_TEXTURE texture +#else +#define COMPAT_VARYING varying +#define COMPAT_ATTRIBUTE attribute +#define COMPAT_TEXTURE texture2D +#endif + +#ifdef GL_ES +#define COMPAT_PRECISION mediump +#else +#define COMPAT_PRECISION +#endif + +COMPAT_ATTRIBUTE vec4 VertexCoord; +COMPAT_ATTRIBUTE vec4 COLOR; +COMPAT_ATTRIBUTE vec4 TexCoord; +COMPAT_VARYING vec4 COL0; +COMPAT_VARYING vec4 TEX0; +COMPAT_VARYING vec2 dot_size; +COMPAT_VARYING vec2 one_texel; + +uniform mat4 MVPMatrix; +uniform COMPAT_PRECISION int FrameDirection; +uniform COMPAT_PRECISION int FrameCount; +uniform COMPAT_PRECISION vec2 OutputSize; +uniform COMPAT_PRECISION vec2 TextureSize; +uniform COMPAT_PRECISION vec2 InputSize; + +//////////////////////////////////////////////////////////////////////////////// +// Vertex definitions // +//////////////////////////////////////////////////////////////////////////////// + +#define vTexCoord TEX0.xy +#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize +#define outsize vec4(OutputSize, 1.0 / OutputSize) + +// Largest integer scale of input video that will fit in the current output (y axis would typically be limiting on widescreens) +#define video_scale floor(outsize.y * SourceSize.w) + +// Size of the scaled video +//#define scaled_video_out (SourceSize.xy * vec2(video_scale)) + +//it's... half a pixel +#define half_pixel (vec2(0.5) * outsize.zw) + +void main() +{ + vec2 scaled_video_out = (InputSize.xy * vec2(video_scale)); + // Remaps position to integer scaled output + gl_Position = MVPMatrix * VertexCoord;// / vec4( vec2(outsize.xy / scaled_video_out), 1.0, 1.0 ); + TEX0.xy = TexCoord.xy;// + vec2(0.0, half_pixel); + dot_size = SourceSize.zw; + one_texel = 1.0 / (SourceSize.xy * video_scale); +} + +#elif defined(FRAGMENT) +//////////////////////////////////////////////////////////////////////////////// +// Fragment shader // +//////////////////////////////////////////////////////////////////////////////// + +#if __VERSION__ >= 130 +#define COMPAT_VARYING in +#define COMPAT_TEXTURE texture +out vec4 FragColor; +#else +#define COMPAT_VARYING varying +#define FragColor gl_FragColor +#define COMPAT_TEXTURE texture2D +#endif + +#ifdef GL_ES +#ifdef GL_FRAGMENT_PRECISION_HIGH +precision highp float; +#else +precision mediump float; +#endif +#define COMPAT_PRECISION mediump +#else +#define COMPAT_PRECISION +#endif + +uniform COMPAT_PRECISION int FrameDirection; +uniform COMPAT_PRECISION int FrameCount; +uniform COMPAT_PRECISION vec2 OutputSize; +uniform COMPAT_PRECISION vec2 TextureSize; +uniform COMPAT_PRECISION vec2 InputSize; +uniform sampler2D Texture; +uniform sampler2D MASK; + +COMPAT_VARYING vec4 TEX0; +COMPAT_VARYING vec2 dot_size; +COMPAT_VARYING vec2 one_texel; + +// compatibility #defines +#define Source Texture +#define vTexCoord TEX0.xy + +#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize +#define outsize vec4(OutputSize, 1.0 / OutputSize) + +#define maskSize vec2(2., floor(outsize.y / InputSize.y + 0.000001)) + +//////////////////////////////////////////////////////////////////////////////// +//fragment definitions // +//////////////////////////////////////////////////////////////////////////////// + +#define curr_rgb COMPAT_TEXTURE(Source, vTexCoord) +#define mask_rgb COMPAT_TEXTURE(MASK, fract(gl_FragCoord.xy / maskSize)) + +void main() +{ + FragColor = mask_rgb * curr_rgb; +} +#endif diff --git a/crt/shaders/crt-potato/shader-files/crt-potato.slang b/crt/shaders/crt-potato/shader-files/crt-potato.slang new file mode 100644 index 0000000..0451858 --- /dev/null +++ b/crt/shaders/crt-potato/shader-files/crt-potato.slang @@ -0,0 +1,76 @@ +#version 450 + +/////////////////////////////////////////////////////////////////////////// +// // +// Copyright (C) 2017 - Brad Parker // +// // +// 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 . // +// // +/////////////////////////////////////////////////////////////////////////// + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +// Largest integer scale of input video that will fit in the current output (y axis would typically be limiting on widescreens) +#define video_scale floor(params.OutputSize.y * params.SourceSize.w) + +// Size of the scaled video +//#define scaled_video_out (params.SourceSize.xy * vec2(video_scale)) + +//it's... half a pixel +#define half_pixel (vec2(0.5) * params.OutputSize.zw) + +#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 dot_size; +layout(location = 2) out vec2 one_texel; + +void main() +{ + gl_Position = global.MVP * Position; + vTexCoord = TexCoord; + vec2 scaled_video_out = (params.SourceSize.xy * vec2(video_scale)); + dot_size = params.SourceSize.zw; + one_texel = 1.0 / (params.SourceSize.xy * video_scale); +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 1) in vec2 dot_size; +layout(location = 2) in vec2 one_texel; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; +layout(set = 0, binding = 3) uniform sampler2D MASK; + +#define maskSize vec2(2., floor(params.OutputSize.y / params.SourceSize.y + 0.000001)) + +#define curr_rgb texture(Source, vTexCoord) +#define mask_rgb texture(MASK, fract((vTexCoord.xy * params.OutputSize.xy) / maskSize)) + +void main() +{ + FragColor = mask_rgb * curr_rgb; +} \ No newline at end of file