Skip to content

Commit

Permalink
shader improvements + cc props
Browse files Browse the repository at this point in the history
  • Loading branch information
ILoveAGoodCrisp committed Feb 3, 2025
1 parent 172c695 commit e9c7e7b
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 95 deletions.
1 change: 0 additions & 1 deletion blender/addons/io_scene_foundry/managed_blam/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def set_model_tag_path(self, new_path: str):
self.tag_has_changes = True

def get_change_colors(self, variant="") -> list:
print("CC VARIANT: ", variant)
change_colors = [tuple((1, 1, 1, 1)), tuple((1, 1, 1, 1)), tuple((1, 1, 1, 1)), tuple((1, 1, 1, 1))]
if not variant:
variant = self.default_variant.GetStringData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ def get_categories(self):

return categories

def get_default_bitmaps(self):
def get_defaults(self):
defaults = {}
parameter_types = {}
for element in self.block_categories.Elements:
for sub_element in element.Fields[1].Elements:
option_path = sub_element.Fields[1].Path
if option_path is not None:
with RenderMethodOptionTag(path=option_path) as render_method_option:
defaults.update(render_method_option.read_default_bitmaps())
parameter_types.update(render_method_option.read_parameter_types())

return defaults
return defaults, parameter_types
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ def read_options(self):
parameters[e.SelectField('parameter name').GetStringData()] = [e.SelectField('parameter ui override name').GetStringData(), e.SelectField('parameter type').Value]
return parameters

def read_parameter_types(self):
return {element.Fields[0].GetStringData(): element.Fields[2].Value for element in self.block_parameters.Elements}

def read_default_bitmaps(self) -> dict:
"""Returns a dict of parameter names and their default bitmaps"""
return {element.Fields[0].GetStringData(): element.Fields[4].Path for element in self.block_parameters.Elements}
155 changes: 74 additions & 81 deletions blender/addons/io_scene_foundry/managed_blam/shader.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion blender/addons/io_scene_foundry/props/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def update_shader(self, context):
options=set(),
)

prev_shader_path: StringProperty()
prev_shader_path: StringProperty(options={'HIDDEN'})

def recursive_image_search_object(self, tree_owner, object):
nodes = tree_owner.node_tree.nodes
Expand Down
41 changes: 41 additions & 0 deletions blender/addons/io_scene_foundry/props/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,47 @@ def poop_pathfinding_items(self, context):
min=0.0,
max=1.0,
)

cc_primary: bpy.props.FloatVectorProperty(
name="Change Color Primary",
options=set(),
description="",
size=4,
default=(1, 1, 1, 1.0),
subtype="COLOR",
min=0.0,
max=1.0,
)
cc_secondary: bpy.props.FloatVectorProperty(
name="Change Color Secondary",
options=set(),
description="",
size=4,
default=(1, 1, 1, 1.0),
subtype="COLOR",
min=0.0,
max=1.0,
)
cc_tertiary: bpy.props.FloatVectorProperty(
name="Change Color Tertiary",
options=set(),
description="",
size=4,
default=(1, 1, 1, 1.0),
subtype="COLOR",
min=0.0,
max=1.0,
)
cc_quaternary: bpy.props.FloatVectorProperty(
name="Change Color Quaternary",
options=set(),
description="",
size=4,
default=(1, 1, 1, 1.0),
subtype="COLOR",
min=0.0,
max=1.0,
)

def fog_clean_tag_path(self, context):
self["fog_appearance_tag"] = utils.clean_tag_path(
Expand Down
16 changes: 10 additions & 6 deletions blender/addons/io_scene_foundry/tools/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ def execute(self, context):
self.nothing_imported = False
self.user_cancelled = False
utils.set_object_mode(context)
change_colors = None
if self.tag_variant == "all_variants":
self.tag_variant = ""
if self.tag_zone_set == "all_zone_sets":
Expand Down Expand Up @@ -455,9 +454,8 @@ def execute(self, context):
importer.tag_animation = False
importer.tag_variant = self.tag_variant.lower()
importer.tag_state = State[self.tag_state].value
self.tag_state
object_files = importer.sorted_filepaths["object"]
imported_object_objects, change_colors = importer.import_object(object_files)
imported_object_objects = importer.import_object(object_files)
if needs_scaling:
utils.transform_scene(context, scale_factor, from_x_rot, 'x', context.scene.nwo.forward_direction, objects=imported_object_objects, actions=[])

Expand Down Expand Up @@ -515,7 +513,7 @@ def execute(self, context):
if needs_scaling:
utils.transform_scene(context, scale_factor, from_x_rot, 'x', context.scene.nwo.forward_direction, objects=[existing_armature], actions=imported_animations)

if self.context.scene.nwo.asset_type in {'model', 'animation'}:
if context.scene.nwo.asset_type in {'model', 'animation'}:
self.context.scene.nwo.active_animation_index = len(self.context.scene.nwo.animations) - 1

if 'scenario' in importer.extensions:
Expand Down Expand Up @@ -592,7 +590,7 @@ def execute(self, context):
for mat in new_materials:
shader_path = mat.nwo.shader_path
if shader_path:
tag_to_nodes(corinth, mat, shader_path, change_colors)
tag_to_nodes(corinth, mat, shader_path)

if 'bitmap' in importer.extensions:
bitmap_files = importer.sorted_filepaths["bitmap"]
Expand Down Expand Up @@ -1147,6 +1145,12 @@ def import_object(self, paths):
self.context.scene.collection.children.link(model_collection)
if render:
render_objects, armature = self.import_render_model(render, model_collection, None, allowed_region_permutations)
for ob in render_objects:
ob.nwo.cc_primary = change_colors[0]
ob.nwo.cc_secondary = change_colors[1]
ob.nwo.cc_tertiary = change_colors[2]
ob.nwo.cc_quaternary = change_colors[3]

imported_objects.extend(render_objects)
for ob in render_objects:
if ob.type == 'ARMATURE':
Expand All @@ -1155,7 +1159,7 @@ def import_object(self, paths):
if temp_variant == self.tag_variant:
ob.nwo.cinematic_variant = temp_variant

return imported_objects, change_colors
return imported_objects

def import_render_model(self, file, model_collection, existing_armature, allowed_region_permutations, skip_print=False):
if not skip_print:
Expand Down
8 changes: 4 additions & 4 deletions blender/addons/io_scene_foundry/tools/shader_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def execute(self, context):
tag_to_nodes(utils.is_corinth(context), mat, shader_path)
return {"FINISHED"}

def tag_to_nodes(corinth: bool, mat: bpy.types.Material, tag_path: str, change_colors=None):
def tag_to_nodes(corinth: bool, mat: bpy.types.Material, tag_path: str):
"""Turns a shader/material tag into blender material nodes"""
if corinth:
with MaterialTag(path=tag_path) as material:
Expand All @@ -45,10 +45,10 @@ def tag_to_nodes(corinth: bool, mat: bpy.types.Material, tag_path: str, change_c
match shader_type:
case 'shader':
with ShaderTag(path=tag_path) as shader:
shader.to_nodes(mat, change_colors)
shader.to_nodes(mat)
case 'shader_decal':
with ShaderDecalTag(path=tag_path) as shader:
shader.to_nodes(mat, change_colors)
shader.to_nodes(mat)
case 'shader_terrain':
with ShaderTerrainTag(path=tag_path) as shader:
shader.to_nodes(mat, change_colors)
shader.to_nodes(mat)

0 comments on commit e9c7e7b

Please sign in to comment.