def _variant_apply( val ):
nonlocal mat
- if isinstance( val, str ):
- return val
- else:
+ if isinstance( val, list ):
for shader_variant in val:
if shader_variant[0] == mat.cxr_data.shader:
return shader_variant[1]
+ return val[0][1]
+ else:
+ return val
# Find rootnodes
if node == None:
for node_idname in node_def:
for n in mat.node_tree.nodes:
- if n.bl_idname == node_idname:
+ if n.name == node_idname:
node_def = node_def[node_idname]
node = n
break
for link in node_def:
- if isinstance( node_def[link], dict ):
- inputt = node.inputs[link]
- inputt_def = node_def[link]
+ link_def = _variant_apply( node_def[link] )
+
+ if isinstance( link_def, dict ):
+ node_link = node.inputs[link]
- if inputt.is_linked:
+ if node_link.is_linked:
# look for definitions for the connected node type
- con = inputt.links[0].from_node
+ from_node = node_link.links[0].from_node
- for node_idname in inputt_def:
- if con.bl_idname == node_idname:
- con_def = inputt_def[ node_idname ]
- _graph_read( con_def, con, depth+1 )
+ node_name = from_node.name.split('.')[0]
+ if node_name in link_def:
+ from_node_def = link_def[ node_name ]
+
+ _graph_read( from_node_def, from_node, depth+1 )
- # No definition found! :(
+ # No definition! :(
# TODO: Make a warning for this?
else:
- if "default" in inputt_def:
- prop = _variant_apply( inputt_def['default'] )
- info[prop] = inputt.default_value
+ if "default" in link_def:
+ prop = _variant_apply( link_def['default'] )
+ info[prop] = node_link.default_value
else:
- prop = _variant_apply( node_def[link] )
- info[prop] = getattr(node,link)
+ prop = _variant_apply( link_def )
+ info[prop] = getattr( node, link )
_graph_read(cxr_graph_mapping)
"LightMappedGeneric": { "name": "Light Mapped" },
"VertexLitGeneric": { "name": "Vertex Lit" },
"UnlitGeneric": { "name": "Unlit" },
- "Builtin": { "name": "Builtin" }
+ "Builtin": { "name": "Builtin" },
+ "WorldVertexTransition": { "name": "Light Mapped Blend" }
}
# Shader graph mapping
def material_tex_image(v):
return {
- "ShaderNodeTexImage":
+ "Image Texture":
{
"image": F"${v}"
}
cxr_graph_mapping = \
{
- "ShaderNodeBsdfPrincipled":
+ # 'Special' shader for wvt
+ "cxr_blend":
+ {
+ "modulate": material_tex_image("blendmodulatetexture"),
+ "basetexture": material_tex_image("basetexture"),
+ "basetexture2": material_tex_image("basetexture2"),
+ "bumpmap": material_tex_image("bumpmap"),
+ "bumpmap2": material_tex_image("bumpmap2")
+ },
+
+ # Default shader setup
+ "Principled BSDF":
{
"Base Color":
{
- "ShaderNodeMixRGB":
+ "Mix":
{
"Color1": material_tex_image("basetexture"),
"Color2": material_tex_image("decaltexture")
},
- "ShaderNodeTexImage":
+ "Image Texture":
{
- "image":"$basetexture"
+ "image": "$basetexture"
},
"default":
[("VertexLitGeneric","$color2"),\
},
"Normal":
{
- "ShaderNodeNormalMap":
+ "Normal Map":
{
"Color": material_tex_image("bumpmap")
}
"Textures":
{
"type": "ui",
- "shaders": ("UnlitGeneric","VertexLitGeneric","LightMappedGeneric"),
+ "shaders": ("UnlitGeneric",\
+ "VertexLitGeneric",\
+ "LightMappedGeneric",\
+ "WorldVertexTransition"),
"$basetexture":
{
"type": "intrinsic",
"default": None
},
+ "$basetexture2":
+ {
+ "name": "Base Texture 2",
+ "type": "intrinsic",
+ "default": None
+ },
+ "$blendmodulatetexture":
+ {
+ "name": "Blend Modulate",
+ "type": "intrinsic",
+ "default": None
+ },
"$decaltexture":
{
"name": "Decal Texture",
"type": "intrinsic",
"flags": NBVTF_TEXTUREFLAGS_NORMAL, # OpenGL (correct) normal maps.
"default": None
+ },
+ "$bumpmap2":
+ {
+ "name": "Normal Map 2",
+ "type": "intrinsic",
+ "flags": NBVTF_TEXTUREFLAGS_NORMAL,
+ "default": None
}
},
"$color":
"Lighting":
{
"type": "ui",
- "shaders": ("VertexLitGeneric", "LightMappedGeneric"),
+ "shaders": ("VertexLitGeneric", "LightMappedGeneric", "WorldVertexTransition"),
"$phong":
{
"name": "Surface",
"type": "string",
"default": ""
+ },
+ "$surfaceprop2":
+ {
+ "shaders": ("WorldVertexTransition",),
+ "name": "Surface 2",
+ "type": "string",
+ "default": ""
}
}