Skip to content

Commit

Permalink
Merged main
Browse files Browse the repository at this point in the history
  • Loading branch information
sauraen committed Jan 9, 2024
2 parents ea8bb90 + fbb249f commit 1339da5
Show file tree
Hide file tree
Showing 31 changed files with 1,615 additions and 1,420 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
10 changes: 8 additions & 2 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from . import addon_updater_ops
from .fast64_internal.operators import AddWaterBox
from .fast64_internal.panels import SM64_Panel
from .fast64_internal.utility import PluginError, raisePluginError, attemptModifierApply, prop_split
from .fast64_internal.utility import PluginError, raisePluginError, attemptModifierApply, prop_split, multilineLabel

from .fast64_internal.sm64 import SM64_Properties, sm64_register, sm64_unregister
from .fast64_internal.sm64.sm64_geolayout_bone import SM64_BoneProperties
Expand Down 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 @@ -165,6 +165,12 @@ def draw(self, context):
col.prop(context.scene, "f3d_simple", text="Simple Material UI")
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",
)
col.prop(context.scene, "decomp_compatible", invert_checkbox=True, text="Homebrew Compatibility")
col.prop(context.scene, "ignoreTextureRestrictions")
if context.scene.ignoreTextureRestrictions:
Expand Down
457 changes: 331 additions & 126 deletions fast64_internal/f3d/f3d_bleed.py

Large diffs are not rendered by default.

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
40 changes: 20 additions & 20 deletions fast64_internal/f3d/f3d_gbi.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,16 @@ class DLFormat(enum.Enum):
Dynamic = 2


class GfxListTag(enum.Enum):
class GfxListTag(enum.IntFlag):
Geometry = 1
Material = 2
MaterialRevert = 3
Draw = 3
MaterialRevert = 4
Draw = 4
NoExport = 16

@property
def Export(self):
return not self & GfxListTag.NoExport


class GfxTag(enum.Flag):
Expand Down Expand Up @@ -2680,7 +2685,7 @@ def to_c_gfx_scroll(self, gfxFormatter: GfxFormatter) -> CScrollData:
data = CScrollData()
for fMaterial, _ in self.materials.values():
fMaterial: FMaterial
if fMaterial.material:
if fMaterial.material.tag.Export:
data.append(gfxFormatter.gfxScrollToC(fMaterial.material, self.f3d))
for fMesh in self.meshes.values():
fMesh: FMesh
Expand Down Expand Up @@ -2940,7 +2945,7 @@ def set_addr(self, startAddress, f3d):

def save_binary(self, romfile, f3d, segments):
for celTriList in self.celTriLists:
celTriList.save_binary(romfile, f3d, segments);
celTriList.save_binary(romfile, f3d, segments)
self.triList.save_binary(romfile, f3d, segments)
self.vertexList.save_binary(romfile)

Expand All @@ -2949,7 +2954,7 @@ def to_c(self, f3d, gfxFormatter):
data.append(self.vertexList.to_c())
for celTriList in self.celTriLists:
data.append(celTriList.to_c(f3d))
if self.triList:
if self.triList.tag.Export:
data.append(self.triList.to_c(f3d))
return data

Expand Down Expand Up @@ -3049,7 +3054,7 @@ def sets_rendermode(self):

def get_ptr_addresses(self, f3d):
addresses = self.material.get_ptr_addresses(f3d)
if self.revert is not None:
if self.revert is not None and self.revert.tag.Export:
addresses.extend(self.revert.get_ptr_addresses(f3d))
return addresses

Expand All @@ -3067,9 +3072,9 @@ def save_binary(self, romfile, f3d, segments):

def to_c(self, f3d):
data = CData()
if self.material:
if self.material.tag.Export:
data.append(self.material.to_c(f3d))
if self.revert is not None:
if self.revert is not None and self.revert.tag.Export:
data.append(self.revert.to_c(f3d))
return data

Expand Down Expand Up @@ -3781,9 +3786,7 @@ class SPAmbOcclusionAmbDir(GbiMacro):
def to_binary(self, f3d, segments):
if not f3d.F3DEX_GBI_3:
raise PluginError("SPAmbOcclusionAmbDir requires F3DEX3 microcode")
return gsMoveWd(
f3d.G_MW_FX, f3d.G_MWO_AO_AMBIENT, (_SHIFTL(self.amb, 16, 16) | _SHIFTL(self.dir, 0, 16)), f3d
)
return gsMoveWd(f3d.G_MW_FX, f3d.G_MWO_AO_AMBIENT, (_SHIFTL(self.amb, 16, 16) | _SHIFTL(self.dir, 0, 16)), f3d)


@dataclass(unsafe_hash=True)
Expand All @@ -3810,8 +3813,9 @@ class SPAmbOcclusion(GbiMacro):
def to_binary(self, f3d, segments):
if not f3d.F3DEX_GBI_3:
raise PluginError("SPAmbOcclusion requires F3DEX3 microcode")
return SPAmbOcclusionAmbDir(self.amb, self.dir).to_binary(f3d, segments) + \
SPAmbOcclusionPoint(self.point).to_binary(f3d, segments)
return SPAmbOcclusionAmbDir(self.amb, self.dir).to_binary(f3d, segments) + SPAmbOcclusionPoint(
self.point
).to_binary(f3d, segments)


@dataclass(unsafe_hash=True)
Expand All @@ -3822,9 +3826,7 @@ class SPFresnelScale(GbiMacro):
def to_binary(self, f3d, segments):
if not f3d.F3DEX_GBI_3:
raise PluginError("SPFresnelScale requires F3DEX3 microcode")
return gsMoveHalfwd(
f3d.G_MW_FX, f3d.G_MWO_FRESNEL_SCALE, self.scale, f3d
)
return gsMoveHalfwd(f3d.G_MW_FX, f3d.G_MWO_FRESNEL_SCALE, self.scale, f3d)


@dataclass(unsafe_hash=True)
Expand All @@ -3835,9 +3837,7 @@ class SPFresnelOffset(GbiMacro):
def to_binary(self, f3d, segments):
if not f3d.F3DEX_GBI_3:
raise PluginError("SPFresnelOffset requires F3DEX3 microcode")
return gsMoveHalfwd(
f3d.G_MW_FX, f3d.G_MWO_FRESNEL_OFFSET, self.offset, f3d
)
return gsMoveHalfwd(f3d.G_MW_FX, f3d.G_MWO_FRESNEL_OFFSET, self.offset, f3d)


@dataclass(unsafe_hash=True)
Expand Down
36 changes: 18 additions & 18 deletions fast64_internal/f3d/f3d_generate_presets.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import os

basePath = 'presets/f3d'
data = ''
basePath = "presets/f3d"
data = ""
presetList = "material_presets = {\n"

for subdir in os.listdir(basePath):
subPath = os.path.join(basePath, subdir)
if subdir != '__pycache__' and subdir != 'user' and os.path.isdir(subPath):
presetList += '\t"' + subdir + '" : {\n'
for filename in os.listdir(subPath):
presetPath = os.path.join(subPath, filename)
if os.path.isfile(presetPath):
print(presetPath)
presetFile = open(presetPath, 'r')
presetData = presetFile.read()
presetFile.close()
subPath = os.path.join(basePath, subdir)
if subdir != "__pycache__" and subdir != "user" and os.path.isdir(subPath):
presetList += '\t"' + subdir + '" : {\n'
for filename in os.listdir(subPath):
presetPath = os.path.join(subPath, filename)
if os.path.isfile(presetPath):
print(presetPath)
presetFile = open(presetPath, "r")
presetData = presetFile.read()
presetFile.close()

data += filename[:-3] + " = '''\n" + presetData + "'''\n\n"
presetList += '\t\t"' + filename[:-3] + '" : ' + filename[:-3] + ',\n'
presetList += '\t},\n'
data += filename[:-3] + " = '''\n" + presetData + "'''\n\n"
presetList += '\t\t"' + filename[:-3] + '" : ' + filename[:-3] + ",\n"
presetList += "\t},\n"

presetList += '}\n'
presetList += "}\n"

data += presetList

outFile = open('f3d_material_presets.py', 'w')
outFile = open("f3d_material_presets.py", "w")
outFile.write(data)
outFile.close()
outFile.close()
Loading

0 comments on commit 1339da5

Please sign in to comment.