From e9dfc8143e7fb6417da600699f57e68b8ab3b445 Mon Sep 17 00:00:00 2001 From: hunterk Date: Wed, 22 May 2019 14:24:40 -0500 Subject: [PATCH] fix broken paths and add edge-detect shader; closes #101 --- .../metacrt/metacrt-shadertoy-passes.slangp | 19 ----- handheld/lcd-grid-v2-motionblur.glslp | 28 ------- misc/edge-detect.slang | 83 +++++++++++++++++++ presets/bigblur-lottes-multipass.slangp | 69 --------------- 4 files changed, 83 insertions(+), 116 deletions(-) delete mode 100644 crt/shaders/metacrt/metacrt-shadertoy-passes.slangp delete mode 100644 handheld/lcd-grid-v2-motionblur.glslp create mode 100644 misc/edge-detect.slang delete mode 100644 presets/bigblur-lottes-multipass.slangp diff --git a/crt/shaders/metacrt/metacrt-shadertoy-passes.slangp b/crt/shaders/metacrt/metacrt-shadertoy-passes.slangp deleted file mode 100644 index b5260b5..0000000 --- a/crt/shaders/metacrt/metacrt-shadertoy-passes.slangp +++ /dev/null @@ -1,19 +0,0 @@ -shaders = 3 - -shader0 = shaders/metacrt/bufC.slang -scale_type0 = viewport -filter_linear0 = true - -shader1 = shaders/metacrt/bufD.slang -scale_type1 = viewport -filter_linear1 = true - -shader2 = shaders/metacrt/Image.slang -scale_type2 = viewport -filter_linear2 = true - -textures = "cubeMap;table" -cubeMap = shaders/metacrt/basilica.png -cubeMap_wrap_mode = repeat -table = shaders/metacrt/woodgrain.png -table_wrap_mode = repeat \ No newline at end of file diff --git a/handheld/lcd-grid-v2-motionblur.glslp b/handheld/lcd-grid-v2-motionblur.glslp deleted file mode 100644 index 591980e..0000000 --- a/handheld/lcd-grid-v2-motionblur.glslp +++ /dev/null @@ -1,28 +0,0 @@ -shaders = "2" -shader0 = "../motionblur/shaders/response-time.glsl" -shader1 = "shaders/lcd-cgwg/lcd-grid-v2.glsl" - -scale_type0 = "source" -scale0 = "1.0" - -scale_type1 = "viewport" -scale1 = "1.0" - -filter_linear0 = "false" -filter_linear1 = "false" - -parameters = "RSUBPIX_R;RSUBPIX_G;RSUBPIX_B;GSUBPIX_R;GSUBPIX_G;GSUBPIX_B;BSUBPIX_R;BSUBPIX_G;BSUBPIX_B;gain;gamma;blacklevel;ambient;BGR" -RSUBPIX_R = "0.750000" -RSUBPIX_G = "0.000000" -RSUBPIX_B = "0.000000" -GSUBPIX_R = "0.000000" -GSUBPIX_G = "0.750000" -GSUBPIX_B = "0.000000" -BSUBPIX_R = "0.000000" -BSUBPIX_G = "0.000000" -BSUBPIX_B = "0.750000" -gain = "1.500000" -gamma = "2.200000" -blacklevel = "0.000000" -ambient = "0.000000" -BGR = "0.000000" diff --git a/misc/edge-detect.slang b/misc/edge-detect.slang new file mode 100644 index 0000000..6701f78 --- /dev/null +++ b/misc/edge-detect.slang @@ -0,0 +1,83 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; + float minimum; + float maximum; +} params; + +#pragma parameter minimum "Edge Thresh Min" 0.05 0.0 1.0 0.01 +#pragma parameter maximum "Edge Thresh Max" 0.35 0.0 1.0 0.01 + +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; + +float threshold(float thr1, float thr2 , float val) { + val = (val < thr1) ? 0.0 : val; + val = (val > thr2) ? 1.0 : val; + return val; +} + +// averaged pixel intensity from 3 color channels +float avg_intensity(vec4 pix) { + return dot(pix.rgb, vec3(0.2126, 0.7152, 0.0722)); +} + +vec4 get_pixel(sampler2D tex, vec2 coords, float dx, float dy) { + return texture(tex, coords + vec2(dx, dy)); +} + +// returns pixel color +float IsEdge(sampler2D tex, vec2 coords){ + float dxtex = params.SourceSize.z; + float dytex = params.SourceSize.w; + float pix[9]; + int k = -1; + float delta; + + // read neighboring pixel intensities + for (int i=-1; i<2; i++) { + for(int j=-1; j<2; j++) { + k++; + pix[k] = avg_intensity(get_pixel(tex, coords, float(i) * dxtex, + float(j) * dytex)); + } + } + + // average color differences around neighboring pixels + delta = (abs(pix[1]-pix[7])+ + abs(pix[5]-pix[3]) + + abs(pix[0]-pix[8])+ + abs(pix[2]-pix[6]) + )/4.; + + return threshold(params.minimum, params.maximum,clamp(delta,0.0,1.0)); +} + +void main() +{ + float test = IsEdge(Source, vTexCoord); + FragColor = vec4(test); +} diff --git a/presets/bigblur-lottes-multipass.slangp b/presets/bigblur-lottes-multipass.slangp deleted file mode 100644 index f4ec960..0000000 --- a/presets/bigblur-lottes-multipass.slangp +++ /dev/null @@ -1,69 +0,0 @@ -shaders = 13 - -shader0 = ../crt/shaders/crt-lottes-multipass/old/linearize.slang -srgb_framebuffer0 = true -alias0 = "REFERENCE" - -shader1 = ../crt/shaders/crt-lottes-multipass/old/horz3minus1.slang -srgb_framebuffer1 = true -scale_type1 = source -filter_linear1 = true -alias1 = horz3minus1 - -shader2 = ../crt/shaders/crt-lottes-multipass/old/horz3plus1.slang -srgb_framebuffer2 = true -scale_type2 = source -filter_linear2 = true -alias2 = horz3plus1 - -shader3 = ../crt/shaders/crt-lottes-multipass/old/horz5minus2.slang -srgb_framebuffer3 = true -scale_type3 = source -filter_linear3 = true -alias3 = horz5minus2 - -shader4 = ../crt/shaders/crt-lottes-multipass/old/horz5.slang -srgb_framebuffer4 = true -scale_type4 = source -filter_linear4 = true -alias4 = horz5 - -shader5 = ../crt/shaders/crt-lottes-multipass/old/horz5plus2.slang -srgb_framebuffer5 = true -scale_type5 = source -filter_linear5 = true -alias5 = horz5plus2 - -shader6 = ../crt/shaders/crt-lottes-multipass/old/horz7minus1.slang -srgb_framebuffer6 = true -scale_type6 = source -filter_linear6 = true -alias6 = horz7minus1 - -shader7 = ../crt/shaders/crt-lottes-multipass/old/horz7.slang -srgb_framebuffer7 = true -scale_type7 = source -filter_linear7 = true -alias7 = horz7 - -shader8 = ../crt/shaders/crt-lottes-multipass/old/horz7plus1.slang -srgb_framebuffer8 = true -scale_type8 = source -filter_linear8 = true -alias8 = horz7plus1 - -shader9 = ../crt/shaders/crt-lottes-multipass/old/crt-lottes-multipass.slang -scale_type9 = source -scale9 = 4.0 -filter_linear9 = false -alias9 = Reference - -shader10 = ../blurs/blur11resize-vertical.slang -scale_type10 = source -scale10 = 0.5 - -shader11 = ../blurs/blur11resize-horizontal.slang -scale_type11 = source -scale11 = 0.5 - -shader12 = ../border/shaders/bigblur.slang \ No newline at end of file