From 5c4f167a296976c2aab6e8982d010fffbd26a85e Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sun, 24 Jan 2016 22:02:49 -0500 Subject: [PATCH 1/2] Port better alpha blending from PyPRP --- korman/exporter/material.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/korman/exporter/material.py b/korman/exporter/material.py index b4ea99b..59215a3 100644 --- a/korman/exporter/material.py +++ b/korman/exporter/material.py @@ -195,7 +195,7 @@ class MaterialConverter: else: # Standard layer flags ahoy if slot.blend_type == "ADD": - state.blendFlags |= hsGMatState.kBlendAdd + state.blendFlags |= hsGMatState.kBlendAddColorTimesAlpha elif slot.blend_type == "MULTIPLY": state.blendFlags |= hsGMatState.kBlendMult @@ -433,6 +433,10 @@ class MaterialConverter: # mutually exclusive blend flags if texture.use_alpha and has_alpha: state.blendFlags |= hsGMatState.kBlendAlpha + if slot.blend_type == "ADD": + state.blendFlags |= hsGMatState.kBlendAlphaAdd + elif slot.blend_type == "MULTIPLY": + state.blendFlags |= hsGMatState.kBlendAlphaMult if texture.invert_alpha and has_alpha: state.blendFlags |= hsGMatState.kBlendInvertAlpha From 9cbb9b791a864efcd53841185f3be66aeb51e239 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sun, 24 Jan 2016 22:11:33 -0500 Subject: [PATCH 2/2] kBlendAlpha is illegal with kBlendAlphaMult and kBlendAlphaAdd --- korman/exporter/material.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/korman/exporter/material.py b/korman/exporter/material.py index 59215a3..bb8ba84 100644 --- a/korman/exporter/material.py +++ b/korman/exporter/material.py @@ -432,11 +432,12 @@ class MaterialConverter: if not slot.use_stencil: # mutually exclusive blend flags if texture.use_alpha and has_alpha: - state.blendFlags |= hsGMatState.kBlendAlpha if slot.blend_type == "ADD": state.blendFlags |= hsGMatState.kBlendAlphaAdd elif slot.blend_type == "MULTIPLY": state.blendFlags |= hsGMatState.kBlendAlphaMult + else: + state.blendFlags |= hsGMatState.kBlendAlpha if texture.invert_alpha and has_alpha: state.blendFlags |= hsGMatState.kBlendInvertAlpha