import bpy, mathutils mat = bpy.data.materials.new(name = "Wood.001") mat.use_nodes = True #initialize Wood.001 node group def wood_001_node_group(): wood_001 = mat.node_tree #start with a clean node tree for node in wood_001.nodes: wood_001.nodes.remove(node) wood_001.color_tag = 'NONE' wood_001.description = "" wood_001.default_group_node_width = 140 #wood_001 interface #initialize wood_001 nodes #node Musgrave Texture.001 musgrave_texture_001 = wood_001.nodes.new("ShaderNodeTexNoise") musgrave_texture_001.name = "Musgrave Texture.001" musgrave_texture_001.noise_dimensions = '3D' musgrave_texture_001.noise_type = 'FBM' musgrave_texture_001.normalize = False #W musgrave_texture_001.inputs[1].default_value = 0.0 #Scale musgrave_texture_001.inputs[2].default_value = 5.0 #Detail musgrave_texture_001.inputs[3].default_value = 1.0 #Roughness musgrave_texture_001.inputs[4].default_value = 0.25 #Lacunarity musgrave_texture_001.inputs[5].default_value = 2.0 #Offset musgrave_texture_001.inputs[6].default_value = 0.0 #Gain musgrave_texture_001.inputs[7].default_value = 1.0 #Distortion musgrave_texture_001.inputs[8].default_value = 0.0 #node Mapping mapping = wood_001.nodes.new("ShaderNodeMapping") mapping.name = "Mapping" mapping.vector_type = 'POINT' #Location mapping.inputs[1].default_value = (0.0, 0.0, 0.0) #Rotation mapping.inputs[2].default_value = (0.0, 0.0, 0.0) #Scale mapping.inputs[3].default_value = (0.10000000149011612, 1.0, 1.0) #node Texture Coordinate texture_coordinate = wood_001.nodes.new("ShaderNodeTexCoord") texture_coordinate.name = "Texture Coordinate" texture_coordinate.from_instancer = False #node Musgrave Texture musgrave_texture = wood_001.nodes.new("ShaderNodeTexNoise") musgrave_texture.name = "Musgrave Texture" musgrave_texture.noise_dimensions = '3D' musgrave_texture.noise_type = 'FBM' musgrave_texture.normalize = False #W musgrave_texture.inputs[1].default_value = 0.0 #Scale musgrave_texture.inputs[2].default_value = 50.0 #Detail musgrave_texture.inputs[3].default_value = 1.0 #Roughness musgrave_texture.inputs[4].default_value = 0.25 #Lacunarity musgrave_texture.inputs[5].default_value = 2.0 #Offset musgrave_texture.inputs[6].default_value = 0.0 #Gain musgrave_texture.inputs[7].default_value = 1.0 #Distortion musgrave_texture.inputs[8].default_value = 0.0 #node Noise Texture noise_texture = wood_001.nodes.new("ShaderNodeTexNoise") noise_texture.name = "Noise Texture" noise_texture.noise_dimensions = '3D' noise_texture.noise_type = 'FBM' noise_texture.normalize = True #Vector noise_texture.inputs[0].default_value = (0.0, 0.0, 0.0) #W noise_texture.inputs[1].default_value = 0.0 #Scale noise_texture.inputs[2].default_value = 5.0 #Detail noise_texture.inputs[3].default_value = 16.0 #Roughness noise_texture.inputs[4].default_value = 1.0 #Lacunarity noise_texture.inputs[5].default_value = 2.0 #Offset noise_texture.inputs[6].default_value = 0.0 #Gain noise_texture.inputs[7].default_value = 1.0 #Distortion noise_texture.inputs[8].default_value = 0.0 #node Mix mix = wood_001.nodes.new("ShaderNodeMix") mix.name = "Mix" mix.blend_type = 'MIX' mix.clamp_factor = True mix.clamp_result = False mix.data_type = 'RGBA' mix.factor_mode = 'UNIFORM' #Factor_Float mix.inputs[0].default_value = 0.5 #Factor_Vector mix.inputs[1].default_value = (0.5, 0.5, 0.5) #A_Float mix.inputs[2].default_value = 0.0 #B_Float mix.inputs[3].default_value = 0.0 #A_Vector mix.inputs[4].default_value = (0.0, 0.0, 0.0) #B_Vector mix.inputs[5].default_value = (0.0, 0.0, 0.0) #A_Rotation mix.inputs[8].default_value = (0.0, 0.0, 0.0) #B_Rotation mix.inputs[9].default_value = (0.0, 0.0, 0.0) #node ColorRamp colorramp = wood_001.nodes.new("ShaderNodeValToRGB") colorramp.name = "ColorRamp" colorramp.color_ramp.color_mode = 'RGB' colorramp.color_ramp.hue_interpolation = 'NEAR' colorramp.color_ramp.interpolation = 'LINEAR' #initialize color ramp elements colorramp.color_ramp.elements.remove(colorramp.color_ramp.elements[0]) colorramp_cre_0 = colorramp.color_ramp.elements[0] colorramp_cre_0.position = 0.0 colorramp_cre_0.alpha = 1.0 colorramp_cre_0.color = (1.0, 0.4306367337703705, 0.12983587384223938, 1.0) colorramp_cre_1 = colorramp.color_ramp.elements.new(0.3227273225784302) colorramp_cre_1.alpha = 1.0 colorramp_cre_1.color = (0.0, 0.0, 0.0, 1.0) colorramp_cre_2 = colorramp.color_ramp.elements.new(0.5227271318435669) colorramp_cre_2.alpha = 1.0 colorramp_cre_2.color = (0.15588904917240143, 0.03536082059144974, 0.010269050486385822, 1.0) #node Material Output material_output = wood_001.nodes.new("ShaderNodeOutputMaterial") material_output.name = "Material Output" material_output.is_active_output = True material_output.target = 'ALL' #Displacement material_output.inputs[2].default_value = (0.0, 0.0, 0.0) #Thickness material_output.inputs[3].default_value = 0.0 #node Principled BSDF principled_bsdf = wood_001.nodes.new("ShaderNodeBsdfPrincipled") principled_bsdf.name = "Principled BSDF" principled_bsdf.distribution = 'GGX' principled_bsdf.subsurface_method = 'RANDOM_WALK_SKIN' #Metallic principled_bsdf.inputs[1].default_value = 0.0 #IOR principled_bsdf.inputs[3].default_value = 1.4500000476837158 #Alpha principled_bsdf.inputs[4].default_value = 1.0 #Weight principled_bsdf.inputs[6].default_value = 0.0 #Diffuse Roughness principled_bsdf.inputs[7].default_value = 0.0 #Subsurface Weight principled_bsdf.inputs[8].default_value = 0.0 #Subsurface Radius principled_bsdf.inputs[9].default_value = (1.0, 0.20000000298023224, 0.10000000149011612) #Subsurface Scale principled_bsdf.inputs[10].default_value = 0.05000000074505806 #Subsurface IOR principled_bsdf.inputs[11].default_value = 1.399999976158142 #Subsurface Anisotropy principled_bsdf.inputs[12].default_value = 0.0 #Specular IOR Level principled_bsdf.inputs[13].default_value = 0.5 #Specular Tint principled_bsdf.inputs[14].default_value = (1.0, 1.0, 1.0, 1.0) #Anisotropic principled_bsdf.inputs[15].default_value = 0.0 #Anisotropic Rotation principled_bsdf.inputs[16].default_value = 0.0 #Tangent principled_bsdf.inputs[17].default_value = (0.0, 0.0, 0.0) #Transmission Weight principled_bsdf.inputs[18].default_value = 0.0 #Coat Weight principled_bsdf.inputs[19].default_value = 0.0 #Coat Roughness principled_bsdf.inputs[20].default_value = 0.029999999329447746 #Coat IOR principled_bsdf.inputs[21].default_value = 1.5 #Coat Tint principled_bsdf.inputs[22].default_value = (1.0, 1.0, 1.0, 1.0) #Coat Normal principled_bsdf.inputs[23].default_value = (0.0, 0.0, 0.0) #Sheen Weight principled_bsdf.inputs[24].default_value = 0.0 #Sheen Roughness principled_bsdf.inputs[25].default_value = 0.5 #Sheen Tint principled_bsdf.inputs[26].default_value = (1.0, 1.0, 1.0, 1.0) #Emission Color principled_bsdf.inputs[27].default_value = (0.0, 0.0, 0.0, 1.0) #Emission Strength principled_bsdf.inputs[28].default_value = 1.0 #Thin Film Thickness principled_bsdf.inputs[29].default_value = 0.0 #Thin Film IOR principled_bsdf.inputs[30].default_value = 1.3300000429153442 #node ColorRamp.002 colorramp_002 = wood_001.nodes.new("ShaderNodeValToRGB") colorramp_002.name = "ColorRamp.002" colorramp_002.color_ramp.color_mode = 'RGB' colorramp_002.color_ramp.hue_interpolation = 'NEAR' colorramp_002.color_ramp.interpolation = 'LINEAR' #initialize color ramp elements colorramp_002.color_ramp.elements.remove(colorramp_002.color_ramp.elements[0]) colorramp_002_cre_0 = colorramp_002.color_ramp.elements[0] colorramp_002_cre_0.position = 0.22272707521915436 colorramp_002_cre_0.alpha = 1.0 colorramp_002_cre_0.color = (0.1662798523902893, 0.1662798523902893, 0.1662798523902893, 1.0) colorramp_002_cre_1 = colorramp_002.color_ramp.elements.new(0.3681822419166565) colorramp_002_cre_1.alpha = 1.0 colorramp_002_cre_1.color = (1.0, 1.0, 1.0, 1.0) #node Bump bump = wood_001.nodes.new("ShaderNodeBump") bump.name = "Bump" bump.invert = False #Strength bump.inputs[0].default_value = 0.10000000149011612 #Distance bump.inputs[1].default_value = 1.0 #Normal bump.inputs[3].default_value = (0.0, 0.0, 0.0) #Set locations musgrave_texture_001.location = (-6.902099609375, 241.80926513671875) mapping.location = (-195.26602172851562, 261.11572265625) texture_coordinate.location = (-395.26654052734375, 213.25885009765625) musgrave_texture.location = (188.85498046875, 244.064453125) noise_texture.location = (192.729248046875, 13.096694946289062) mix.location = (425.0, 180.56295776367188) colorramp.location = (633.5625, 141.04071044921875) material_output.location = (1598.4180908203125, 341.356689453125) principled_bsdf.location = (1308.418212890625, 341.356689453125) colorramp_002.location = (1023.76318359375, 118.6533203125) bump.location = (1038.65625, -220.26556396484375) #Set dimensions musgrave_texture_001.width, musgrave_texture_001.height = 150.0, 100.0 mapping.width, mapping.height = 140.0, 100.0 texture_coordinate.width, texture_coordinate.height = 140.0, 100.0 musgrave_texture.width, musgrave_texture.height = 150.0, 100.0 noise_texture.width, noise_texture.height = 140.0, 100.0 mix.width, mix.height = 140.0, 100.0 colorramp.width, colorramp.height = 240.0, 100.0 material_output.width, material_output.height = 140.0, 100.0 principled_bsdf.width, principled_bsdf.height = 240.0, 100.0 colorramp_002.width, colorramp_002.height = 240.0, 100.0 bump.width, bump.height = 140.0, 100.0 #initialize wood_001 links #principled_bsdf.BSDF -> material_output.Surface wood_001.links.new(principled_bsdf.outputs[0], material_output.inputs[0]) #musgrave_texture_001.Fac -> musgrave_texture.Vector wood_001.links.new(musgrave_texture_001.outputs[0], musgrave_texture.inputs[0]) #texture_coordinate.UV -> mapping.Vector wood_001.links.new(texture_coordinate.outputs[2], mapping.inputs[0]) #mapping.Vector -> musgrave_texture_001.Vector wood_001.links.new(mapping.outputs[0], musgrave_texture_001.inputs[0]) #mix.Result -> colorramp.Fac wood_001.links.new(mix.outputs[2], colorramp.inputs[0]) #musgrave_texture.Fac -> mix.A wood_001.links.new(musgrave_texture.outputs[0], mix.inputs[6]) #noise_texture.Fac -> mix.B wood_001.links.new(noise_texture.outputs[0], mix.inputs[7]) #colorramp.Color -> principled_bsdf.Base Color wood_001.links.new(colorramp.outputs[0], principled_bsdf.inputs[0]) #colorramp.Color -> colorramp_002.Fac wood_001.links.new(colorramp.outputs[0], colorramp_002.inputs[0]) #colorramp_002.Color -> principled_bsdf.Roughness wood_001.links.new(colorramp_002.outputs[0], principled_bsdf.inputs[2]) #colorramp.Color -> bump.Height wood_001.links.new(colorramp.outputs[0], bump.inputs[2]) #bump.Normal -> principled_bsdf.Normal wood_001.links.new(bump.outputs[0], principled_bsdf.inputs[5]) return wood_001 wood_001 = wood_001_node_group()