From d80c6a5ccddd16b97aef6e10eb0e9f0f28c03c4f Mon Sep 17 00:00:00 2001 From: Jennifer Taylor Date: Mon, 9 Aug 2021 20:20:26 +0000 Subject: [PATCH] No longer take "blank pixels" outside of the screen into consideration for rendering SSAA. --- bemani/format/afp/blend/blend.py | 16 +++++++++++++++- bemani/format/afp/blend/blendcppimpl.cxx | 13 +++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/bemani/format/afp/blend/blend.py b/bemani/format/afp/blend/blend.py index 52b9210..b7f044c 100644 --- a/bemani/format/afp/blend/blend.py +++ b/bemani/format/afp/blend/blend.py @@ -199,6 +199,7 @@ def pixel_renderer( imgx: int, imgy: int, imgwidth: int, + imgheight: int, texwidth: int, texheight: int, xscale: float, @@ -299,7 +300,12 @@ def pixel_renderer( else: for addy in ypoints: for addx in xpoints: - texloc = callback(Point(imgx + addx, imgy + addy)) + xloc = imgx + addx + yloc = imgy + addy + if xloc < 0.0 or yloc < 0.0 or xloc >= imgwidth or yloc >= imgheight: + continue + + texloc = callback(Point(xloc, yloc)) denom += 1 if texloc is None: @@ -367,6 +373,7 @@ def affine_line_renderer( minx: int, maxx: int, imgwidth: int, + imgheight: int, texwidth: int, texheight: int, inverse: Matrix, @@ -394,6 +401,7 @@ def affine_line_renderer( imgx, imgy, imgwidth, + imgheight, texwidth, texheight, 1.0 / inverse.xscale, @@ -479,6 +487,7 @@ def affine_composite( imgx, imgy, imgwidth, + imgheight, texwidth, texheight, 1.0 / inverse.xscale, @@ -526,6 +535,7 @@ def affine_composite( minx, maxx, imgwidth, + imgheight, texwidth, texheight, inverse, @@ -576,6 +586,7 @@ def perspective_line_renderer( minx: int, maxx: int, imgwidth: int, + imgheight: int, texwidth: int, texheight: int, xscale: float, @@ -613,6 +624,7 @@ def perspective_line_renderer( imgx, imgy, imgwidth, + imgheight, texwidth, texheight, xscale, @@ -698,6 +710,7 @@ def perspective_composite( imgx, imgy, imgwidth, + imgheight, texwidth, texheight, transform.xscale, @@ -745,6 +758,7 @@ def perspective_composite( minx, maxx, imgwidth, + imgheight, texwidth, texheight, transform.xscale, diff --git a/bemani/format/afp/blend/blendcppimpl.cxx b/bemani/format/afp/blend/blendcppimpl.cxx index 19c06dd..d31541b 100644 --- a/bemani/format/afp/blend/blendcppimpl.cxx +++ b/bemani/format/afp/blend/blendcppimpl.cxx @@ -67,6 +67,7 @@ extern "C" intcolor_t *imgdata; unsigned char *maskdata; unsigned int imgwidth; + unsigned int imgheight; unsigned int minx; unsigned int maxx; unsigned int miny; @@ -393,14 +394,20 @@ extern "C" int aax = -1; int aay = -1; + float xloc = (float)imgx + addx; + float yloc = (float)imgy + addy; + if (xloc < 0.0 || yloc < 0.0 || xloc >= (float)work->imgwidth || yloc >= (float)work->imgheight) { + continue; + } + if (work->use_perspective) { - point_t texloc = work->inverse.multiply_point((point_t){(float)imgx + addx, (float)imgy + addy}); + point_t texloc = work->inverse.multiply_point((point_t){xloc, yloc}); if (texloc.z > 0.0) { aax = texloc.x / texloc.z; aay = texloc.y / texloc.z; } } else { - point_t texloc = work->inverse.multiply_point((point_t){(float)imgx + addx, (float)imgy + addy}); + point_t texloc = work->inverse.multiply_point((point_t){xloc, yloc}); aax = texloc.x; aay = texloc.y; } @@ -530,6 +537,7 @@ extern "C" work.imgdata = imgdata; work.maskdata = maskbytes; work.imgwidth = imgwidth; + work.imgheight = imgheight; work.minx = minx; work.maxx = maxx; work.miny = miny; @@ -576,6 +584,7 @@ extern "C" work->imgdata = imgdata; work->maskdata = maskbytes; work->imgwidth = imgwidth; + work->imgheight = imgheight; work->minx = minx; work->maxx = maxx; work->miny = imgy;