Browse Source

Improve blendspan criteria stuff.

This allows blend textures to be used for mesh transparency without
having to fiddle around too much. It was also a stab at fixing some
regressions in the MOUL engine around decals, but that bit failed,
sadly.
pull/172/head
Adam Johnson 5 years ago
parent
commit
dd467547d2
Signed by: Hoikas
GPG Key ID: 0B6515D6FF6F271E
  1. 9
      korman/exporter/material.py
  2. 29
      korman/exporter/mesh.py
  3. 14
      korman/properties/modifiers/base.py
  4. 4
      korman/properties/modifiers/render.py

9
korman/exporter/material.py

@ -429,8 +429,6 @@ class MaterialConverter:
if canStencil:
hsgmat.compFlags |= hsGMaterial.kCompNeedsBlendChannel
state.blendFlags |= hsGMatState.kBlendAlpha | hsGMatState.kBlendAlphaMult | hsGMatState.kBlendNoTexColor
if slot.texture.type == "BLEND":
state.clampFlags |= hsGMatState.kClampTexture
state.ZFlags |= hsGMatState.kZNoZWrite
layer.ambient = hsColorRGBA(1.0, 1.0, 1.0, 1.0)
elif blend_flags:
@ -453,6 +451,8 @@ class MaterialConverter:
layer.specularPower = 1.0
texture = slot.texture
if texture.type == "BLEND":
hsgmat.compFlags |= hsGMaterial.kCompNeedsBlendChannel
# Apply custom layer properties
wantBumpmap = bm is not None and slot.use_map_normal
@ -788,6 +788,11 @@ class MaterialConverter:
pass
def _export_texture_type_blend(self, bo, layer, slot):
state = layer.state
state.blendFlags |= hsGMatState.kBlendAlpha | hsGMatState.kBlendAlphaMult | hsGMatState.kBlendNoTexColor
state.clampFlags |= hsGMatState.kClampTexture
state.ZFlags |= hsGMatState.kZNoZWrite
# This has been separated out because other things may need alpha blend textures.
texture = slot.texture
self.export_alpha_blend(texture.progression, texture.use_flip_axis, layer)

29
korman/exporter/mesh.py

@ -39,11 +39,13 @@ class _RenderLevel:
_MAJOR_SHIFT = 28
_MINOR_MASK = ((1 << _MAJOR_SHIFT) - 1)
def __init__(self, bo, hsgmat, pass_index, blendSpan=False):
def __init__(self, bo, hsgmat, pass_index, blend_span=False):
self.level = 0
if blendSpan:
self.major = self.MAJOR_DEFAULT
if pass_index > 0:
self.major = self.MAJOR_FRAMEBUF
self.minor = pass_index * 4
else:
self.major = self.MAJOR_BLEND if blend_span else self.MAJOR_OPAQUE
# We use the blender material's pass index (which we stashed in the hsGMaterial) to increment
# the render pass, just like it says...
@ -74,11 +76,10 @@ class _DrawableCriteria:
self.criteria = 0
if self.blend_span:
for mod in bo.plasma_modifiers.modifiers:
if mod.requires_face_sort:
self.criteria |= plDrawable.kCritSortFaces
if mod.requires_span_sort:
self.criteria |= plDrawable.kCritSortSpans
if self._face_sort_allowed(bo):
self.criteria |= plDrawable.kCritSortFaces
if self._span_sort_allowed(bo):
self.criteria |= plDrawable.kCritSortSpans
self.render_level = _RenderLevel(bo, hsgmat, pass_index, self.blend_span)
def __eq__(self, other):
@ -92,6 +93,16 @@ class _DrawableCriteria:
def __hash__(self):
return hash(self.render_level) ^ hash(self.blend_span) ^ hash(self.criteria)
def _face_sort_allowed(self, bo):
# For now, only test the modifiers
# This will need to be tweaked further for GUIs...
return not any((i.no_face_sort for i in bo.plasma_modifiers.modifiers))
def _span_sort_allowed(self, bo):
# For now, only test the modifiers
# This will need to be tweaked further for GUIs...
return not any((i.no_face_sort for i in bo.plasma_modifiers.modifiers))
@property
def span_type(self):
if self.blend_span:

14
korman/properties/modifiers/base.py

@ -37,19 +37,19 @@ class PlasmaModifierProperties(bpy.types.PropertyGroup):
return self.id_data.name
@property
def requires_actor(self):
"""Indicates if this modifier requires the object to be a movable actor"""
def no_face_sort(self):
"""Indicates that the geometry's faces should never be sorted by the engine"""
return False
@property
def requires_face_sort(self):
"""Indicates that the geometry's faces must be sorted by the engine"""
def no_span_sort(self):
"""Indicates that the geometry's Spans should never be sorted with those from other
Drawables that will render in the same pass"""
return False
@property
def requires_span_sort(self):
"""Indicates that the geometry's Spans must be sorted with those from other Drawables that
will render in the same pass"""
def requires_actor(self):
"""Indicates if this modifier requires the object to be a movable actor"""
return False
# Guess what?

4
korman/properties/modifiers/render.py

@ -114,10 +114,6 @@ class PlasmaFadeMod(PlasmaModifierProperties):
mod.farOpaq = self.far_opaq
mod.farTrans = self.far_trans
@property
def requires_span_sort(self):
return True
class PlasmaFollowMod(idprops.IDPropObjectMixin, PlasmaModifierProperties):
pl_id = "followmod"

Loading…
Cancel
Save