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
+16
View File
@@ -273,6 +273,22 @@ vec4 reframe_b(sampler2D tex, vec2 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
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;
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;
uv2 = round(uv2 * k1) / k1;
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);
}
// 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)
{
return fx_2(vUV, previous, feedback, seed, b1, f1, b2, f2, b3, f3, m0);
// start
vec2 uv0 = vUV.st;
@@ -470,10 +469,20 @@ subroutine(fx_stage_sub) vec4 fx_13(vec2 vUV, sampler2D previous, sampler2D feed
// 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
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);
}
@@ -481,7 +490,7 @@ subroutine(fx_stage_sub) vec4 fx_13(vec2 vUV, sampler2D previous, sampler2D feed
// 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)
{
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
vec2 uv0 = vUV.st;
@@ -501,7 +510,7 @@ subroutine(fx_stage_sub) vec4 fx_14(vec2 vUV, sampler2D previous, sampler2D feed
// 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)
{
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
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
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);
}
@@ -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
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);
}
@@ -384,7 +392,7 @@ subroutine(src_stage_sub) vec4 src_12(vec2 vUV, int seed, vec3 b1, vec2 f1, vec3
// 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)
{
return src_2(vUV, seed, b1, f1, b2, f2, b3, f3);
return src_7(vUV, seed, b1, f1, b2, f2, b3, f3);
// start
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
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
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
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
vec2 uv0 = vUV.st;