mirror of
https://github.com/ApfelTeeSaft/lightspeed64.git
synced 2026-08-26 19:33:24 +00:00
[SM64] Add lighting engine presets (#531)
* [SM64] Add lighting engine presets * remove preset dir function
This commit is contained in:
@@ -3993,10 +3993,6 @@ class CelLevelRemove(bpy.types.Operator):
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
def getCurrentPresetDir():
|
||||
return "f3d/" + bpy.context.scene.gameEditorMode.lower()
|
||||
|
||||
|
||||
class ApplyMaterialPresetOperator(Operator):
|
||||
bl_idname = "material.f3d_preset_apply"
|
||||
bl_label = "Apply F3D Material Preset"
|
||||
@@ -4008,10 +4004,6 @@ class ApplyMaterialPresetOperator(Operator):
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
def getCurrentPresetDir():
|
||||
return "f3d/" + bpy.context.scene.gameEditorMode.lower()
|
||||
|
||||
|
||||
# modules/bpy_types.py -> Menu
|
||||
class MATERIAL_MT_f3d_presets(Menu):
|
||||
bl_label = "F3D Material Presets"
|
||||
@@ -4031,13 +4023,19 @@ class MATERIAL_MT_f3d_presets(Menu):
|
||||
ext_valid = getattr(self, "preset_extensions", {".py", ".xml"})
|
||||
props_default = getattr(self, "preset_operator_defaults", None)
|
||||
add_operator = getattr(self, "preset_add_operator", None)
|
||||
presetDir = getCurrentPresetDir()
|
||||
|
||||
game = bpy.context.scene.gameEditorMode.lower()
|
||||
paths = bpy.utils.preset_paths("f3d/user")
|
||||
if not bpy.context.scene.f3dUserPresetsOnly:
|
||||
paths += bpy.utils.preset_paths(presetDir)
|
||||
if bpy.context.scene.f3d_type == "F3DEX3":
|
||||
paths += bpy.utils.preset_paths(f"{presetDir}_f3dex3")
|
||||
if game == "sm64":
|
||||
if bpy.context.scene.fast64.sm64.lighting_engine_presets:
|
||||
paths += bpy.utils.preset_paths("f3d/sm64_lighting_engine")
|
||||
else:
|
||||
paths += bpy.utils.preset_paths("f3d/sm64")
|
||||
elif game == "oot":
|
||||
paths += bpy.utils.preset_paths("f3d/oot")
|
||||
if bpy.context.scene.f3d_type == "F3DEX3":
|
||||
paths += bpy.utils.preset_paths("f3d/oot_f3dex3")
|
||||
self.path_menu(
|
||||
paths,
|
||||
self.preset_operator,
|
||||
|
||||
@@ -1809,13 +1809,13 @@ f3d_mat.use_default_lighting = f3d_mat.use_default_lighting # Force nodes update
|
||||
f3d_mat.presetName = 'Sm64 Decal'
|
||||
"""
|
||||
|
||||
sm64_environment_map = """
|
||||
sm64_unlit_environment_map = """
|
||||
|
||||
import bpy
|
||||
f3d_mat = bpy.context.material.f3d_mat
|
||||
bpy.context.material.f3d_update_flag = True
|
||||
|
||||
f3d_mat.name = ''
|
||||
f3d_mat.name = 'Sm64 Unlit Environment Map'
|
||||
f3d_mat.combiner1.name = ''
|
||||
f3d_mat.combiner1.A = '0'
|
||||
f3d_mat.combiner1.B = '0'
|
||||
@@ -1918,9 +1918,27 @@ f3d_mat.draw_layer.sm64 = '1'
|
||||
f3d_mat.draw_layer.oot = 'Opaque'
|
||||
bpy.context.material.f3d_update_flag = False
|
||||
f3d_mat.use_default_lighting = f3d_mat.use_default_lighting # Force nodes update
|
||||
f3d_mat.presetName = 'Sm64 Environment Map'
|
||||
f3d_mat.presetName = 'Sm64 Unlit Environment Map'
|
||||
"""
|
||||
|
||||
sm64_shaded_environment_map = (
|
||||
sm64_unlit_environment_map
|
||||
+ """
|
||||
bpy.context.material.f3d_update_flag = True
|
||||
f3d_mat.combiner1.A = 'TEXEL0'
|
||||
f3d_mat.combiner1.B = '0'
|
||||
f3d_mat.combiner1.C = 'SHADE'
|
||||
f3d_mat.combiner1.D = '0'
|
||||
f3d_mat.combiner1.A_alpha = '0'
|
||||
f3d_mat.combiner1.B_alpha = '0'
|
||||
f3d_mat.combiner1.C_alpha = '0'
|
||||
f3d_mat.combiner1.D_alpha = 'ENVIRONMENT'
|
||||
bpy.context.material.f3d_update_flag = False
|
||||
f3d_mat.use_default_lighting = f3d_mat.use_default_lighting # Force nodes update
|
||||
f3d_mat.presetName = 'Sm64 Shaded Environment Map'
|
||||
"""
|
||||
)
|
||||
|
||||
sm64_fog_shaded_texture = """
|
||||
|
||||
import bpy
|
||||
@@ -2953,7 +2971,7 @@ f3d_mat.combiner2.D = 'TEXEL0'
|
||||
f3d_mat.combiner2.A_alpha = '0'
|
||||
f3d_mat.combiner2.B_alpha = '0'
|
||||
f3d_mat.combiner2.C_alpha = '0'
|
||||
f3d_mat.combiner2.D_alpha = 'ENVIRONMENT'
|
||||
f3d_mat.combiner2.D_alpha = 'TEXEL0'
|
||||
f3d_mat.tex0.tex_set = True
|
||||
f3d_mat.tex1.tex_set = True
|
||||
f3d_mat.set_prim = True
|
||||
@@ -6380,6 +6398,125 @@ f3d_mat.use_default_lighting = f3d_mat.use_default_lighting # Force nodes update
|
||||
f3d_mat.presetName = 'Oot Water Mult Specular Fresnel'
|
||||
"""
|
||||
|
||||
# SM64 Lighting Engine specific
|
||||
|
||||
lighting_engine_sm64_decal = (
|
||||
sm64_decal
|
||||
+ """
|
||||
bpy.context.material.f3d_update_flag = True
|
||||
f3d_mat.combiner1.A = 'TEXEL0'
|
||||
f3d_mat.combiner1.B = 'PRIMITIVE'
|
||||
f3d_mat.combiner1.C = 'TEXEL0_ALPHA'
|
||||
f3d_mat.combiner1.D = 'PRIMITIVE'
|
||||
f3d_mat.combiner1.A_alpha = '0'
|
||||
f3d_mat.combiner1.B_alpha = '0'
|
||||
f3d_mat.combiner1.C_alpha = '0'
|
||||
f3d_mat.combiner1.D_alpha = 'ENVIRONMENT'
|
||||
f3d_mat.combiner2.A = 'COMBINED'
|
||||
f3d_mat.combiner2.B = '0'
|
||||
f3d_mat.combiner2.C = 'SHADE'
|
||||
f3d_mat.combiner2.D = '0'
|
||||
f3d_mat.combiner2.A_alpha = '0'
|
||||
f3d_mat.combiner2.B_alpha = '0'
|
||||
f3d_mat.combiner2.C_alpha = '0'
|
||||
f3d_mat.combiner2.D_alpha = 'COMBINED'
|
||||
f3d_mat.set_prim = True
|
||||
f3d_mat.set_lights = False
|
||||
f3d_mat.rdp_settings.g_mdsft_cycletype = 'G_CYC_2CYCLE'
|
||||
f3d_mat.rdp_settings.set_rendermode = True
|
||||
f3d_mat.rdp_settings.rendermode_advanced_enabled = False
|
||||
f3d_mat.rdp_settings.rendermode_preset_cycle_1 = 'G_RM_NOOP'
|
||||
f3d_mat.rdp_settings.rendermode_preset_cycle_2 = 'G_RM_AA_ZB_OPA_SURF2'
|
||||
bpy.context.material.f3d_update_flag = False
|
||||
f3d_mat.use_default_lighting = f3d_mat.use_default_lighting # Force nodes update
|
||||
"""
|
||||
)
|
||||
|
||||
lighting_engine_sm64_fog_shaded_texture = (
|
||||
sm64_fog_shaded_texture
|
||||
+ """
|
||||
bpy.context.material.f3d_update_flag = True
|
||||
f3d_mat.set_lights = False
|
||||
bpy.context.material.f3d_update_flag = False
|
||||
f3d_mat.use_default_lighting = f3d_mat.use_default_lighting # Force nodes update
|
||||
"""
|
||||
)
|
||||
|
||||
lighting_engine_sm64_fog_shaded_texture_cutout = (
|
||||
sm64_fog_shaded_texture_cutout
|
||||
+ """
|
||||
bpy.context.material.f3d_update_flag = True
|
||||
f3d_mat.set_lights = False
|
||||
bpy.context.material.f3d_update_flag = False
|
||||
f3d_mat.use_default_lighting = f3d_mat.use_default_lighting # Force nodes update
|
||||
"""
|
||||
)
|
||||
|
||||
lighting_fog_shaded_texture_transparent = (
|
||||
sm64_fog_shaded_texture_transparent
|
||||
+ """
|
||||
bpy.context.material.f3d_update_flag = True
|
||||
f3d_mat.set_lights = False
|
||||
bpy.context.material.f3d_update_flag = False
|
||||
f3d_mat.use_default_lighting = f3d_mat.use_default_lighting # Force nodes update
|
||||
"""
|
||||
)
|
||||
|
||||
lighting_engine_sm64_shaded_noise = (
|
||||
sm64_shaded_noise
|
||||
+ """
|
||||
bpy.context.material.f3d_update_flag = True
|
||||
f3d_mat.set_lights = False
|
||||
bpy.context.material.f3d_update_flag = False
|
||||
f3d_mat.use_default_lighting = f3d_mat.use_default_lighting # Force nodes update
|
||||
"""
|
||||
)
|
||||
|
||||
lighting_engine_sm64_shaded_solid = (
|
||||
sm64_shaded_solid
|
||||
+ """
|
||||
bpy.context.material.f3d_update_flag = True
|
||||
f3d_mat.combiner1.A = 'PRIMITIVE'
|
||||
f3d_mat.combiner1.B = '0'
|
||||
f3d_mat.combiner1.C = 'SHADE'
|
||||
f3d_mat.combiner1.D = '0'
|
||||
f3d_mat.set_lights = False
|
||||
bpy.context.material.f3d_update_flag = False
|
||||
f3d_mat.use_default_lighting = f3d_mat.use_default_lighting # Force nodes update
|
||||
"""
|
||||
)
|
||||
|
||||
lighting_engine_sm64_shaded_texture_cutout = (
|
||||
sm64_shaded_texture_cutout
|
||||
+ """
|
||||
bpy.context.material.f3d_update_flag = True
|
||||
f3d_mat.set_lights = False
|
||||
bpy.context.material.f3d_update_flag = False
|
||||
f3d_mat.use_default_lighting = f3d_mat.use_default_lighting # Force nodes update
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
lighting_engine_sm64_shaded_texture_transparent = (
|
||||
sm64_shaded_texture_transparent
|
||||
+ """
|
||||
bpy.context.material.f3d_update_flag = True
|
||||
f3d_mat.set_lights = False
|
||||
bpy.context.material.f3d_update_flag = False
|
||||
f3d_mat.use_default_lighting = f3d_mat.use_default_lighting # Force nodes update
|
||||
"""
|
||||
)
|
||||
|
||||
lighting_engine_sm64_shaded_environment_map = (
|
||||
sm64_shaded_environment_map
|
||||
+ """
|
||||
bpy.context.material.f3d_update_flag = True
|
||||
f3d_mat.set_lights = False
|
||||
bpy.context.material.f3d_update_flag = False
|
||||
f3d_mat.use_default_lighting = f3d_mat.use_default_lighting # Force nodes update
|
||||
"""
|
||||
)
|
||||
|
||||
homebrew_and_oot = {
|
||||
"shaded_environment_mapped": shaded_environment_mapped,
|
||||
"shaded_environment_mapped_transparent": shaded_environment_mapped_transparent,
|
||||
@@ -6399,6 +6536,7 @@ homebrew_and_oot = {
|
||||
"vertex_colored_texture_cutout": vertex_colored_texture_cutout,
|
||||
"vertex_colored_texture_transparent": vertex_colored_texture_transparent,
|
||||
}
|
||||
|
||||
material_presets = {
|
||||
"homebrew": homebrew_and_oot,
|
||||
"oot": {
|
||||
@@ -6430,7 +6568,6 @@ material_presets = {
|
||||
},
|
||||
"sm64": {
|
||||
"sm64_decal": sm64_decal,
|
||||
"sm64_environment_map": sm64_environment_map,
|
||||
"sm64_fog_shaded_texture": sm64_fog_shaded_texture,
|
||||
"sm64_fog_shaded_texture_cutout": sm64_fog_shaded_texture_cutout,
|
||||
"sm64_fog_shaded_texture_transparent": sm64_fog_shaded_texture_transparent,
|
||||
@@ -6439,6 +6576,24 @@ material_presets = {
|
||||
"sm64_shaded_texture": sm64_shaded_texture,
|
||||
"sm64_shaded_texture_cutout": sm64_shaded_texture_cutout,
|
||||
"sm64_shaded_texture_transparent": sm64_shaded_texture_transparent,
|
||||
"sm64_shaded_environment_map": sm64_shaded_environment_map,
|
||||
"sm64_unlit_environment_map": sm64_unlit_environment_map,
|
||||
"sm64_unlit_texture": sm64_unlit_texture,
|
||||
"sm64_unlit_texture_cutout": sm64_unlit_texture_cutout,
|
||||
"sm64_vertex_colored_texture": sm64_vertex_colored_texture,
|
||||
"sm64_vertex_colored_texture_transparent": sm64_vertex_colored_texture_transparent,
|
||||
},
|
||||
"sm64_lighting_engine": {
|
||||
"sm64_decal": lighting_engine_sm64_decal,
|
||||
"sm64_fog_shaded_texture": lighting_engine_sm64_fog_shaded_texture,
|
||||
"sm64_fog_shaded_texture_cutout": lighting_engine_sm64_fog_shaded_texture_cutout,
|
||||
"sm64_fog_shaded_texture_transparent": lighting_fog_shaded_texture_transparent,
|
||||
"sm64_shaded_noise": lighting_engine_sm64_shaded_noise,
|
||||
"sm64_shaded_solid": lighting_engine_sm64_shaded_solid,
|
||||
"sm64_shaded_texture_cutout": lighting_engine_sm64_shaded_texture_cutout,
|
||||
"sm64_shaded_texture_transparent": lighting_engine_sm64_shaded_texture_transparent,
|
||||
"sm64_shaded_environment_map": lighting_engine_sm64_shaded_environment_map,
|
||||
"sm64_unlit_environment_map": sm64_unlit_environment_map,
|
||||
"sm64_unlit_texture": sm64_unlit_texture,
|
||||
"sm64_unlit_texture_cutout": sm64_unlit_texture_cutout,
|
||||
"sm64_vertex_colored_texture": sm64_vertex_colored_texture,
|
||||
|
||||
@@ -88,6 +88,7 @@ class SM64_Properties(PropertyGroup):
|
||||
name="Matstack Fix",
|
||||
description="Exports account for matstack fix requirements",
|
||||
)
|
||||
lighting_engine_presets: BoolProperty(name="Lighting Engine Presets")
|
||||
write_all: BoolProperty(
|
||||
name="Write All",
|
||||
description="Write single load geo and set othermode commands instead of writting the difference to defaults. Can result in smaller displaylists but may introduce issues",
|
||||
@@ -171,6 +172,8 @@ class SM64_Properties(PropertyGroup):
|
||||
data["compression_format"] = self.compression_format
|
||||
data["force_extended_ram"] = self.force_extended_ram
|
||||
data["matstack_fix"] = self.matstack_fix
|
||||
if self.matstack_fix:
|
||||
data["lighting_engine_presets"] = self.lighting_engine_presets
|
||||
data["write_all"] = self.write_all
|
||||
return data
|
||||
|
||||
@@ -179,6 +182,7 @@ class SM64_Properties(PropertyGroup):
|
||||
set_prop_if_in_data(self, "compression_format", data, "compression_format")
|
||||
set_prop_if_in_data(self, "force_extended_ram", data, "force_extended_ram")
|
||||
set_prop_if_in_data(self, "matstack_fix", data, "matstack_fix")
|
||||
set_prop_if_in_data(self, "lighting_engine_presets", data, "lighting_engine_presets")
|
||||
set_prop_if_in_data(self, "write_all", data, "write_all")
|
||||
|
||||
def draw_repo_settings(self, layout: UILayout):
|
||||
@@ -189,6 +193,8 @@ class SM64_Properties(PropertyGroup):
|
||||
prop_split(col, self, "refresh_version", "Refresh (Function Map)")
|
||||
col.prop(self, "force_extended_ram")
|
||||
col.prop(self, "matstack_fix")
|
||||
if self.matstack_fix:
|
||||
col.prop(self, "lighting_engine_presets")
|
||||
col.prop(self, "write_all")
|
||||
|
||||
def draw_props(self, layout: UILayout, show_repo_settings: bool = True):
|
||||
|
||||
Reference in New Issue
Block a user