From 3acddce7667c80e3c86a29d412d954190cd54dce Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sat, 19 Sep 2015 13:36:46 -0700 Subject: [PATCH] Material fixes --- DataSpec/Blender/RetroMasterShader.py | 33 +++++++++++++++++++-------- DataSpec/DNAMP3/CMDLMaterials.cpp | 19 ++++++++++++--- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/DataSpec/Blender/RetroMasterShader.py b/DataSpec/Blender/RetroMasterShader.py index 2a2d5ebfb..ce2a52613 100644 --- a/DataSpec/Blender/RetroMasterShader.py +++ b/DataSpec/Blender/RetroMasterShader.py @@ -567,9 +567,17 @@ def make_pass_tran(): grp_out = new_grp.nodes.new('NodeGroupOutput') grp_out.location = (0, 0) + # Multiply + mul1 = new_grp.nodes.new('ShaderNodeMath') + mul1.operation = 'MULTIPLY' + mul1.inputs[0].default_value = 1.0 + mul1.location = (-400, 0) + # Links new_grp.links.new(grp_in.outputs[0], grp_out.inputs[0]) - new_grp.links.new(grp_in.outputs[2], grp_out.inputs[1]) + new_grp.links.new(grp_in.outputs[1], mul1.inputs[0]) + new_grp.links.new(grp_in.outputs[2], mul1.inputs[1]) + new_grp.links.new(mul1.outputs[0], grp_out.inputs[1]) # Opacity Map Inverted def make_pass_tran_inv(): @@ -590,16 +598,23 @@ def make_pass_tran_inv(): grp_out = new_grp.nodes.new('NodeGroupOutput') grp_out.location = (0, 0) - # Subtract - sub1 = new_grp.nodes.new('ShaderNodeMath') - sub1.operation = 'SUBTRACT' - sub1.inputs[0].default_value = 1.0 - sub1.location = (-400, 0) + # Multiply + mul1 = new_grp.nodes.new('ShaderNodeMath') + mul1.operation = 'MULTIPLY' + mul1.inputs[0].default_value = 1.0 + mul1.location = (-400, 0) + + # Invert + inv1 = new_grp.nodes.new('ShaderNodeInvert') + inv1.inputs[0].default_value = 1.0 + inv1.location = (-600, 0) # Links - new_grp.links.new(grp_in.outputs[0], sub1.inputs[1]) - new_grp.links.new(sub1.outputs[0], grp_out.inputs[0]) - new_grp.links.new(grp_in.outputs[2], grp_out.inputs[1]) + new_grp.links.new(grp_in.outputs[0], grp_out.inputs[0]) + new_grp.links.new(grp_in.outputs[1], mul1.inputs[1]) + new_grp.links.new(grp_in.outputs[2], inv1.inputs[1]) + new_grp.links.new(inv1.outputs[0], mul1.inputs[0]) + new_grp.links.new(mul1.outputs[0], grp_out.inputs[1]) # Incandescence Map def make_pass_inca(): diff --git a/DataSpec/DNAMP3/CMDLMaterials.cpp b/DataSpec/DNAMP3/CMDLMaterials.cpp index f07c6eb54..fff2c24fd 100644 --- a/DataSpec/DNAMP3/CMDLMaterials.cpp +++ b/DataSpec/DNAMP3/CMDLMaterials.cpp @@ -89,7 +89,9 @@ void MaterialSet::ConstructMaterial(Stream& out, for (const Material::SectionFactory& factory : material.sections) { factory.section->constructNode(out, pakRouter, entry, prevSection, i++, texMapIdx, texMtxIdx, kColorIdx); - prevSection = factory.section.get(); + Material::SectionPASS* pass = dynamic_cast(factory.section.get()); + if (!pass || (pass && pass->subtype.toUint32() != Material::SectionPASS::RFLV)) + prevSection = factory.section.get(); } /* Connect final PASS */ @@ -161,22 +163,33 @@ void Material::SectionPASS::constructNode(HECL::BlenderConnection::PyOutStream& { case DIFF: out << "pnode.node_tree = bpy.data.node_groups['RetroPassDIFF']\n"; + linkRAS = true; break; case RIML: out << "pnode.node_tree = bpy.data.node_groups['RetroPassRIML']\n"; + if (idx == 0) + linkRAS = true; break; case BLOL: out << "pnode.node_tree = bpy.data.node_groups['RetroPassBLOL']\n"; + if (idx == 0) + linkRAS = true; break; case BLOD: out << "pnode.node_tree = bpy.data.node_groups['RetroPassBLOD']\n"; + if (idx == 0) + linkRAS = true; break; case CLR: out << "pnode.node_tree = bpy.data.node_groups['RetroPassCLR']\n"; - linkRAS = true; + if (idx == 0) + linkRAS = true; break; case TRAN: - out << "pnode.node_tree = bpy.data.node_groups['RetroPassTRAN']\n"; + if (flags.TRANInvert()) + out << "pnode.node_tree = bpy.data.node_groups['RetroPassTRANInv']\n"; + else + out << "pnode.node_tree = bpy.data.node_groups['RetroPassTRAN']\n"; break; case INCA: out << "pnode.node_tree = bpy.data.node_groups['RetroPassINCA']\n";