MP3 Material updates

This commit is contained in:
Jack Andersen 2015-09-18 21:08:01 -10:00
parent 872e2d4d52
commit e431f96f5d
3 changed files with 59 additions and 33 deletions

View File

@ -12,8 +12,6 @@ namespace Blender
bool BuildMasterShader(const HECL::ProjectPath& path) bool BuildMasterShader(const HECL::ProjectPath& path)
{ {
if (path.getPathType() == HECL::ProjectPath::PT_FILE)
return true;
HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection(); HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection();
if (!conn.createBlend(path.getAbsolutePath())) if (!conn.createBlend(path.getAbsolutePath()))
return false; return false;

View File

@ -536,8 +536,16 @@ def make_pass_clr():
grp_out = new_grp.nodes.new('NodeGroupOutput') grp_out = new_grp.nodes.new('NodeGroupOutput')
grp_out.location = (0, 0) grp_out.location = (0, 0)
# Multiply
mult1 = new_grp.nodes.new('ShaderNodeMixRGB')
mult1.blend_type = 'MULTIPLY'
mult1.inputs[0].default_value = 1.0
grp_in.location = (-400, 0)
# Links # Links
new_grp.links.new(grp_in.outputs[2], grp_out.inputs[0]) new_grp.links.new(grp_in.outputs[0], mult1.inputs[1])
new_grp.links.new(grp_in.outputs[2], mult1.inputs[2])
new_grp.links.new(mult1.outputs[0], grp_out.inputs[0])
grp_out.inputs[1].default_value = 1.0 grp_out.inputs[1].default_value = 1.0
# Opacity Map # Opacity Map
@ -612,38 +620,25 @@ def make_pass_inca():
grp_out = new_grp.nodes.new('NodeGroupOutput') grp_out = new_grp.nodes.new('NodeGroupOutput')
grp_out.location = (0, 0) grp_out.location = (0, 0)
# Links # Multiply
new_grp.links.new(grp_in.outputs[0], grp_out.inputs[0]) add1 = new_grp.nodes.new('ShaderNodeMixRGB')
new_grp.links.new(grp_in.outputs[1], grp_out.inputs[1]) add1.blend_type = 'ADD'
add1.inputs[0].default_value = 1.0
# Reflectivity Map grp_in.location = (-400, 0)
def make_pass_rflv():
new_grp = bpy.data.node_groups.new('RetroPassRFLV', 'ShaderNodeTree')
new_grp.inputs.new('NodeSocketColor', 'Prev Color')
new_grp.inputs.new('NodeSocketFloat', 'Prev Alpha')
new_grp.inputs.new('NodeSocketColor', 'Tex Color')
new_grp.inputs.new('NodeSocketFloat', 'Tex Alpha')
new_grp.outputs.new('NodeSocketColor', 'Next Color')
new_grp.outputs.new('NodeSocketFloat', 'Next Alpha')
new_grp.use_fake_user = True
# Group inputs
grp_in = new_grp.nodes.new('NodeGroupInput')
grp_in.location = (-800, 0)
# Group outputs
grp_out = new_grp.nodes.new('NodeGroupOutput')
grp_out.location = (0, 0)
# Links # Links
new_grp.links.new(grp_in.outputs[0], grp_out.inputs[0]) new_grp.links.new(grp_in.outputs[0], add1.inputs[1])
new_grp.links.new(grp_in.outputs[1], grp_out.inputs[1]) new_grp.links.new(grp_in.outputs[2], add1.inputs[2])
new_grp.links.new(add1.outputs[0], grp_out.inputs[0])
grp_out.inputs[1].default_value = 1.0
# Reflection Map # Reflection Map
def make_pass_rfld(): def make_pass_rfld():
new_grp = bpy.data.node_groups.new('RetroPassRFLD', 'ShaderNodeTree') new_grp = bpy.data.node_groups.new('RetroPassRFLD', 'ShaderNodeTree')
new_grp.inputs.new('NodeSocketColor', 'Prev Color') new_grp.inputs.new('NodeSocketColor', 'Prev Color')
new_grp.inputs.new('NodeSocketFloat', 'Prev Alpha') new_grp.inputs.new('NodeSocketFloat', 'Prev Alpha')
new_grp.inputs.new('NodeSocketColor', 'Mask Color')
new_grp.inputs.new('NodeSocketFloat', 'Mask Alpha')
new_grp.inputs.new('NodeSocketColor', 'Tex Color') new_grp.inputs.new('NodeSocketColor', 'Tex Color')
new_grp.inputs.new('NodeSocketFloat', 'Tex Alpha') new_grp.inputs.new('NodeSocketFloat', 'Tex Alpha')
new_grp.outputs.new('NodeSocketColor', 'Next Color') new_grp.outputs.new('NodeSocketColor', 'Next Color')
@ -658,8 +653,24 @@ def make_pass_rfld():
grp_out = new_grp.nodes.new('NodeGroupOutput') grp_out = new_grp.nodes.new('NodeGroupOutput')
grp_out.location = (0, 0) grp_out.location = (0, 0)
# Multiply
mult1 = new_grp.nodes.new('ShaderNodeMixRGB')
mult1.location = (-600, 0)
mult1.blend_type = 'MULTIPLY'
mult1.inputs[0].default_value = 1.0
# Add
add1 = new_grp.nodes.new('ShaderNodeMixRGB')
add1.location = (-400, 0)
add1.blend_type = 'ADD'
add1.inputs[0].default_value = 1.0
# Links # Links
new_grp.links.new(grp_in.outputs[0], grp_out.inputs[0]) new_grp.links.new(grp_in.outputs[0], add1.inputs[1])
new_grp.links.new(grp_in.outputs[2], mult1.inputs[1])
new_grp.links.new(grp_in.outputs[4], mult1.inputs[2])
new_grp.links.new(mult1.outputs[0], add1.inputs[2])
new_grp.links.new(add1.outputs[0], grp_out.inputs[0])
new_grp.links.new(grp_in.outputs[1], grp_out.inputs[1]) new_grp.links.new(grp_in.outputs[1], grp_out.inputs[1])
# Unk1 # Unk1
@ -786,7 +797,6 @@ MP3_PASS_GROUPS = (
make_pass_tran, make_pass_tran,
make_pass_tran_inv, make_pass_tran_inv,
make_pass_inca, make_pass_inca,
make_pass_rflv,
make_pass_rfld, make_pass_rfld,
make_pass_lrld, make_pass_lrld,
make_pass_lurd, make_pass_lurd,

View File

@ -77,7 +77,8 @@ void MaterialSet::ConstructMaterial(Stream& out,
/* Texmap list */ /* Texmap list */
out << "tex_maps = []\n" out << "tex_maps = []\n"
"pnode = None\n"; "pnode = None\n"
"rflv_tex_node = None\n";
/* Add PASSes */ /* Add PASSes */
i=0; i=0;
@ -137,14 +138,23 @@ void Material::SectionPASS::constructNode(HECL::BlenderConnection::PyOutStream&
if (uvAnim.size()) if (uvAnim.size())
{ {
const UVAnimation& uva = uvAnim[0]; const UVAnimation& uva = uvAnim[0];
DNAMP1::MaterialSet::Material::AddTexture(out, GX::TexGenSrc(uva.unk1 + (uva.unk1 < 2 ? 0 : 4)), -1, texMapIdx++); DNAMP1::MaterialSet::Material::AddTexture(out, GX::TexGenSrc(uva.unk1 + (uva.unk1 < 2 ? 0 : 2)), texMtxIdx, texMapIdx++);
DNAMP1::MaterialSet::Material::AddTextureAnim(out, uva.anim.mode, texMtxIdx++, uva.anim.vals); DNAMP1::MaterialSet::Material::AddTextureAnim(out, uva.anim.mode, texMtxIdx++, uva.anim.vals);
} }
else else
DNAMP1::MaterialSet::Material::AddTexture(out, GX::TexGenSrc(uvSrc + 4), -1, texMapIdx++); DNAMP1::MaterialSet::Material::AddTexture(out, GX::TexGenSrc(uvSrc + 4), -1, texMapIdx++);
} }
/* Special case for RFLV (environment UV mask) */
if (subtype.toUint32() == RFLV)
{
if (txtrId)
out << "rflv_tex_node = texture_nodes[-1]\n";
return;
}
/* Add PASS node */ /* Add PASS node */
bool linkRAS = false;
out << "prev_pnode = pnode\n" out << "prev_pnode = pnode\n"
"pnode = new_nodetree.nodes.new('ShaderNodeGroup')\n"; "pnode = new_nodetree.nodes.new('ShaderNodeGroup')\n";
switch (subtype) switch (subtype)
@ -163,6 +173,7 @@ void Material::SectionPASS::constructNode(HECL::BlenderConnection::PyOutStream&
break; break;
case CLR: case CLR:
out << "pnode.node_tree = bpy.data.node_groups['RetroPassCLR']\n"; out << "pnode.node_tree = bpy.data.node_groups['RetroPassCLR']\n";
linkRAS = true;
break; break;
case TRAN: case TRAN:
out << "pnode.node_tree = bpy.data.node_groups['RetroPassTRAN']\n"; out << "pnode.node_tree = bpy.data.node_groups['RetroPassTRAN']\n";
@ -174,7 +185,10 @@ void Material::SectionPASS::constructNode(HECL::BlenderConnection::PyOutStream&
out << "pnode.node_tree = bpy.data.node_groups['RetroPassRFLV']\n"; out << "pnode.node_tree = bpy.data.node_groups['RetroPassRFLV']\n";
break; break;
case RFLD: case RFLD:
out << "pnode.node_tree = bpy.data.node_groups['RetroPassRFLD']\n"; out << "pnode.node_tree = bpy.data.node_groups['RetroPassRFLD']\n"
"if rflv_tex_node:\n"
" new_nodetree.links.new(rflv_tex_node.outputs['Color'], pnode.inputs['Mask Color'])\n"
" new_nodetree.links.new(rflv_tex_node.outputs['Value'], pnode.inputs['Mask Alpha'])\n";
break; break;
case LRLD: case LRLD:
out << "pnode.node_tree = bpy.data.node_groups['RetroPassLRLD']\n"; out << "pnode.node_tree = bpy.data.node_groups['RetroPassLRLD']\n";
@ -201,7 +215,10 @@ void Material::SectionPASS::constructNode(HECL::BlenderConnection::PyOutStream&
"new_nodetree.links.new(texture_nodes[-1].outputs['Value'], pnode.inputs['Tex Alpha'])\n"; "new_nodetree.links.new(texture_nodes[-1].outputs['Value'], pnode.inputs['Tex Alpha'])\n";
} }
if (prevSection) if (linkRAS)
out << "new_nodetree.links.new(material_node.outputs['Color'], pnode.inputs['Prev Color'])\n"
"new_nodetree.links.new(material_node.outputs['Alpha'], pnode.inputs['Prev Alpha'])\n";
else if (prevSection)
{ {
if (prevSection->m_type == ISection::PASS) if (prevSection->m_type == ISection::PASS)
out << "new_nodetree.links.new(prev_pnode.outputs['Next Color'], pnode.inputs['Prev Color'])\n" out << "new_nodetree.links.new(prev_pnode.outputs['Next Color'], pnode.inputs['Prev Color'])\n"
@ -211,6 +228,7 @@ void Material::SectionPASS::constructNode(HECL::BlenderConnection::PyOutStream&
"new_nodetree.links.new(kcolor_nodes[-1][1].outputs[0], pnode.inputs['Prev Alpha'])\n"; "new_nodetree.links.new(kcolor_nodes[-1][1].outputs[0], pnode.inputs['Prev Alpha'])\n";
} }
/* Row Break in gridder */ /* Row Break in gridder */
out << "gridder.row_break(2)\n"; out << "gridder.row_break(2)\n";
} }