fx 13 sobel filter

This commit is contained in:
2025-11-09 21:24:15 +01:00
parent 800503bbad
commit d58b8c56a6
5 changed files with 48 additions and 15 deletions
+2 -2
View File
@@ -94,8 +94,8 @@ make -f Makefile.dev release-arch
- [ ] src 15 : ? - [ ] src 15 : ?
- [x] fx 11 : spill - [x] fx 11 : spill
- [x] fx 12 : game of life - [x] fx 12 : game of life
- [ ] fx 13 : colorize range (pretty color ranges) - [x] fx 13 : sobel
- [ ] fx 14 : ? - [ ] fx 14 : colorize range (pretty color ranges)
- [ ] fx 15 : ? - [ ] fx 15 : ?
- [x] frag 10 : move debug screen here - [x] frag 10 : move debug screen here
- [ ] debug : add src/fx/A/B indicators - [ ] debug : add src/fx/A/B indicators
+3 -3
View File
@@ -153,9 +153,9 @@ options:
| | **9** | Isometric grid | _Zoom_ | _Scroll_ | _Elevation_ | Lens | _Lens limit_ | _Lens power_ | _Pre Zoom_ | | | **9** | Isometric grid | _Zoom_ | _Scroll_ | _Elevation_ | Lens | _Lens limit_ | _Lens power_ | _Pre Zoom_ |
| **3** | **A** | Video In 2 + Thru | _Hue_ | _Saturation_ | _Light_ | Spill | _Bottom limit_ | _Top Limit_ | _Rotation_ | | **3** | **A** | Video In 2 + Thru | _Hue_ | _Saturation_ | _Light_ | Spill | _Bottom limit_ | _Top Limit_ | _Rotation_ |
| | **B** | Scales | _Zoom_ | _Shape_ | _Ripples_ | Game Of Life | _Pixel Size_ | _Ruleset/Threshold_ | _Feedback_ | | | **B** | Scales | _Zoom_ | _Shape_ | _Ripples_ | Game Of Life | _Pixel Size_ | _Ruleset/Threshold_ | _Feedback_ |
| | **C** | (same as 1) | | | | | (same as 1) | | | | | **C** | (same as 6) | | | | Sobel Filter | _Horz. filter_ | _Vert. filter_ | _Filter Size_ |
| | **D** | (same as 2) | | | | | (same as 2) | | | | | **D** | (same as 7) | | | | (same as 0) | | | |
| | **E** | (same as 3) | | | | | (same as 3) | | | | | **E** | (same as 8) | | | | (same as 1) | | | |
TODO update TODO update
+16
View File
@@ -273,6 +273,22 @@ vec4 reframe_b(sampler2D tex, vec2 uv)
return texture(tex, uv); return texture(tex, uv);
} }
vec4 kernel(sampler2D tex, vec2 uv, mat3x3 k, float spm)
{
int x, y;
vec2 offset;
vec4 sum = vec4(0);
for (y = -1; y <= 1; ++y) {
for (x = -1; x <= 1; ++x) {
offset = vec2(x, y) * spm;
if (abs(k[x + 1][y + 1]) > 0) {
sum += k[x + 1][y + 1] * texture(tex, uv + offset);
}
}
}
return sum;
}
// BLUR // BLUR
float gaussian_weight(float x, float sigma) float gaussian_weight(float x, float sigma)
+16 -7
View File
@@ -367,7 +367,7 @@ subroutine(fx_stage_sub) vec4 fx_12(vec2 vUV, sampler2D previous, sampler2D feed
vec3 c0 = texture(previous, uv0).xyz; vec3 c0 = texture(previous, uv0).xyz;
vec2 uv2 = uv1; vec2 uv2 = uv1;
float k1 = pow(2, 10 - floor(pixel_size * 6)); float k1 = pow(2, 9 - floor(pixel_size * 5));
float p = 1 / k1; float p = 1 / k1;
uv2 = round(uv2 * k1) / k1; uv2 = round(uv2 * k1) / k1;
vec3 c1 = mix( vec3 c1 = mix(
@@ -458,10 +458,9 @@ subroutine(fx_stage_sub) vec4 fx_12(vec2 vUV, sampler2D previous, sampler2D feed
return fx_master(c0, cout, seed, m0); return fx_master(c0, cout, seed, m0);
} }
// TODO FX 13 // FX 13 : Sobel
subroutine(fx_stage_sub) vec4 fx_13(vec2 vUV, sampler2D previous, sampler2D feedback, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3, vec3 m0) subroutine(fx_stage_sub) vec4 fx_13(vec2 vUV, sampler2D previous, sampler2D feedback, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3, vec3 m0)
{ {
return fx_2(vUV, previous, feedback, seed, b1, f1, b2, f2, b3, f3, m0);
// start // start
vec2 uv0 = vUV.st; vec2 uv0 = vUV.st;
@@ -470,10 +469,20 @@ subroutine(fx_stage_sub) vec4 fx_13(vec2 vUV, sampler2D previous, sampler2D feed
// controls // controls
float sx = magic(f1, b1, seed + 10) * 2;
float sy = magic(f2, b2, seed + 20) * 2;
float disp = 0.005 * magic(f3, b3, seed + 30);
// logic // logic
vec3 c0 = texture(previous, uv0).xyz; vec3 c0 = texture(previous, uv0).xyz;
vec3 c = c0;
const mat3x3 sobelx = {{-1, -2, -1}, {0, 0, 0}, {1, 2, 1}};
const mat3x3 sobely = {{-1, 0, 1}, {-2, 0, 2}, {-1, 0, 1}};
mat3x3 sobel = sobelx * sx + sobely * sy;
vec3 c = abs(kernel(previous, uv0, sobel, disp).xyz);
return fx_master(c0, c, seed, m0); return fx_master(c0, c, seed, m0);
} }
@@ -481,7 +490,7 @@ subroutine(fx_stage_sub) vec4 fx_13(vec2 vUV, sampler2D previous, sampler2D feed
// TODO FX 14 // TODO FX 14
subroutine(fx_stage_sub) vec4 fx_14(vec2 vUV, sampler2D previous, sampler2D feedback, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3, vec3 m0) subroutine(fx_stage_sub) vec4 fx_14(vec2 vUV, sampler2D previous, sampler2D feedback, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3, vec3 m0)
{ {
return fx_3(vUV, previous, feedback, seed, b1, f1, b2, f2, b3, f3, m0); return fx_1(vUV, previous, feedback, seed, b1, f1, b2, f2, b3, f3, m0);
// start // start
vec2 uv0 = vUV.st; vec2 uv0 = vUV.st;
@@ -501,7 +510,7 @@ subroutine(fx_stage_sub) vec4 fx_14(vec2 vUV, sampler2D previous, sampler2D feed
// TODO FX 15 // TODO FX 15
subroutine(fx_stage_sub) vec4 fx_15(vec2 vUV, sampler2D previous, sampler2D feedback, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3, vec3 m0) subroutine(fx_stage_sub) vec4 fx_15(vec2 vUV, sampler2D previous, sampler2D feedback, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3, vec3 m0)
{ {
return fx_4(vUV, previous, feedback, seed, b1, f1, b2, f2, b3, f3, m0); return fx_2(vUV, previous, feedback, seed, b1, f1, b2, f2, b3, f3, m0);
// start // start
vec2 uv0 = vUV.st; vec2 uv0 = vUV.st;
+11 -3
View File
@@ -175,6 +175,10 @@ subroutine(src_stage_sub) vec4 src_5(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3
// SRC 6 : video in 1 + thru // SRC 6 : video in 1 + thru
subroutine(src_stage_sub) vec4 src_6(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3) subroutine(src_stage_sub) vec4 src_6(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3)
{ {
if (iDemo > 0) {
return src_2(vUV, seed, b1, f1, b2, f2, b3, f3);
}
return src_thru(vUV, iTex3, seed, b1, f1, b2, f2, b3, f3); return src_thru(vUV, iTex3, seed, b1, f1, b2, f2, b3, f3);
} }
@@ -335,6 +339,10 @@ subroutine(src_stage_sub) vec4 src_10(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3
// SRC 11 : video in 2 + thru // SRC 11 : video in 2 + thru
subroutine(src_stage_sub) vec4 src_11(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3) subroutine(src_stage_sub) vec4 src_11(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3)
{ {
if (iDemo > 0) {
return src_3(vUV, seed, b1, f1, b2, f2, b3, f3);
}
return src_thru(vUV, iTex4, seed, b1, f1, b2, f2, b3, f3); return src_thru(vUV, iTex4, seed, b1, f1, b2, f2, b3, f3);
} }
@@ -384,7 +392,7 @@ subroutine(src_stage_sub) vec4 src_12(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3
// TODO SRC 13 // TODO SRC 13
subroutine(src_stage_sub) vec4 src_13(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3) subroutine(src_stage_sub) vec4 src_13(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3)
{ {
return src_2(vUV, seed, b1, f1, b2, f2, b3, f3); return src_7(vUV, seed, b1, f1, b2, f2, b3, f3);
// start // start
vec2 uv0 = vUV.st; vec2 uv0 = vUV.st;
@@ -401,7 +409,7 @@ subroutine(src_stage_sub) vec4 src_13(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3
// TODO SRC 14 // TODO SRC 14
subroutine(src_stage_sub) vec4 src_14(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3) subroutine(src_stage_sub) vec4 src_14(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3)
{ {
return src_3(vUV, seed, b1, f1, b2, f2, b3, f3); return src_8(vUV, seed, b1, f1, b2, f2, b3, f3);
// start // start
vec2 uv0 = vUV.st; vec2 uv0 = vUV.st;
@@ -418,7 +426,7 @@ subroutine(src_stage_sub) vec4 src_14(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3
// TODO SRC 15 // TODO SRC 15
subroutine(src_stage_sub) vec4 src_15(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3) subroutine(src_stage_sub) vec4 src_15(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3 b2, vec2 f2, vec3 b3, vec2 f3)
{ {
return src_4(vUV, seed, b1, f1, b2, f2, b3, f3); return src_9(vUV, seed, b1, f1, b2, f2, b3, f3);
// start // start
vec2 uv0 = vUV.st; vec2 uv0 = vUV.st;