Created
February 2, 2022 19:22
-
-
Save chik4ge/bb136ee26ebc0f0329ad4893bb4363c7 to your computer and use it in GitHub Desktop.
Blender用 MineExporteR マテリアル変換スクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
#Layot screen to texture shading | |
for screen in bpy.data.screens: | |
for area in screen.areas: | |
if area.type == "VIEW_3D": | |
for space in area.spaces: | |
if space.type == "VIEW_3D": | |
space.shading.color_type = 'TEXTURE' | |
#create shader | |
for mat in bpy.data.materials: | |
mat.use_backface_culling = True | |
mat.blend_method = 'CLIP' | |
node_tex = None | |
node_BSDF = None | |
node_output = None | |
node_geometry = None | |
node_transparent = None | |
node_mix = None | |
if mat.use_nodes: | |
for node in mat.node_tree.nodes: | |
print(node.type) | |
if node.type == "TEX_IMAGE": | |
node_tex = node | |
node.interpolation = "Closest" | |
if node.type == "BSDF_PRINCIPLED": | |
node_BSDF = node | |
if node.type == "OUTPUT_MATERIAL": | |
node_output = node | |
if node.type == "NEW_GEOMETRY": | |
node_geometry = node | |
if node.type == "MIX_SHADER": | |
node_mix = node | |
if node.type == "BSDF_TRANSPARENT": | |
node_transparent = node | |
if node_tex is None: | |
node_tex = mat.node_tree.nodes.new("ShaderNodeTexImage") | |
node_tex.interpolation = "Closest" | |
if node_BSDF is None: | |
node_BSDF = mat.node_tree.nodes.new("ShaderNodeBsdfPrincipled") | |
if node_output is None: | |
node_output = mat.node_tree.nodes.new("ShaderNodeOutputMaterial") | |
if node_geometry is None: | |
node_geometry = mat.node_tree.nodes.new("ShaderNodeNewGeometry") | |
if node_transparent is None: | |
node_transparent = mat.node_tree.nodes.new("ShaderNodeBsdfTransparent") | |
if node_mix is None: | |
node_mix = mat.node_tree.nodes.new("ShaderNodeMixShader") | |
mat.node_tree.links.new(node_tex.outputs["Alpha"], node_BSDF.inputs[21]) | |
mat.node_tree.links.new(node_geometry.outputs["Backfacing"], node_mix.inputs[0]) | |
mat.node_tree.links.new(node_BSDF.outputs["BSDF"], node_mix.inputs[1]) | |
mat.node_tree.links.new(node_transparent.outputs["BSDF"], node_mix.inputs[2]) | |
mat.node_tree.links.new(node_mix.outputs["Shader"], node_output.inputs[0]) | |
node_tex.location = 0,0 | |
node_BSDF.location = 300,0 | |
node_geometry.location = 400,250 | |
node_transparent.location = 550,-100 | |
node_mix.location = 750, 0 | |
node_output.location = 950,0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment