Skip to content

Commit

Permalink
[F3D] Rewrite BSDF to F3D converter and add an F3D to BSDF converter
Browse files Browse the repository at this point in the history
Rewritten BSDF to F3D converter with support for picking up on which and how layers are used for merging them correctly in bad model imports, support for glTF2 styled color mul, picking up on uv gen, filtering, mapping, etc, if a material is lit, if a material is a cutout, transparent or opaque (even in 4.2)
Brand new F3D to BSDF converter for outside fast64 context workflows where simple materials are desired. I mainly targeted glTF and obj compatible models.
The new implementations should also make non sm64 people pretty happy aha!
Code may need some clean up, I'll consider undrafting tomorrow morning but all the features and bugs should be review ready.. hopefully
  • Loading branch information
Lilaa3 committed Oct 26, 2024
1 parent ddd6969 commit b71ef57
Show file tree
Hide file tree
Showing 10 changed files with 1,307 additions and 163 deletions.
32 changes: 22 additions & 10 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

from .fast64_internal.mk64 import MK64_Properties, mk64_register, mk64_unregister

from .fast64_internal.f3d import F3D_Properties, f3d_register, f3d_unregister
from .fast64_internal.f3d.f3d_material import (
F3D_MAT_CUR_VERSION,
mat_register,
Expand All @@ -37,15 +38,13 @@
from .fast64_internal.f3d.f3d_parser import f3d_parser_register, f3d_parser_unregister
from .fast64_internal.f3d.flipbook import flipbook_register, flipbook_unregister
from .fast64_internal.f3d.op_largetexture import op_largetexture_register, op_largetexture_unregister, ui_oplargetexture

from .fast64_internal.f3d_material_converter import (
MatUpdateConvert,
mat_updater_draw,
upgrade_f3d_version_all_meshes,
bsdf_conv_register,
bsdf_conv_unregister,
bsdf_conv_panel_regsiter,
bsdf_conv_panel_unregsiter,
mat_updater_register,
mat_updater_unregister,
)
from .fast64_internal.f3d.bsdf_converter import bsdf_converter_panel_draw

from .fast64_internal.render_settings import (
Fast64RenderSettings_Properties,
Expand Down Expand Up @@ -152,6 +151,18 @@ def draw(self, context):
col.operator(ArmatureApplyWithMeshOperator.bl_idname)
# col.operator(CreateMetarig.bl_idname)
ui_oplargetexture(col, context)
col.separator()

box = col.box().column()
box.label(text="Material Updater")
mat_updater_draw(box, context)
col.separator()

box = col.box().column()
box.label(text="BSDF Converter")
bsdf_converter_panel_draw(box, context)
col.separator()

addon_updater_ops.update_notice_box_ui(self, context)


Expand Down Expand Up @@ -223,6 +234,7 @@ class Fast64_Properties(bpy.types.PropertyGroup):
sm64: bpy.props.PointerProperty(type=SM64_Properties, name="SM64 Properties")
oot: bpy.props.PointerProperty(type=OOT_Properties, name="OOT Properties")
mk64: bpy.props.PointerProperty(type=MK64_Properties, name="MK64 Properties")
f3d: bpy.props.PointerProperty(type=F3D_Properties, name="F3D Properties")
settings: bpy.props.PointerProperty(type=Fast64Settings_Properties, name="Fast64 Settings")
renderSettings: bpy.props.PointerProperty(type=Fast64RenderSettings_Properties, name="Fast64 Render Settings")

Expand Down Expand Up @@ -420,7 +432,8 @@ def register():
utility_anim_register()
mat_register()
render_engine_register()
bsdf_conv_register()
mat_updater_register()
f3d_register(True)
sm64_register(True)
oot_register(True)
mk64_register(True)
Expand All @@ -430,7 +443,6 @@ def register():
for cls in classes:
register_class(cls)

bsdf_conv_panel_regsiter()
f3d_writer_register()
flipbook_register()
f3d_parser_register()
Expand Down Expand Up @@ -471,9 +483,9 @@ def unregister():
sm64_unregister(True)
oot_unregister(True)
mk64_unregister(True)
f3d_unregister(True)
mat_unregister()
bsdf_conv_unregister()
bsdf_conv_panel_unregsiter()
mat_updater_unregister()
render_engine_unregister()

del bpy.types.Scene.fullTraceback
Expand Down
1 change: 0 additions & 1 deletion fast64_internal/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from .f3d_material_converter import *
from .f3d import *
from .sm64 import *
from .oot import * # is this really needed?
from .panels import *
28 changes: 28 additions & 0 deletions fast64_internal/f3d/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,32 @@
from bpy.types import PropertyGroup
from bpy.props import PointerProperty

from .f3d_parser import *
from .f3d_material import *
from .f3d_render_engine import *
from .f3d_gbi import *
from .bsdf_converter import F3D_BSDFConverterProperties, bsdf_converter_register, bsdf_converter_unregister


class F3D_Properties(PropertyGroup):
"""
Properties in scene.fast64.f3d.
All new scene f3d properties should be children of this property group.
"""

bsdf_converter: PointerProperty(name="BSDF Converter", type=F3D_BSDFConverterProperties)


classes = (F3D_Properties,)


def f3d_register(register_panel=True):
bsdf_converter_register()
for cls in classes:
register_class(cls)


def f3d_unregister(register_panel=True):
for cls in reversed(classes):
unregister_class(cls)
bsdf_converter_unregister()
13 changes: 13 additions & 0 deletions fast64_internal/f3d/bsdf_converter/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from .operators import bsdf_converter_ops_register, bsdf_converter_ops_unregister
from .ui import bsdf_converter_panel_draw
from .properties import F3D_BSDFConverterProperties, bsdf_converter_props_register, bsdf_converter_props_unregister


def bsdf_converter_register():
bsdf_converter_ops_register()
bsdf_converter_props_register()


def bsdf_converter_unregister():
bsdf_converter_ops_unregister()
bsdf_converter_props_unregister()
Loading

0 comments on commit b71ef57

Please sign in to comment.