Skip to content

Commit

Permalink
Resource Packs pre-reformat commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Aspirata committed Jun 26, 2024
1 parent 49bfae2 commit 9f0afeb
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 39 deletions.
4 changes: 2 additions & 2 deletions Mcblend Source/Data.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

main_directory = os.path.dirname(os.path.realpath(__file__))
resource_packs_directory = os.path.join(main_directory, "Resource Packs")
materials_file_path = os.path.join(main_directory, "Materials", "Materials.blend")
nodes_file = os.path.join(main_directory, "Materials", "Nodes.blend")
materials_folder = os.path.join(main_directory, "Materials")
optimization_folder = os.path.join(main_directory, "Optimization")
assets_directory = os.path.join(main_directory, "Assets")
Expand Down Expand Up @@ -279,7 +279,7 @@

SSS_Materials = ["leaves", "grass", "tulip", "oxeye_daisy", "dandelion", "poppy", "blue_orchid", "torchflower", "lily_of_the_valley", "cornflower", "allium", "azure bluet"]

Translucent_Materials = ["leaves"]
Translucent_Materials = ["leaves", "glass"]

Metal = ["iron", "gold", "copper", "diamond", "netherite", "minecart", "lantern", "chain", "anvil", "clock", "cauldron", "spyglass", "rail"]

Expand Down
24 changes: 12 additions & 12 deletions Mcblend Source/Materials/Materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def fix_world():
if bfc_node == None:
if "Backface Culling" not in bpy.data.node_groups:
try:
with bpy.data.libraries.load(materials_file_path, link=False) as (data_from, data_to):
with bpy.data.libraries.load(nodes_file, link=False) as (data_from, data_to):
data_to.node_groups = ["Backface Culling"]
except:
Absolute_Solver("004", "Materials", traceback.format_exc())
Expand Down Expand Up @@ -219,7 +219,7 @@ def fix_world():
if lbcf_node == None:
if "Lazy Biome Color Fix" not in bpy.data.node_groups:
try:
with bpy.data.libraries.load(materials_file_path, link=False) as (data_from, data_to):
with bpy.data.libraries.load(nodes_file, link=False) as (data_from, data_to):
data_to.node_groups = ["Lazy Biome Color Fix"]
except:
Absolute_Solver("004", "Materials", traceback.format_exc())
Expand Down Expand Up @@ -293,7 +293,7 @@ def create_env(self=None):
bpy.data.node_groups.remove(group)

try:
with bpy.data.libraries.load(materials_file_path, link=False) as (data_from, data_to):
with bpy.data.libraries.load(nodes_file, link=False) as (data_from, data_to):
data_to.worlds = [world_material_name]
appended_world_material = bpy.data.worlds.get(world_material_name)
bpy.context.scene.world = appended_world_material
Expand Down Expand Up @@ -368,7 +368,7 @@ def create_env(self=None):
if scene.env_properties.create_sky:
try:
if world_material_name not in bpy.data.worlds:
with bpy.data.libraries.load(materials_file_path, link=False) as (data_from, data_to):
with bpy.data.libraries.load(nodes_file, link=False) as (data_from, data_to):
data_to.worlds = [world_material_name]
appended_world_material = bpy.data.worlds.get(world_material_name)
else:
Expand Down Expand Up @@ -550,10 +550,10 @@ def animate_texture(texture_node, image_texture, new_image_texture_path, ITextur
ITexture_Animator.node_tree = Current_node_tree
else:
if "Texture Animator" not in bpy.data.node_groups:
with bpy.data.libraries.load(materials_file_path, link=False) as (data_from, data_to):
with bpy.data.libraries.load(nodes_file, link=False) as (data_from, data_to):
data_to.node_groups = ["Texture Animator"]

with bpy.data.libraries.load(materials_file_path, link=False) as (data_from, data_to):
with bpy.data.libraries.load(nodes_file, link=False) as (data_from, data_to):
data_to.node_groups = ["Texture Animator"]

bpy.data.node_groups[f"Texture Animator.001"].name = f"Animated; {image_texture.replace('.png', '')}"
Expand Down Expand Up @@ -595,7 +595,7 @@ def animate_texture(texture_node, image_texture, new_image_texture_path, ITextur
if Texture_Animator is None:
if "Texture Animator" not in bpy.data.node_groups:
try:
with bpy.data.libraries.load(materials_file_path, link=False) as (data_from, data_to):
with bpy.data.libraries.load(nodes_file, link=False) as (data_from, data_to):
data_to.node_groups = ["Texture Animator"]
except:
Absolute_Solver("004", "Materials", traceback.format_exc())
Expand Down Expand Up @@ -848,7 +848,7 @@ def animate_texture(texture_node, image_texture, new_image_texture_path, ITextur

if LabPBR_s == None:
if "LabPBR Specular" not in bpy.data.node_groups:
with bpy.data.libraries.load(materials_file_path, link=False) as (data_from, data_to):
with bpy.data.libraries.load(nodes_file, link=False) as (data_from, data_to):
data_to.node_groups = ["LabPBR Specular"]

LabPBR_s = material.node_tree.nodes.new("ShaderNodeGroup")
Expand Down Expand Up @@ -1073,7 +1073,7 @@ def setproceduralpbr():
PNormals.location = (PBSDF.location.x - 200, PBSDF.location.y - 132)

else:
with bpy.data.libraries.load(materials_file_path, link=False) as (data_from, data_to):
with bpy.data.libraries.load(nodes_file, link=False) as (data_from, data_to):
data_to.node_groups = ["PNormals"]

PNormals = material.node_tree.nodes.new(type='ShaderNodeGroup')
Expand Down Expand Up @@ -1190,7 +1190,7 @@ def setproceduralpbr():
# BATGroup Import if BATGroup isn't in File
if node_group == None:
if BATGroup not in bpy.data.node_groups:
with bpy.data.libraries.load(materials_file_path, link=False) as (data_from, data_to):
with bpy.data.libraries.load(nodes_file, link=False) as (data_from, data_to):
data_to.node_groups = [BATGroup]

node_group = material.node_tree.nodes.new(type='ShaderNodeGroup')
Expand Down Expand Up @@ -1257,7 +1257,7 @@ def setproceduralpbr():
material.node_tree.links.new(GetConnectedSocketTo("Base Color", PBSDF), proughness_node.inputs["Value"])
material.node_tree.links.new(proughness_node.outputs[0], PBSDF.inputs["Roughness"])

elif PProperties.revert_proughness and proughness_node != None:
elif PProperties.pr_revert and proughness_node != None:
material.node_tree.nodes.remove(proughness_node)

if PProperties.pspecular:
Expand All @@ -1276,7 +1276,7 @@ def setproceduralpbr():
material.node_tree.links.new(GetConnectedSocketTo("Base Color", PBSDF), pspecular_node.inputs["Value"])
material.node_tree.links.new(pspecular_node.outputs[0], PBSDF.inputs[PBSDF_compability("Specular IOR Level")])

elif PProperties.revert_pspecular and pspecular_node != None:
elif PProperties.ps_revert and pspecular_node != None:
material.node_tree.nodes.remove(pspecular_node)

else:
Expand Down
File renamed without changes.
51 changes: 26 additions & 25 deletions Mcblend Source/Properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,26 +241,12 @@ class PPBRProperties(PropertyGroup):
description=""
)

revert_pspecular: BoolProperty(
name="Revert",
default=True,
description=""
)

pspecular_settings: BoolProperty(
name="Procedural Specular Settings",
default=False,
description=""
)

ps_dif: FloatProperty(
name="Difference",
default=0.0,
min=0.0,
max=1.0,
description="Value 1 will be Ignored"
)

ps_interpolation: EnumProperty(
items=[('LINEAR', 'Linear', ''),
('SMOOTHSTEP', 'Smooth Step', ''),
Expand All @@ -269,14 +255,23 @@ class PPBRProperties(PropertyGroup):
default='LINEAR'
)

proughness: BoolProperty(
name="Procedural Roughness",
ps_dif: FloatProperty(
name="Difference",
default=0.0,
min=0.0,
max=1.0,
description="Value 1 will be Ignored"
)

ps_revert: BoolProperty(
name="Revert",
default=True,
description=""
)


revert_proughness: BoolProperty(
name="Revert",
proughness: BoolProperty(
name="Procedural Roughness",
default=True,
description=""
)
Expand All @@ -287,20 +282,26 @@ class PPBRProperties(PropertyGroup):
description=""
)

pr_interpolation: EnumProperty(
items=[('LINEAR', 'Linear', ''),
('SMOOTHSTEP', 'Smooth Step', ''),
('SMOOTHERSTEP', 'Smoother Step', '')],
name="Interpolation",
default='LINEAR'
)

pr_dif: FloatProperty(
name="Difference",
default=0.6,
min=0.0,
max=1.0,
description="Value 1 will be Ignored"
)

pr_interpolation: EnumProperty(
items=[('LINEAR', 'Linear', ''),
('SMOOTHSTEP', 'Smooth Step', ''),
('SMOOTHERSTEP', 'Smoother Step', '')],
name="Interpolation",
default='LINEAR'

pr_revert: BoolProperty(
name="Revert",
default=True,
description=""
)

advanced_settings: BoolProperty(
Expand Down
6 changes: 6 additions & 0 deletions Mcblend Source/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,9 @@ def draw(self, context):

row = sbox.row()
row.prop(scene.ppbr_properties, "ps_dif")

row = sbox.row()
row.prop(scene.ppbr_properties, "ps_revert")

row = box.row()
row.prop(scene.ppbr_properties, "proughness")
Expand All @@ -664,6 +667,9 @@ def draw(self, context):
row = sbox.row()
row.prop(scene.ppbr_properties, "pr_dif")

row = sbox.row()
row.prop(scene.ppbr_properties, "pr_revert")

row = box.row()
row.prop(scene.ppbr_properties, "advanced_settings", toggle=True, text="Advanced Settings", icon=("TRIA_DOWN" if scene.ppbr_properties.advanced_settings else "TRIA_RIGHT"))
if scene.ppbr_properties.advanced_settings:
Expand Down

0 comments on commit 9f0afeb

Please sign in to comment.