Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,17 @@ def upgrade_changed_props():
OOT_ObjectProperties.upgrade_changed_props()
for scene in bpy.data.scenes:
settings: Fast64Settings_Properties = scene.fast64.settings
if settings.internal_game_update_ver != 1:
set_game_defaults(scene, False)
settings.internal_game_update_ver = 1

if scene.get("decomp_compatible", False):
scene.gameEditorMode = "Homebrew"
del scene["decomp_compatible"]

if settings.internal_game_update_ver == 0: # set world defaults, since we default to ucode defaults
set_game_defaults(scene, False)
if settings.internal_game_update_ver <= 1 and scene.gameEditorMode != "Homebrew" and scene.world is not None:
scene.world.rdp_defaults.g_lighting_positional = True # set lighting positional in old/new files
settings.internal_game_update_ver = 2

settings = scene.fast64.renderSettings
light0Color = settings.pop("lightColor", None)
if light0Color is not None:
Expand Down
5 changes: 3 additions & 2 deletions fast64_internal/f3d/f3d_bleed.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,10 @@ def place_in_flaglist(flag: bool, enum: str, set_list: SPSetGeometryMode, clear_
place_in_flaglist(defaults.g_tex_gen, "G_TEXTURE_GEN", setGeo, clearGeo)
place_in_flaglist(defaults.g_tex_gen_linear, "G_TEXTURE_GEN_LINEAR", setGeo, clearGeo)
place_in_flaglist(defaults.g_shade_smooth, "G_SHADING_SMOOTH", setGeo, clearGeo)
if bpy.context.scene.f3d_type == "F3DEX_GBI_2" or bpy.context.scene.f3d_type == "F3DEX_GBI":
if self.f3d.F3DEX_GBI:
place_in_flaglist(defaults.g_clipping, "G_CLIPPING", setGeo, clearGeo)

if self.f3d.POINT_LIT_GBI:
place_in_flaglist(defaults.g_lighting_positional, "G_LIGHTING_POSITIONAL", setGeo, clearGeo)
self.default_load_geo = SPLoadGeometryMode(setGeo.flagList)
self.default_set_geo = setGeo
self.default_clear_geo = clearGeo
Expand Down
6 changes: 6 additions & 0 deletions fast64_internal/f3d/f3d_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,12 @@
"Variant of F3DEX2 family using vertex rejection instead of clipping",
5,
),
(
"F3DEX2_PL",
"F3DEX2 (Point Lit)",
"Variant of F3DEX2 family with support for point lighting used in a few games including MM",
11,
),
("F3DEX3", "F3DEX3", "Custom microcode by Sauraen", 6),
("", "Homebrew", "", 8),
("RDPQ", "RDPQ", "Base libdragon microcode", 9),
Expand Down
13 changes: 10 additions & 3 deletions fast64_internal/f3d/f3d_gbi.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class GfxMatWriteMethod(enum.Enum):
"F3DLX.Rej": (64, 32),
"F3DLP.Rej": (80, 32),
"F3DEX2/LX2": (32, 32),
"F3DEX2_PL": (32, 32),
"F3DEX2.Rej/LX2.Rej": (64, 64),
"F3DEX3": (56, 56),
"T3D": (70, 70),
Expand Down Expand Up @@ -138,13 +139,17 @@ def isUcodeF3DEX1(F3D_VER: str) -> bool:


def isUcodeF3DEX2(F3D_VER: str) -> bool:
return F3D_VER in {"F3DEX2.Rej/LX2.Rej", "F3DEX2/LX2"}
return F3D_VER in {"F3DEX2.Rej/LX2.Rej", "F3DEX2/LX2", "F3DEX2_PL"}


def isUcodeF3DEX3(F3D_VER: str) -> bool:
return F3D_VER == "F3DEX3"


def is_ucode_point_lit(F3D_VER: str) -> bool:
return F3D_VER in {"F3DEX3", "F3DEX2_PL"}


def is_ucode_t3d(UCODE_VER: str) -> bool:
return UCODE_VER == "T3D"

Expand All @@ -163,6 +168,7 @@ def __init__(self, F3D_VER):
F3DEX_GBI_3 = self.F3DEX_GBI_3 = isUcodeF3DEX3(F3D_VER)
F3DLP_GBI = self.F3DLP_GBI = self.F3DEX_GBI
self.F3D_OLD_GBI = not (F3DEX_GBI or F3DEX_GBI_2 or F3DEX_GBI_3)
POINT_LIT_GBI = self.POINT_LIT_GBI = is_ucode_point_lit(F3D_VER)
self.F3D_GBI = is_ucode_f3d(F3D_VER)

# F3DEX2 is F3DEX1 and F3DEX3 is F3DEX2, but F3DEX3 is not F3DEX1
Expand Down Expand Up @@ -372,7 +378,6 @@ def __init__(self, F3D_VER):
self.G_LIGHTING_SPECULAR = 0x00002000
self.G_FRESNEL_COLOR = 0x00004000
self.G_FRESNEL_ALPHA = 0x00008000
self.G_LIGHTING_POSITIONAL = 0x00400000 # Ignored, always on

self.allGeomModeFlags = {
"G_ZBUFFER",
Expand All @@ -387,7 +392,6 @@ def __init__(self, F3D_VER):
"G_TEXTURE_GEN_LINEAR",
"G_LOD",
"G_SHADING_SMOOTH",
"G_LIGHTING_POSITIONAL",
"G_CLIPPING",
}
if F3DEX_GBI_3:
Expand All @@ -401,6 +405,9 @@ def __init__(self, F3D_VER):
"G_FRESNEL_COLOR",
"G_FRESNEL_ALPHA",
}
if POINT_LIT_GBI:
self.G_LIGHTING_POSITIONAL = 0x00400000
self.allGeomModeFlags.add("G_LIGHTING_POSITIONAL")

self.G_FOG_H = self.G_FOG / 0x10000
self.G_LIGHTING_H = self.G_LIGHTING / 0x10000
Expand Down
23 changes: 21 additions & 2 deletions fast64_internal/f3d/f3d_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
isUcodeF3DEX1,
isUcodeF3DEX3,
is_ucode_f3d,
is_ucode_point_lit,
is_ucode_t3d,
default_draw_layers,
)
Expand Down Expand Up @@ -170,6 +171,10 @@ def menu_items_enum(_self, context):
"clipping": "g_clipping",
}

F3D_PL_MODES = {
"positionalLighting": "g_lighting_positional",
}

F3DEX3_GEO_MODES = {
"ambientOcclusion": "g_ambocclusion",
"attroffsetZ": "g_attroffset_z_enable",
Expand Down Expand Up @@ -200,6 +205,8 @@ def geo_modes_in_ucode(UCODE_VER: str):
geo_modes.update(F3DEX3_GEO_MODES)
if is_ucode_t3d(UCODE_VER):
geo_modes.update(T3D_GEO_MODES)
if is_ucode_point_lit(UCODE_VER):
geo_modes.update(F3D_PL_MODES)
return geo_modes


Expand Down Expand Up @@ -557,6 +564,8 @@ def indentGroup(parent: UILayout, textOrProp: Union[str, "F3DMaterialProperty"],
c.enabled = enable or not disable_dependent
return c

f3d = get_F3D_GBI()

ccWarnings = shadeInCC = False
blendWarnings = shadeInBlender = zInBlender = False
if isinstance(dataHolder, F3DMaterialProperty):
Expand All @@ -575,6 +584,8 @@ def indentGroup(parent: UILayout, textOrProp: Union[str, "F3DMaterialProperty"],
if ccWarnings and not shadeInCC and is_on("g_lighting") and not is_on("g_tex_gen"):
multilineLabel(c, "Shade not used in CC, can disable\nlighting.", icon="INFO")
draw_mode(c, "g_packed_normals", "g_lighting_specular", "g_ambocclusion", "g_fresnel_color")
if not f3d.F3DEX_GBI_3: # Draw this flag in Not Useful for f3dex3
draw_mode(c, "g_lighting_positional")
if should_draw("g_tex_gen_linear"):
d = indentGroup(c, "g_tex_gen", False)
else:
Expand Down Expand Up @@ -663,9 +674,11 @@ def indentGroup(parent: UILayout, textOrProp: Union[str, "F3DMaterialProperty"],
elif ccWarnings and is_on("g_shade") and not shadeInCC and not shadeInBlender:
c.label(text="Shade is not being used, can disable.", icon="INFO")

if should_draw("g_lod", "g_clipping"):
if should_draw("g_lod", "g_clipping") or f3d.F3DEX_GBI_3:
c = indentGroup(inputGroup, "Not useful:", True)
draw_mode(c, "g_lod", "g_clipping")
if f3d.F3DEX_GBI_3:
c.prop(settings, "g_lighting_positional", text="Positional Lighting (Always enabled in EX3)")


def ui_upper_mode(settings, dataHolder, layout: UILayout, useDropdown):
Expand Down Expand Up @@ -3452,6 +3465,12 @@ class RDPSettings(PropertyGroup):
update=update_node_values_with_preset,
description="F3DEX1/LX only, exact function unknown",
)
g_lighting_positional: bpy.props.BoolProperty(
name="Positional Lighting",
default=False,
update=update_node_values_with_preset,
description="F3DEX2 (Point Lit): Enables calculating shade color using positional lights along with directional, ignored in F3DEX3",
)

# upper half mode
# v2 only
Expand Down Expand Up @@ -3721,7 +3740,7 @@ def attributes_from_dict(self, data: dict, info: dict):
for key, attr, default in info:
setattr(self, attr, data.get(key, default))

geo_mode_attributes = {**F3D_GEO_MODES, **F3DLX_GEO_MODES, **F3DEX3_GEO_MODES}
geo_mode_attributes = {**F3D_GEO_MODES, **F3DLX_GEO_MODES, **F3D_PL_MODES, **F3DEX3_GEO_MODES, **T3D_GEO_MODES}

def geo_mode_to_dict(self):
data = {}
Expand Down
Loading