bnp.objects.shading

create_material(material_name="debug_material")

Create material in bpy.data.materials

Parameters:material_name (str) – name of the material
assign_material(obj, material)

Assign the input material to the object

Parameters:
  • obj (bpy.types.Object) – object in the scene
  • material (bpy.types.Material) – material in bpy.data.materials
create_shader(material)

Add a BSDF shader to the material

Parameters:material (bpy.types.Material) – material
add_pbr_textures(material, texture_paths, use_combined_metallic_roughness=True, metallic_channel=2, roughness_channel=1)

Add pbr textures to the material

Parameters:
  • material (bpy.types.Material) – material
  • texture_paths (dict) – absolute paths of textures. key: “albedo”, “normal”, “metallic”, “roughness”, “metallic_roughness”, “emissive” or “ao”.
  • use_combined_metallic_roughness (bool) – whether to use a texture combined with metallic and roughness
  • metallic_channel (int) – metallic channel of the combined texture only used when use_combined_metallic_roughness == True
  • roughness_channel (int) – roughness channel of the combined texture only used when use_combined_metallic_roughness == True
add_albedo(material, albedo_path)

Add albedo texture to the material

Parameters:
  • material (bpy.types.Material) – material
  • albedo_path (str) – abosolute albedo texture path
add_normal(material, normal_path)

Add normal texture to the material

Parameters:
  • material (bpy.types.Material) – material
  • normal_path (str) – abosolute normal texture path
add_metallic(material, metallic_path)

Add metallic texture to the material

Parameters:
  • material (bpy.types.Material) – material
  • metallic_path (str) – abosolute metallic texture path
add_roughness(material, roughness_path)

Add roughness texture to the material

Parameters:
  • material (bpy.types.Material) – material
  • roughness_path (str) – absolute roughness texture path
add_metallic_roughness(material, metallic_roughness_path, metallic_channel=2, roughness_channel=1)

Add metalic and roughness textures to the material

Parameters:
  • material (bpy.types.Material) – material
  • metallic_roughness_path (str) – abosolute metalic and roughness texture path
  • metallic_channel (int) – metallic channel of the combined texture
  • roughness_channel (int) – roughness channel of the combined texture
add_emissive(material, emissive_path)

Add emissive texture to the material

Parameters:
  • material (bpy.types.Material) – material
  • emissive_path (str) – abosolute emissive texture path
add_ao(material, ao_path, fac=0.25)

Add AO (Ambient Occlusion) texture to the material

Parameters:
  • material (bpy.types.Material) – material
  • ao_path (str) – abosolute AO texture path
  • fac (float) – mixing ratio of ao (ambient occlusion) to albedo
set_envmap(filepath)

Set an environment map to the current world

Parameters:filepath (str) – environment map filepath