mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-07-06 10:25:53 +00:00
Emit material chunk if socket value differs from default
This commit is contained in:
parent
a441a3e7a0
commit
c98442de9a
@ -13,12 +13,14 @@ SHADER_TYPES = {
|
|||||||
PASS_TYPE = {
|
PASS_TYPE = {
|
||||||
'Lightmap': b'LMAP',
|
'Lightmap': b'LMAP',
|
||||||
'Diffuse': b'DIFF',
|
'Diffuse': b'DIFF',
|
||||||
|
'DiffuseMod': b'DIFM',
|
||||||
'Emissive': b'EMIS',
|
'Emissive': b'EMIS',
|
||||||
'Specular': b'SPEC',
|
'Specular': b'SPEC',
|
||||||
'ExtendedSpecular': b'ESPC',
|
'ExtendedSpecular': b'ESPC',
|
||||||
'Reflection': b'REFL',
|
'Reflection': b'REFL',
|
||||||
'IndirectTex': b'INDR',
|
'IndirectTex': b'INDR',
|
||||||
'Alpha': b'ALPH',
|
'Alpha': b'ALPH',
|
||||||
|
'AlphaMod': b'ALPM'
|
||||||
}
|
}
|
||||||
|
|
||||||
def write_chunks(writebuf, mat_obj, mesh_obj):
|
def write_chunks(writebuf, mat_obj, mesh_obj):
|
||||||
@ -37,7 +39,7 @@ def write_chunks(writebuf, mat_obj, mesh_obj):
|
|||||||
|
|
||||||
# Count sockets
|
# Count sockets
|
||||||
chunk_count = 0
|
chunk_count = 0
|
||||||
for inp in output_node.inputs:
|
for inp, def_inp in zip(output_node.inputs, output_node.node_tree.inputs):
|
||||||
if inp.name in PASS_TYPE:
|
if inp.name in PASS_TYPE:
|
||||||
if inp.is_linked:
|
if inp.is_linked:
|
||||||
chunk_count += 1
|
chunk_count += 1
|
||||||
@ -45,17 +47,17 @@ def write_chunks(writebuf, mat_obj, mesh_obj):
|
|||||||
# Color pass
|
# Color pass
|
||||||
color_set = False
|
color_set = False
|
||||||
if inp.type == 'VALUE':
|
if inp.type == 'VALUE':
|
||||||
color_set = bool(inp.default_value)
|
color_set = inp.default_value != def_inp.default_value
|
||||||
else:
|
else:
|
||||||
for comp in inp.default_value:
|
for comp, def_comp in zip(inp.default_value, def_inp.default_value):
|
||||||
color_set |= bool(comp)
|
color_set |= comp != def_comp
|
||||||
if color_set:
|
if color_set:
|
||||||
chunk_count += 1
|
chunk_count += 1
|
||||||
|
|
||||||
writebuf(struct.pack('I', chunk_count))
|
writebuf(struct.pack('I', chunk_count))
|
||||||
|
|
||||||
# Enumerate sockets
|
# Enumerate sockets
|
||||||
for inp in output_node.inputs:
|
for inp, def_inp in zip(output_node.inputs, output_node.node_tree.inputs):
|
||||||
if inp.name in PASS_TYPE:
|
if inp.name in PASS_TYPE:
|
||||||
pass_fourcc = PASS_TYPE[inp.name]
|
pass_fourcc = PASS_TYPE[inp.name]
|
||||||
if inp.is_linked:
|
if inp.is_linked:
|
||||||
@ -146,10 +148,10 @@ def write_chunks(writebuf, mat_obj, mesh_obj):
|
|||||||
# Color pass
|
# Color pass
|
||||||
color_set = False
|
color_set = False
|
||||||
if inp.type == 'VALUE':
|
if inp.type == 'VALUE':
|
||||||
color_set = bool(inp.default_value)
|
color_set = inp.default_value != def_inp.default_value
|
||||||
else:
|
else:
|
||||||
for comp in inp.default_value:
|
for comp, def_comp in zip(inp.default_value, def_inp.default_value):
|
||||||
color_set |= bool(comp)
|
color_set |= comp != def_comp
|
||||||
|
|
||||||
if color_set:
|
if color_set:
|
||||||
writebuf(b'CLR ')
|
writebuf(b'CLR ')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user