Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into cleanup_f3d_parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Dragorn421 committed Jan 7, 2024
2 parents a77f288 + cad6560 commit 658d94a
Show file tree
Hide file tree
Showing 29 changed files with 1,259 additions and 1,280 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/black-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# https://black.readthedocs.io/en/stable/integrations/github_actions.html

name: Black Lint

on: [push, pull_request]

jobs:
black-lint:
permissions: {} # Remove all permissions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable
8 changes: 6 additions & 2 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
# info about add on
bl_info = {
"name": "Fast64",
"version": (2, 1, 0),
"version": (2, 2, 0),
"author": "kurethedead",
"location": "3DView",
"description": "Plugin for exporting F3D display lists and other game data related to Nintendo 64 games.",
Expand Down Expand Up @@ -166,7 +166,11 @@ def draw(self, context):
col.prop(context.scene, "generateF3DNodeGraph", text="Generate F3D Node Graph For Materials")
col.prop(context.scene, "exportInlineF3D", text="Bleed and Inline Material Exports")
if context.scene.exportInlineF3D:
multilineLabel(col.box(), "While inlining, all meshes will be restored to world default values.\n You can configure these values in the world properties tab.", icon="INFO")
multilineLabel(
col.box(),
"While inlining, all meshes will be restored to world default values.\n You can configure these values in the world properties tab.",
icon="INFO",
)
col.prop(context.scene, "decomp_compatible", invert_checkbox=True, text="Homebrew Compatibility")
col.prop(context.scene, "ignoreTextureRestrictions")
if context.scene.ignoreTextureRestrictions:
Expand Down
46 changes: 28 additions & 18 deletions fast64_internal/f3d/f3d_bleed.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@


class BleedGraphics:

# bleed_state "enums"
bleed_start = 1
bleed_in_progress = 2
Expand Down Expand Up @@ -126,18 +125,25 @@ def bleed_fModel(self, fModel: FModel, fMeshes: dict[FMesh]):

# clear the gfx lists so they don't export
def clear_gfx_lists(self, fModel: FModel):
for (fMaterial, texDimensions) in fModel.materials.values():
for fMaterial, texDimensions in fModel.materials.values():
fMaterial.material.tag |= GfxListTag.NoExport
if fMaterial.revert:
fMaterial.revert.tag |= GfxListTag.NoExport
for fMesh in fModel.meshes.values():
for tri_list in fMesh.triangleGroups:
tri_list.triList.tag |= GfxListTag.NoExport

def bleed_fmesh(self, fMesh: FMesh, last_mat: FMaterial, cmd_list: GfxList, fmodel_materials, default_render_mode: list[str] = None):
def bleed_fmesh(
self,
fMesh: FMesh,
last_mat: FMaterial,
cmd_list: GfxList,
fmodel_materials,
default_render_mode: list[str] = None,
):
if bled_mat := self.bled_gfx_lists.get(cmd_list, None):
return bled_mat

bleed_state = self.bleed_start
cur_fmat = None
reset_cmd_dict = dict()
Expand Down Expand Up @@ -169,15 +175,15 @@ def bleed_fmesh(self, fMesh: FMesh, last_mat: FMaterial, cmd_list: GfxList, fmod
bleed_gfx_lists = BleedGfxLists()
# set bleed state for cmd reverts
bleed_state = self.bleed_in_progress

last_mat = cur_fmat
self.on_bleed_end(last_mat, cmd_list, fmesh_static_cmds, reset_cmd_dict, default_render_mode)
return last_mat

def build_tmem_dict(self, cmd_list: GfxList):
im_buffer = None
tmem_dict = dict()
tile_dict = {i:0 for i in range(8)} # an assumption that hopefully never needs correction
tile_dict = {i: 0 for i in range(8)} # an assumption that hopefully never needs correction
for cmd in cmd_list.commands:
if type(cmd) == DPSetTextureImage:
im_buffer = cmd
Expand All @@ -188,7 +194,7 @@ def build_tmem_dict(self, cmd_list: GfxList):
tmem_dict[tile_dict[cmd.tile]] = im_buffer
continue
return tmem_dict

def bleed_textures(self, cur_fmat: FMaterial, last_mat: FMaterial, bleed_state: int):
if last_mat:
# bleed cmds if matching tile has duplicate cmds
Expand Down Expand Up @@ -220,7 +226,7 @@ def bleed_textures(self, cur_fmat: FMaterial, last_mat: FMaterial, bleed_state:
# now eval as normal conditionals
for j, cmd in enumerate(cur_fmat.texture_DL.commands):
if not cmd:
continue # some cmds are None from previous step
continue # some cmds are None from previous step
if self.bleed_individual_cmd(commands_bled, cmd, bleed_state):
if cmd in last_mat.texture_DL.commands:
commands_bled.commands[j] = None
Expand Down Expand Up @@ -252,9 +258,7 @@ def bleed_mat(self, cur_fmat: FMaterial, last_mat: FMaterial, bleed_state: int):
commands_bled.commands.remove(SPEndDisplayList())
return commands_bled.commands

def bleed_tri_group(
self, tri_list: GfxList, cur_fmat: fMaterial, bleed_state: int
):
def bleed_tri_group(self, tri_list: GfxList, cur_fmat: fMaterial, bleed_state: int):
# remove SPEndDisplayList from triGroup
while SPEndDisplayList() in tri_list.commands:
tri_list.commands.remove(SPEndDisplayList())
Expand All @@ -281,7 +285,9 @@ def bleed_cmd_list(self, target_cmd_list: GfxList, bleed_state: int):
return commands_bled

# Put triGroup bleed gfx in the FMesh.draw object
def inline_triGroup(self, tri_list: GfxList, bleed_gfx_lists: BleedGfxLists, cmd_list: GfxList, reset_cmd_dict: dict[GbiMacro]):
def inline_triGroup(
self, tri_list: GfxList, bleed_gfx_lists: BleedGfxLists, cmd_list: GfxList, reset_cmd_dict: dict[GbiMacro]
):
# add material
cmd_list.commands.extend(bleed_gfx_lists.bled_mats)
# add textures
Expand Down Expand Up @@ -329,7 +335,12 @@ def on_tri_group_bleed_end(self, triGroup: FTriGroup, last_mat: FMaterial, bleed
return

def on_bleed_end(
self, last_mat: FMaterial, cmd_list: GfxList, fmesh_static_cmds: list[GbiMacro], reset_cmd_dict: dict[GbiMacro], default_render_mode: list[str] = None
self,
last_mat: FMaterial,
cmd_list: GfxList,
fmesh_static_cmds: list[GbiMacro],
reset_cmd_dict: dict[GbiMacro],
default_render_mode: list[str] = None,
):
# revert certain cmds for extra safety
reset_cmds = self.create_reset_cmds(reset_cmd_dict, default_render_mode)
Expand All @@ -338,14 +349,13 @@ def on_bleed_end(
reset_cmds.remove(DPPipeSync)
reset_cmds.insert(0, DPPipeSync)
cmd_list.commands.extend(reset_cmds)
cmd_list.commands.extend(fmesh_static_cmds) # this is troublesome
cmd_list.commands.extend(fmesh_static_cmds) # this is troublesome
cmd_list.commands.append(SPEndDisplayList())
self.bled_gfx_lists[cmd_list] = last_mat

def create_reset_cmds(self, reset_cmd_dict: dict[GbiMacro], default_render_mode: list[str]):
reset_cmds = []
for cmd_type, cmd_use in reset_cmd_dict.items():

if cmd_type == DPPipeSync:
reset_cmds.append(DPPipeSync())

Expand Down Expand Up @@ -493,7 +503,7 @@ def bleed_between_tris(self, cmd_list: GfxList, cmd: GbiMacro, bleed_state: int,
class BleedGfxLists:
bled_mats: GfxList = field(default_factory=list)
bled_tex: GfxList = field(default_factory=list)

@property
def reset_command_dict(self):
return {
Expand All @@ -514,7 +524,7 @@ def add_reset_cmd(self, cmd: GbiMacro, reset_cmd_dict: dict[GbiMacro]):
# separate other mode H and othermode L
if type(cmd) == SPSetOtherMode:
reset_cmd_dict[cmd.cmd] = cmd

if type(cmd) in reset_cmd_list:
reset_cmd_dict[type(cmd)] = cmd

Expand All @@ -533,4 +543,4 @@ def find_material_from_jump_cmd(
return bpy_material, fmaterial
elif fmaterial.material == dl_jump.displayList:
return bpy_material, fmaterial
return None, None
return None, None
129 changes: 0 additions & 129 deletions fast64_internal/f3d/f3d_constants.py

This file was deleted.

30 changes: 25 additions & 5 deletions fast64_internal/f3d/f3d_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,18 +392,38 @@
]

enumCelThreshMode = [
("Lighter", "Lighter", "This cel level is drawn when the lighting level per-pixel is LIGHTER than (>=) the threshold"),
(
"Lighter",
"Lighter",
"This cel level is drawn when the lighting level per-pixel is LIGHTER than (>=) the threshold",
),
("Darker", "Darker", "This cel level is drawn when the lighting level per-pixel is DARKER than (<) the threshold"),
]

enumCelTintPipeline = [
("CC", "CC (tint in Prim Color)", "Cel shading puts tint color in Prim Color and tint level in Prim Alpha. Set up CC color to LERP between source color and tint color based on tint level, or multiply source color by tint color. Source may be Tex 0 or Env Color"),
("Blender", "Blender (tint in Fog Color)", "Cel shading puts tint color in Fog Color and tint level in Fog Alpha. Set up blender to LERP between CC output and tint color based on tint level. Then set CC to Tex 0 * shade color (vertex colors)"),
(
"CC",
"CC (tint in Prim Color)",
"Cel shading puts tint color in Prim Color and tint level in Prim Alpha. Set up CC color to LERP between source color and tint color based on tint level, or multiply source color by tint color. Source may be Tex 0 or Env Color",
),
(
"Blender",
"Blender (tint in Fog Color)",
"Cel shading puts tint color in Fog Color and tint level in Fog Alpha. Set up blender to LERP between CC output and tint color based on tint level. Then set CC to Tex 0 * shade color (vertex colors)",
),
]

enumCelCutoutSource = [
("TEXEL0", "Texture 0", "Cel shading material has binary alpha cutout from Texture 0 alpha. Does not work with I4 or I8 formats"),
("TEXEL1", "Texture 1", "Cel shading material has binary alpha cutout from Texture 1 alpha. Does not work with I4 or I8 formats"),
(
"TEXEL0",
"Texture 0",
"Cel shading material has binary alpha cutout from Texture 0 alpha. Does not work with I4 or I8 formats",
),
(
"TEXEL1",
"Texture 1",
"Cel shading material has binary alpha cutout from Texture 1 alpha. Does not work with I4 or I8 formats",
),
("ENVIRONMENT", "None / Env Alpha", "Make sure your material writes env color, and set env alpha to opaque (255)"),
]

Expand Down
Loading

0 comments on commit 658d94a

Please sign in to comment.