소스 검색

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:
NemesisMate 8 년 전
부모
커밋
7aafb514bf
1개의 변경된 파일9개의 추가작업 그리고 1개의 파일을 삭제
  1. 9 1
      jme3-blender/src/main/java/com/jme3/scene/plugins/blender/textures/blending/TextureBlenderAWT.java

+ 9 - 1
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: