Skip to content

Commit

Permalink
Fix PCB shader artifacts caused by smooth shading (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
30350n committed Jun 3, 2024
1 parent a5c31be commit 29c969f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pcb2blender_importer/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ def import_pcb3d(self, context, filepath):
if not (has_multiple_boards := bool(pcb.boards and self.cut_boards)):
name = f"PCB_{filepath.stem}"
pcb_object.name = pcb_object.data.name = name
add_smooth_by_angle_modifier(pcb_object)
if self.enhance_materials and self.pcb_material == "RASTERIZED":
pcb_object.data.materials[0].name = name

Expand All @@ -420,7 +419,6 @@ def import_pcb3d(self, context, filepath):
bpy.data.objects.remove(pcb_object)
for name, board in pcb.boards.items():
board_obj = bpy.data.objects.new(f"PCB_{name}", pcb_mesh.copy())
add_smooth_by_angle_modifier(board_obj)
context.collection.objects.link(board_obj)

cut_material_index = len(board_obj.material_slots) + 1
Expand Down Expand Up @@ -522,6 +520,9 @@ def import_pcb3d(self, context, filepath):

board.obj = board_obj

# fix smooth shading issues
bpy.ops.object.shade_smooth_by_angle(angle=radians(89), keep_sharp_edges=False)

related_objects = []

# populate components
Expand Down

0 comments on commit 29c969f

Please sign in to comment.