Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into smart-include-function
Browse files Browse the repository at this point in the history
  • Loading branch information
Lilaa3 committed Sep 25, 2024
2 parents de8744f + 7cdb920 commit d2d16dd
Show file tree
Hide file tree
Showing 8 changed files with 206 additions and 41 deletions.
Binary file removed LowPolySkinnedMario.blend
Binary file not shown.
Binary file removed LowPolySkinnedMario_V5.blend
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ Make sure to save often, as this plugin is prone to crashing when creating mater

<https://developer.blender.org/T70574>

### Example models can be found [here](https://github.com/Fast-64/fast64-models)

![alt-text](/images/mat_inspector.png)

### Credits
Thanks to anonymous_moose, Cheezepin, Rovert, and especially InTheBeef for testing.
Thanks to InTheBeef for LowPolySkinnedMario.

### Discord Server
We have a Discord server for support as well as development [here](https://discord.gg/ny7PDcN2x8).
Expand Down
2 changes: 2 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

from .fast64_internal.render_settings import (
Fast64RenderSettings_Properties,
ManualUpdatePreviewOperator,
resync_scene_props,
on_update_render_settings,
)
Expand Down Expand Up @@ -311,6 +312,7 @@ def draw(self, context):
classes = (
Fast64Settings_Properties,
Fast64RenderSettings_Properties,
ManualUpdatePreviewOperator,
Fast64_Properties,
Fast64_BoneProperties,
Fast64_ObjectProperties,
Expand Down
20 changes: 18 additions & 2 deletions fast64_internal/f3d/f3d_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@
from .f3d_gbi import get_F3D_GBI, enumTexScroll, isUcodeF3DEX1, default_draw_layers
from .f3d_material_presets import *
from ..utility import *
from ..render_settings import Fast64RenderSettings_Properties, update_scene_props_from_render_settings
from ..render_settings import (
Fast64RenderSettings_Properties,
update_scene_props_from_render_settings,
ManualUpdatePreviewOperator,
)
from .f3d_material_helpers import F3DMaterial_UpdateLock, node_tree_copy
from bpy.app.handlers import persistent
from typing import Generator, Optional, Tuple, Any, Dict, Union
Expand Down Expand Up @@ -2425,7 +2429,7 @@ def createOrUpdateSceneProperties():
sceneOutputs: NodeGroupOutput = new_group.nodes["Group Output"]
renderSettings: "Fast64RenderSettings_Properties" = bpy.context.scene.fast64.renderSettings

update_scene_props_from_render_settings(bpy.context, sceneOutputs, renderSettings)
update_scene_props_from_render_settings(sceneOutputs, renderSettings)


def createScenePropertiesForMaterial(material: Material):
Expand Down Expand Up @@ -4709,6 +4713,18 @@ def draw(self, context):
labelbox.label(text="Global Settings")
labelbox.ui_units_x = 6

# Only show the update preview UI if the render engine is EEVEE,
# as there's no point in updating the nodes otherwise.
if context.scene.render.engine in {
"BLENDER_EEVEE", # <4.2
"BLENDER_EEVEE_NEXT", # 4.2+
}:
updatePreviewRow = globalSettingsBox.row()
updatePreviewRow.prop(renderSettings, "enableAutoUpdatePreview")
if not renderSettings.enableAutoUpdatePreview:
updatePreviewRow.operator(ManualUpdatePreviewOperator.bl_idname)
globalSettingsBox.separator()

globalSettingsBox.prop(renderSettings, "enableFogPreview")
prop_split(globalSettingsBox, renderSettings, "fogPreviewColor", "Fog Color")
prop_split(globalSettingsBox, renderSettings, "fogPreviewPosition", "Fog Position")
Expand Down
12 changes: 6 additions & 6 deletions fast64_internal/f3d_material_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,16 @@ def convertAllBSDFtoF3D(objs, renameUV):
def convertBSDFtoF3D(obj, index, material, materialDict):
if not material.use_nodes:
newMaterial = createF3DMat(obj, preset="Shaded Solid", index=index)
f3dMat = newMaterial.f3d_mat if newMaterial.mat_ver > 3 else newMaterial
f3dMat.default_light_color = material.diffuse_color
with bpy.context.temp_override(material=newMaterial):
newMaterial.f3d_mat.default_light_color = material.diffuse_color
updateMatWithName(newMaterial, material, materialDict)

elif "Principled BSDF" in material.node_tree.nodes:
tex0Node = material.node_tree.nodes["Principled BSDF"].inputs["Base Color"]
if len(tex0Node.links) == 0:
newMaterial = createF3DMat(obj, preset=getDefaultMaterialPreset("Shaded Solid"), index=index)
f3dMat = newMaterial.f3d_mat if newMaterial.mat_ver > 3 else newMaterial
f3dMat.default_light_color = tex0Node.default_value
with bpy.context.temp_override(material=newMaterial):
newMaterial.f3d_mat.default_light_color = tex0Node.default_value
updateMatWithName(newMaterial, material, materialDict)
else:
if isinstance(tex0Node.links[0].from_node, bpy.types.ShaderNodeTexImage):
Expand All @@ -213,8 +213,8 @@ def convertBSDFtoF3D(obj, index, material, materialDict):
else:
presetName = getDefaultMaterialPreset("Shaded Texture")
newMaterial = createF3DMat(obj, preset=presetName, index=index)
f3dMat = newMaterial.f3d_mat if newMaterial.mat_ver > 3 else newMaterial
f3dMat.tex0.tex = tex0Node.links[0].from_node.image
with bpy.context.temp_override(material=newMaterial):
newMaterial.f3d_mat.tex0.tex = tex0Node.links[0].from_node.image
updateMatWithName(newMaterial, material, materialDict)
else:
print("Principled BSDF material does not have an Image Node attached to its Base Color.")
Expand Down
Loading

0 comments on commit d2d16dd

Please sign in to comment.