Skip to content

Commit

Permalink
ngon-fill: Fix incorrect texturing in ortho mapping mode
Browse files Browse the repository at this point in the history
  • Loading branch information
leikareipa committed Jun 22, 2020
1 parent 5080b05 commit c1251d8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
9 changes: 6 additions & 3 deletions distributable/rngon.cat.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// WHAT: Concatenated JavaScript source files
// PROGRAM: Retro n-gon renderer
// VERSION: beta live (22 June 2020 23:09:43 UTC)
// VERSION: beta live (22 June 2020 23:43:46 UTC)
// AUTHOR: Tarpeeksi Hyvae Soft and others
// LINK: https://www.github.com/leikareipa/retro-ngon/
// FILES:
Expand Down Expand Up @@ -1092,7 +1092,7 @@ Rngon.ngon_filler = function(auxiliaryBuffers = [])
else if (ngon.vertices.length === 2)
{
Rngon.line_draw(ngon.vertices[0], ngon.vertices[1], material.color);

continue;
}

Expand Down Expand Up @@ -1431,7 +1431,7 @@ Rngon.ngon_filler = function(auxiliaryBuffers = [])
v = (ngonY * (texture.height / ngonHeight));

// The texture image is flipped, so we need to flip V as well.
v = (texture.height - v - 1);
v = (texture.height - v);

break;
}
Expand All @@ -1440,6 +1440,9 @@ Rngon.ngon_filler = function(auxiliaryBuffers = [])

const texel = texture.pixels[(~~u) + (~~v) * texture.width];

// Make sure we gracefully exit if accessing the texture out of bounds.
if (!texel) continue;

// Alpha-test the texture. If the texel isn't fully opaque, skip it.
if (texel.alpha !== 255) continue;

Expand Down
7 changes: 5 additions & 2 deletions js/retro-ngon/ngon-fill.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Rngon.ngon_filler = function(auxiliaryBuffers = [])
else if (ngon.vertices.length === 2)
{
Rngon.line_draw(ngon.vertices[0], ngon.vertices[1], material.color);

continue;
}

Expand Down Expand Up @@ -462,7 +462,7 @@ Rngon.ngon_filler = function(auxiliaryBuffers = [])
v = (ngonY * (texture.height / ngonHeight));

// The texture image is flipped, so we need to flip V as well.
v = (texture.height - v - 1);
v = (texture.height - v);

break;
}
Expand All @@ -471,6 +471,9 @@ Rngon.ngon_filler = function(auxiliaryBuffers = [])

const texel = texture.pixels[(~~u) + (~~v) * texture.width];

// Make sure we gracefully exit if accessing the texture out of bounds.
if (!texel) continue;

// Alpha-test the texture. If the texel isn't fully opaque, skip it.
if (texel.alpha !== 255) continue;

Expand Down
Binary file modified tests/integration/render-output/reference-2ikgd535e376.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c1251d8

Please sign in to comment.