diff --git a/src/main/java/net/raphimc/softwarerenderer/rasterizer/TriangleRasterizer.java b/src/main/java/net/raphimc/softwarerenderer/rasterizer/TriangleRasterizer.java index fe43ead..aa081ce 100644 --- a/src/main/java/net/raphimc/softwarerenderer/rasterizer/TriangleRasterizer.java +++ b/src/main/java/net/raphimc/softwarerenderer/rasterizer/TriangleRasterizer.java @@ -113,7 +113,6 @@ public void rasterize(final ImageBuffer colorBuffer, final float @Nullable [] de if (sum == 0) { continue; } - final double pSum = (bc1 / w1) + (bc2 / w2) + (bc3 / w3); final int rasterIndex = y * rasterWidth + x; if (depthBuffer != null) { @@ -124,6 +123,8 @@ public void rasterize(final ImageBuffer colorBuffer, final float @Nullable [] de depthBuffer[rasterIndex] = z; } + final double pSum = (bc1 / w1) + (bc2 / w2) + (bc3 / w3); + final int a = (int) ((bc1 * a1 + bc2 * a2 + bc3 * a3) / sum); final int r = (int) ((bc1 * r1 + bc2 * r2 + bc3 * r3) / sum); final int g = (int) ((bc1 * g1 + bc2 * g2 + bc3 * g3) / sum); @@ -140,7 +141,9 @@ public void rasterize(final ImageBuffer colorBuffer, final float @Nullable [] de color = ColorMixer.mix(color, texColor); } - colorRaster[rasterIndex] = ColorMixer.blend(colorRaster[rasterIndex], color); + if ((color & 0xFF000000) != 0) { + colorRaster[rasterIndex] = ColorMixer.blend(colorRaster[rasterIndex], color); + } } } }