From 7aafb514bf66316d706ef611e80eddc8f77ae688 Mon Sep 17 00:00:00 2001 From: NemesisMate Date: Sun, 7 May 2017 14:09:12 +0100 Subject: [PATCH] Fixed #652 The issue was due to the texture blending with the object material. By default the material is gray (hence, a gray border). If the material color in blender is set to another color this is being the artifact's color. It can bee seen where the alpha in the texture isn't totally 0 or 1. The current implementation weren't taking in account the material transparency when blending, so the fix is basically to use it just like blender does: --- .../blender/textures/blending/TextureBlenderAWT.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/textures/blending/TextureBlenderAWT.java b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/textures/blending/TextureBlenderAWT.java index 1d7bf2146..db4acc68f 100644 --- a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/textures/blending/TextureBlenderAWT.java +++ b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/textures/blending/TextureBlenderAWT.java @@ -163,8 +163,16 @@ public class TextureBlenderAWT extends AbstractTextureBlender { * the blender context */ protected void blendPixel(float[] result, float[] materialColor, float[] pixelColor, BlenderContext blenderContext) { + // We calculate first the importance of the texture (colFactor * texAlphaValue) float blendFactor = this.blendFactor * pixelColor[3]; - float oneMinusFactor = 1.0f - blendFactor, col; + // Then, we get the object material factor ((1 - texture importance) * matAlphaValue) + float oneMinusFactor = (1f - blendFactor) * materialColor[3]; + // Finally, we can get the final blendFactor, which is 1 - the material factor. + blendFactor = 1f - oneMinusFactor; + + // --- Compact method --- + // float blendFactor = this.blendFactor * (1f - ((1f - pixelColor[3]) * materialColor[3])); + // float oneMinusFactor = 1f - blendFactor; switch (blendType) { case MTEX_BLEND: