2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 13:44:56 +00:00

Macros for shader extensions to determine blend factors

This commit is contained in:
Jack Andersen
2018-10-20 18:13:25 -10:00
parent 808e46a4ef
commit a230eeb3b1
10 changed files with 77 additions and 9 deletions

View File

@@ -31,6 +31,11 @@ def write_out_material(writebuf, mat, mesh_obj):
transparent = True
writebuf(struct.pack('b', int(transparent)))
# If this returns true, the material geometry will be split into contiguous faces
def should_split_into_contiguous_faces(mat):
return mat.game_settings.alpha_blend != 'OPAQUE' and \
'retro_depth_sort' in mat and mat['retro_depth_sort']
# Takes a Blender 'Mesh' object (not the datablock)
# and performs a one-shot conversion process to HMDL
def cook(writebuf, mesh_obj, output_mode, max_skin_banks, use_luv=False):
@@ -125,7 +130,7 @@ def cook(writebuf, mesh_obj, output_mode, max_skin_banks, use_luv=False):
# Generate material meshes (if opaque)
for mat_idx in sorted_material_idxs:
mat = mesh_obj.data.materials[mat_idx]
if mat.game_settings.alpha_blend != 'OPAQUE':
if should_split_into_contiguous_faces(mat):
continue
mat_faces_rem = []
for face in bm_master.faces:
@@ -161,7 +166,7 @@ def cook(writebuf, mesh_obj, output_mode, max_skin_banks, use_luv=False):
# Generate island meshes (if transparent)
for mat_idx in sorted_material_idxs:
mat = mesh_obj.data.materials[mat_idx]
if mat.game_settings.alpha_blend == 'OPAQUE':
if not should_split_into_contiguous_faces(mat):
continue
mat_faces_rem = []
for face in bm_master.faces: