diff --git a/public/bof2-snes.png b/public/bof2-snes.png new file mode 100644 index 0000000..62cf3cf Binary files /dev/null and b/public/bof2-snes.png differ diff --git a/src/pages/main/main.ts b/src/pages/main/main.ts index ef04f52..6306cde 100644 --- a/src/pages/main/main.ts +++ b/src/pages/main/main.ts @@ -27,6 +27,7 @@ const images = [ 'hqx-patterns.bmp', 'mario-nes.png', 'pokemon-yellow-sgb.png', + 'bof2-snes.png', 'advance-wars-gba.png', 'ffvii-psx.png', 'medievil-resurrection-psp.png', diff --git a/src/shaders/cut2/cut2_pass_0.frag.glsl b/src/shaders/cut2/cut2_pass_0.frag.glsl index 504acff..a49045a 100644 --- a/src/shaders/cut2/cut2_pass_0.frag.glsl +++ b/src/shaders/cut2/cut2_pass_0.frag.glsl @@ -62,7 +62,7 @@ lowp float quickPackFloats2(lowp vec2 values) { return dot(floor(values * vec2(12.0) + vec2(0.5)), vec2(0.0625, 0.00390625)); } -lowp int findPattern(lowp vec4 values, lowp vec2 diagonals) { +lowp int findPattern(lowp vec4 values, lowp vec2 saddleAdjustments) { lowp vec4 edgesDifferences = abs(values.xxyz - values.yzww); lowp vec4 patternContrasts = vec4( @@ -72,13 +72,16 @@ lowp int findPattern(lowp vec4 values, lowp vec2 diagonals) { max(edgesDifferences.x + edgesDifferences.y, edgesDifferences.z + edgesDifferences.w) ); - patternContrasts.zw += 0.125 * clamp(diagonals.yx - diagonals.xy, -2.0, +0.125); + patternContrasts.zw += clamp((saddleAdjustments.xy - saddleAdjustments.yx) * 0.125, vec2(-0.20), vec2(0.05)); + + lowp float maxContrast = max( + max(patternContrasts.x, patternContrasts.y), + max(patternContrasts.z, patternContrasts.w) + ); - lowp float maxContrast = max(max(patternContrasts.x, patternContrasts.y), max(patternContrasts.z, patternContrasts.w)); bvec4 isMax = greaterThanEqual(patternContrasts, vec4(maxContrast)); - bool isSaddle = all(isMax); - if (maxContrast < EDGE_MIN_VALUE || isSaddle) { + if (maxContrast < EDGE_MIN_VALUE) { return 0; } else if (isMax.x) { return 1; @@ -168,12 +171,12 @@ void main() { softEdgeWeight(l01, l05, l09, l13) ); - edges = clamp(edges + 2.0 * softEdges, min(edges, softEdges), max(edges, softEdges)); + edges = clamp(edges + softEdges, min(edges, softEdges), max(edges, softEdges)); #endif lowp vec2 diagonals = vec2( - (abs(l06 - l01) + abs(l11 - l06) + abs(l14 - l09) + abs(l09 - l04)), - (abs(l08 - l05) + abs(l05 - l02) + abs(l13 - l10) + abs(l10 - l07)) + abs(l08 - l05) + abs(l13 - l10) + abs(l10 - l07) + abs(l05 - l02), + abs(l06 - l01) + abs(l09 - l04) + abs(l11 - l06) + abs(l14 - l09) ); pattern = findPattern(vec4(l05, l06, l09, l10), diagonals); diff --git a/src/shaders/cut3/cut3_pass_0.frag.glsl b/src/shaders/cut3/cut3_pass_0.frag.glsl index 15e28e2..73d0f54 100644 --- a/src/shaders/cut3/cut3_pass_0.frag.glsl +++ b/src/shaders/cut3/cut3_pass_0.frag.glsl @@ -62,7 +62,7 @@ lowp float quickPackFloats2(lowp vec2 values) { return dot(floor(values * vec2(12.0) + vec2(0.5)), vec2(0.0625, 0.00390625)); } -lowp int findPattern(lowp vec4 values, lowp vec2 diagonals) { +lowp int findPattern(lowp vec4 values, lowp vec2 saddleAdjustments) { lowp vec4 edgesDifferences = abs(values.xxyz - values.yzww); lowp vec4 patternContrasts = vec4( @@ -72,13 +72,16 @@ lowp int findPattern(lowp vec4 values, lowp vec2 diagonals) { max(edgesDifferences.x + edgesDifferences.y, edgesDifferences.z + edgesDifferences.w) ); - patternContrasts.zw += 0.125 * clamp(diagonals.yx - diagonals.xy, -2.0, +0.125); + patternContrasts.zw += clamp((saddleAdjustments.xy - saddleAdjustments.yx) * 0.125, vec2(-0.20), vec2(0.05)); + + lowp float maxContrast = max( + max(patternContrasts.x, patternContrasts.y), + max(patternContrasts.z, patternContrasts.w) + ); - lowp float maxContrast = max(max(patternContrasts.x, patternContrasts.y), max(patternContrasts.z, patternContrasts.w)); bvec4 isMax = greaterThanEqual(patternContrasts, vec4(maxContrast)); - bool isSaddle = all(isMax); - if (maxContrast < EDGE_MIN_VALUE || isSaddle) { + if (maxContrast < EDGE_MIN_VALUE) { return 0; } else if (isMax.x) { return 1; @@ -128,8 +131,8 @@ void main() { lowp float l14 = luma(t14); lowp vec2 diagonals = vec2( - (abs(l06 - l01) + abs(l11 - l06) + abs(l14 - l09) + abs(l09 - l04)), - (abs(l08 - l05) + abs(l05 - l02) + abs(l13 - l10) + abs(l10 - l07)) + abs(l08 - l05) + abs(l13 - l10) + abs(l10 - l07) + abs(l05 - l02), + abs(l06 - l01) + abs(l09 - l04) + abs(l11 - l06) + abs(l14 - l09) ); lowp int pattern = findPattern(vec4(l05, l06, l09, l10), diagonals); diff --git a/src/shaders/cut3/cut3_pass_1.frag.glsl b/src/shaders/cut3/cut3_pass_1.frag.glsl index 7a8875e..8d8f88a 100644 --- a/src/shaders/cut3/cut3_pass_1.frag.glsl +++ b/src/shaders/cut3/cut3_pass_1.frag.glsl @@ -178,7 +178,7 @@ void main() { quickUnpackFloats2(previousPassPixel.z + 0.001953125) - vec2(0.5) ); - edges = clamp(edges + 2.0 * softEdges, min(edges, softEdges), max(edges, softEdges)); + edges = clamp(edges + softEdges, min(edges, softEdges), max(edges, softEdges)); #endif lowp int originalPattern = pattern >= 0 ? pattern : -pattern;