5 Commits

Author SHA1 Message Date
Terrev
fd02e3240e disable subsurfacescattering on opaque as it doesnt play nicely with the scaling 2025-01-14 21:05:45 -05:00
Terrev
bbdfafc2b6 Merge pull request #23 from Squareville/lod-color
Coloring vertices per lod group, and repeating the state/seed so each…
2024-11-26 02:43:07 -05:00
473879e900 Coloring vertices per lod group, and repeating the state/seed so each lod is the same color. 2024-11-25 20:27:24 -05:00
Terrev
5c0c04e4a0 Merge pull request #22 from Squareville/reset-orientation
Option to apply a 90° rotation transform, fixes smashable vfx.
2024-11-12 02:04:53 -05:00
9a9b5fe58e Option to apply a 90° rotation transform, fixes smashable vfx. 2024-11-12 01:24:52 -05:00
3 changed files with 41 additions and 12 deletions

View File

@@ -1,7 +1,7 @@
bl_info = {
"name": "LU Toolbox",
"author": "Bobbe",
"version": (2, 1, 0),
"version": (2, 4, 0),
"blender": (2, 93, 0),
"location": "3D View -> Sidebar -> LU Toolbox",
"category": "Import-Export",

View File

@@ -115,6 +115,12 @@ class LUTB_OT_setup_icon_render(bpy.types.Operator):
name = material.name.rsplit(".", 1)[0]
if name in MATERIALS_OPAQUE:
mesh.materials[i] = get_lutb_ir_opaque_mat(self)
# another hack to change a material setting, for the same reasons as the comment below...
# anyway, it was deemed that having this enabled was making the plastic look too soft and washed-out in many scenarios - jamie
if mesh.materials[i].node_tree:
for node in mesh.materials[i].node_tree.nodes:
if node.type == "BSDF_PRINCIPLED":
node.inputs["Subsurface"].default_value = 0
elif name in MATERIALS_TRANSPARENT:
mesh.materials[i] = get_lutb_ir_transparent_mat(self)
# next two lines are a silly hacky fix cause i dont wanna mess with the magical mystery box that is resources.blend, and hollis didnt know why it was broken anyway - jamie

View File

@@ -75,12 +75,15 @@ class LUTB_OT_process_model(bpy.types.Operator):
if not scene.lutb_keep_uvs:
self.clear_uvs(all_objects)
if scene.lutb_reset_orientation:
self.reset_orientation(all_objects)
if scene.lutb_apply_vertex_colors:
if scene.lutb_correct_colors:
self.correct_colors(context, all_objects)
if scene.lutb_use_color_variation:
self.apply_color_variation(context, all_objects)
self.apply_color_variation(context, scene.collection.children)
self.apply_vertex_colors(context, all_objects)
@@ -117,6 +120,15 @@ class LUTB_OT_process_model(bpy.types.Operator):
for uv_layer in reversed(obj.data.uv_layers):
obj.data.uv_layers.remove(uv_layer)
def reset_orientation(self, objects):
for obj in objects:
obj.select_set(True)
bpy.ops.object.transform_apply()
obj.rotation_euler = (radians(-90), 0, 0)
bpy.ops.object.transform_apply()
obj.rotation_euler = (radians(90), 0, 0)
obj.select_set(False)
def combine_objects(self, context, collections):
scene = context.scene
@@ -168,19 +180,25 @@ class LUTB_OT_process_model(bpy.types.Operator):
elif color := MATERIALS_TRANSPARENT.get(name):
material.diffuse_color = color
def apply_color_variation(self, context, objects):
def apply_color_variation(self, context, collections):
initial_state = random.getstate()
variation = context.scene.lutb_color_variation
for obj in objects:
for material in obj.data.materials:
color = Color(material.diffuse_color[:3])
gamma = color.v ** (1 / 2.224)
custom_variation = CUSTOM_VARIATION.get(material.name.rsplit(".", 1)[0])
var = variation if custom_variation is None else variation * custom_variation
gamma += random.uniform(-var / 200, var / 200)
for collection in collections:
for lod_collection in collection.children:
random.setstate(initial_state)
for obj in list(lod_collection.objects):
if obj.type == "MESH":
for material in obj.data.materials:
color = Color(material.diffuse_color[:3])
gamma = color.v ** (1 / 2.224)
color.v = min(max(0, gamma), 1) ** 2.224
material.diffuse_color = (*color, 1.0)
custom_variation = CUSTOM_VARIATION.get(material.name.rsplit(".", 1)[0])
var = variation if custom_variation is None else variation * custom_variation
gamma += random.uniform(-var / 200, var / 200)
color.v = min(max(0, gamma), 1) ** 2.224
material.diffuse_color = (*color, 1.0)
def apply_vertex_colors(self, context, objects):
scene = context.scene
@@ -453,6 +471,8 @@ class LUTB_PT_process_model(LUToolboxPanel, bpy.types.Panel):
layout.prop(scene, "lutb_keep_uvs")
layout.prop(scene, "lutb_reset_orientation")
class LUTB_PT_apply_vertex_colors(LUToolboxPanel, bpy.types.Panel):
bl_label = "Apply Vertex Colors"
bl_parent_id = "LUTB_PT_process_model"
@@ -567,6 +587,8 @@ def register():
"Combine transparent bricks")
bpy.types.Scene.lutb_keep_uvs = BoolProperty(name="Keep UVs", default=False, description=""\
"Keep the original mesh UVs. Disabling this results in a model with no UVs")
bpy.types.Scene.lutb_reset_orientation = BoolProperty(name="Reset Orientation", default=True, description=""\
"Reset the orientation so the model is properly upright for visual effects.")
bpy.types.Scene.lutb_correct_colors = BoolProperty(name="Correct Colors", default=False, description=""\
"Remap model colors to LU color palette. "\
@@ -625,6 +647,7 @@ def unregister():
del bpy.types.Scene.lutb_combine_objects
del bpy.types.Scene.lutb_combine_transparent
del bpy.types.Scene.lutb_keep_uvs
del bpy.types.Scene.lutb_reset_orientation
del bpy.types.Scene.lutb_correct_colors
del bpy.types.Scene.lutb_use_color_variation