aboutsummaryrefslogtreecommitdiff
path: root/tools/lanczos-gen.pl
diff options
context:
space:
mode:
authorlizzie <lizzie@eden-emu.dev>2025-10-20 14:25:03 +0200
committercrueter <crueter@eden-emu.dev>2025-10-20 14:25:03 +0200
commit226160f6398789087ad6f01d660608c701b3cce8 (patch)
tree8e3609c5fb4a6107845565647dac9738699be023 /tools/lanczos-gen.pl
parent0eeeee515e8c8c533b8514b2bbaf7f2d17e93341 (diff)
[docs, tools] Add 3rd party links, debug and testing guidelines; add extra tools for maintaining strings, rewrite lanczos generator in perl (#2749)
RenderDoc checklist inspired by writeup of Charles G. of LunarG Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2749 Reviewed-by: MaranBr <maranbr@eden-emu.dev> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
Diffstat (limited to 'tools/lanczos-gen.pl')
-rw-r--r--tools/lanczos-gen.pl40
1 files changed, 40 insertions, 0 deletions
diff --git a/tools/lanczos-gen.pl b/tools/lanczos-gen.pl
new file mode 100644
index 0000000000..2e26c8c6b9
--- /dev/null
+++ b/tools/lanczos-gen.pl
@@ -0,0 +1,40 @@
+#!/usr/bin/perl
+# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
+# SPDX-License-Identifier: GPL-3.0-or-later
+use strict;
+use warnings;
+sub generate_lanczos {
+ my $pi = 3.14159265358979;
+ sub sinc {
+ if ($_[0] eq 0.0) {
+ return 1.0;
+ } else {
+ return sin($pi * $_[0]) / ($pi * $_[0]);
+ }
+ }
+ sub lanczos {
+ my $d = sqrt($_[0] * $_[0] + $_[1] * $_[1]);
+ return sinc($d) / sinc($d / $_[2]);
+ }
+ my $r = 3.0; #radius (1 = 3 steps)
+ my $k_size = ($r * 2.0 + 1.0) * ($r * 2.0 + 1.0);
+ my $w_sum = \0.0;
+ my $factor = 1.0 / ($r + 1.0);
+ #kernel size = (r * 2 + 1) ^ 2
+ printf("const float w_kernel[%i] = float[] (\n ", $k_size);
+ for (my $x = -$r; $x <= $r; $x++) {
+ for (my $y = -$r; $y <= $r; $y++) {
+ my $w = lanczos($x, $y, $r);
+ printf("%f, ", $w);
+ $w_sum += $w;
+ }
+ }
+ printf("\n);\nconst vec2 w_pos[%i] = vec[](\n ", $k_size);
+ for (my $x = -$r; $x <= $r; $x++) {
+ for (my $y = -$r; $y <= $r; $y++) {
+ printf("vec2(%f, %f), ", $x * $factor, $y * $factor);
+ }
+ }
+ printf("\n);\nconst float w_sum = %f;\n", $w_sum);
+}
+generate_lanczos;