Experimenting PCB rendering using KiCad, FreeCAD and Blender

by ANOOL MAHIDHARIA (@anool)

I’ve been putting off using Blender since over 5 years, being intimidated by the complex UI and workflow, until this month when I mustered courage to go through Andrew Price’s Doughnut tutorials. My aim was to learn how to do photo-realistic renders of KiCad boards.

Within a week of dipping my feet in the shallow end, I made these few renders.

Blender render #1
Blender render #2
Blender render #3
Blender render #4
Blender render #5

I started off with the Open Hardware Summit 2020 badge (which I had a bit role in designing). KiCad’s in-built ray-tracer does a decent job, but there is no way to adjust lighting, background and other parameters. This is what it looks like in KiCad.

Normal 3D view from KiCad
Ray traced render from KiCad – bottom side

This is the bottom of the PCB, so the “floor” is not visible, and the overall render looks darker than expected. 

Ray traced render from KiCad – top side

As a comparison, here’s what the top view looks like. You can see shadows on the floor. There are multiple light sources (multiple shadows), and the scene looks washed out due to excess light.

Unfortunately, KiCad raytrace option does not allow us to set lighting, floor and other scene parameters, hence Blender. So my next step was to export VRML and STEP file models from KiCad.

The STEP export from KiCad is useful in MCAD for designing enclosures and such, but it doesn’t have copper and silk layers, and no material textures too. So it isn’t much use for realistic renders.

STEP import in FreeCAD
VRML import in FreeCAD

One important difference between the raytrace render as seen in KiCad v/s the exported VRML is the “MASK” layer. Look at the “W” in the OSHW logo and the “qwiic” logo. In the KiCad design, there’s a mask opening over these elements so that the underlying Copper/Gold is visible in KiCad 3D. In the VRML export, this mask window gets covered over. So the VRML export from KiCad is not a faithful representation of the board.

I ran another test by using KiCad StepUp Tools workbench in FreeCAD to import the Board with parts and Copper + Silk layers. Once again, the result was the same – the mask openings do not show up as in the pic below.

KSU Tools import in FreeCAD with Copper and Silk

At this moment, I not sure how to resolve this – so anyone have suggestions, please comment away.

Anyway, next step was to move to Blender and try getting better renders. Here’s what the KiCad VRML import looks like in Blender.

VRML import in Blender

According to @maui in this thread on the KiCad forum, from Blender ver 2.8 onward, the WRL/X3D importer has been changed causing the lack of color/texture import.

Opening the KiCad VRML file in Meshlab produces expected results.

VRML import in Meshlab

A workaround to this that I stumbled upon is to use the online 3D file format converter at CADexchanger and convert the KiCad VRML file to Collada DAE format. Importing the DAE format in Blender results in glorious color renders.

COLLADA DAE import in Blender

And now we can fine tune the colors, roughness (shininess), subsurface (internal reflectance / translucency ?) for the PCB fibreglass material (PCB edge), mask, copper, silk, adjust the lighting, change the background etc.

So the workflow looks good now, and it’s possible to get nice renders using Blender. At the moment, render quality is only hampered by my very limited knowledge of Blender (about 2 weeks old) – so more experienced Blender power users will be able to do much better.

Also, FreeCAD ver 0.19 Render workbench has a Blender option now, with Cycles rendering, but I haven’t yet got around to figuring out how to use it.

Render workbench in FreeCAD 0.19 with Blender/Cycles

The one issue which needs to be resolved is the inaccurate “mask” layer export from KiCad and I’m hoping anyone with more insight on this can tell us how to get it right.

Next up, i’m going to try making the initial footprint models more realistic by adding device information on the packages and such.

In Part 2 of this blog post, we’ll look at the Blender workflow needed to get :
– Colors for the various PCB elements – fibreglass body, solder mask, copper, silk legend
– Adjusting light and camera (although there are a lot more better, detailed tutorials on this that you can find)
– Background planes and effects.