Skip to content
This repository has been archived by the owner on May 6, 2023. It is now read-only.

Export KiCad design to Blender to generate a high-quality near-realistic render of the end product #14

Open
volkertb opened this issue Nov 16, 2020 · 16 comments · Fixed by #27
Labels
help wanted Extra attention is needed

Comments

@volkertb
Copy link
Contributor

As an improvement on #12, perhaps we can export the KiCad designs to Blender and render a near-realistic image of what the board would be expected to ultimately look like.

There appear to be multiple projects on GitHub that aim to facilitate just that, including one that was featured on Hackaday here: https://hackaday.io/project/175077-remoticon-kicad-to-blender-pcb-renders

The results look pretty impressive.

If we could manage this for this project as well, it would attract a lot of interest and publicity, including (hopefully) more knowledgeable volunteers willing to help us with the hardware design.

I'll look into those projects to see how feasible this would be. Seems like a fun challenge, and something that even I, lacking hardware development skills, can take a stab at. 🙂

@TheGuyDanish
Copy link
Owner

If anyone wants to do this, I'd love to see it. Ultimately, I don't think this is something that I'd put a whole lot of effort into, seeing as the KiCad renders will likely be fine for most things. But as ever, contributions are welcome!

@TheGuyDanish TheGuyDanish added the help wanted Extra attention is needed label Nov 16, 2020
@derwana
Copy link
Contributor

derwana commented Nov 21, 2020

volkertb added a commit to volkertb/CM4_MATX that referenced this issue Nov 23, 2020
…ing of the rendering.

3D rendering created by exporting from KiCad to VRML format, and importing it in Blender 2.79 (later versions ignore color on VRML import)
NOTE: KiCad->VRML->Blender export/import/render cycle will have to be repeated each time the PCB design changes visually.

Resolves TheGuyDanish#14
@volkertb
Copy link
Contributor Author

volkertb commented Nov 23, 2020

@derwana Thanks. I based my rendering on the instructions at https://github.com/Hack-a-Day/Remoticon_KiCad_Blender, which also featured at Hackaday.

Now the examples you see there are of much higher quality than what I managed to whip up, but I'm not that skilled with 3D modeling. I've dabbled a little bit with Blender, but I'm by no means a wizard. 😅

@TheGuyDanish I also included the Blender file, since importing the PCB into Blender proved to be a bit more challenging than I had expected. First of all, color gets lost when you import VRML files (exported from KiCad) in newer Blender versions for some reason. Importing it in Blender 2.79 preserves the colors, but the VRML exported from this project is so large that the Linux version chokes on it and crashes, so I had to import it in the Windows version of Blender 2.79. Once the export was successful, I saved it into a .blend file, which I could then open in Blender 2.90 without problems, and with the colors still there.

With some more time (and/or contribution from an experienced 3D modeling artist), I'm sure an even more impressive 3D rendering can be made of the PCB design, like the ones you see on Hackaday. However, the .blend file (even being compressed) is quite large at 13MB. I therefore completely understand if you prefer not to have the .blend file included in the code base. If so, let me know, and I'll update the Pull Request accordingly.

Thanks. 🙂

@derwana
Copy link
Contributor

derwana commented Nov 23, 2020

@volkertb from the link i posted (regarding the colorloss with Higher blender versions):

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.

Unfortunately the converter is capped on 10 conversions per month on a free account.

volkertb added a commit to volkertb/CM4_MATX that referenced this issue Nov 23, 2020
3D rendering created by exporting from KiCad to VRML format, and importing it in Blender 2.79 (later versions ignore color on VRML import)
NOTE: KiCad->VRML->Blender export/import/render cycle will have to be repeated each time the PCB design changes visually.

Resolves TheGuyDanish#14
volkertb added a commit to volkertb/CM4_MATX that referenced this issue Nov 23, 2020
3D rendering created by exporting from KiCad to VRML format, and importing it in Blender 2.79 (later versions ignore color on VRML import)
NOTE: KiCad->VRML->Blender export/import/render cycle will have to be repeated each time the PCB design changes visually.

See issue TheGuyDanish#14
@TheGuyDanish TheGuyDanish reopened this Nov 23, 2020
@derwana
Copy link
Contributor

derwana commented Dec 23, 2020

HACKADAY just posted the online workshop KiCad to Blender: Photorealistic PCB Renders on Youtube which led to the repo @volkertb mentioned a month ago.

@volkertb
Copy link
Contributor Author

At first I tried automating the process of importing the VRML file in Blender and rendering it, by scripting it with Python. But I couldn't get it to work. The embedded Python interpreter in Blender seems finicky and the Python API is poorly documented and doesn't appear to expose all of Blender's functionality.

That's a shame, since having a script for this would make it so much easier to redo the render any time the KiCad design were updated.

Help with this would definitely be welcome!

@derwana
Copy link
Contributor

derwana commented Dec 26, 2020

I'll have a look into it the next days.

@Bentschi
Copy link

Hi,

I tried what was explained here with my PSOne RPi Compute Module board.
This is my result... (the board is not done yet)

alt text

If you guys like it and need help with that let me know, i could do a render or 2 for you.

@ldrrp
Copy link

ldrrp commented Dec 27, 2020

It would be cool to use github actions and script the rendering? So its always up to date. Although not certain the amount of compute that would take.

@Bentschi
Copy link

Bentschi commented Dec 27, 2020

It would be cool to use github actions and script the rendering? So its always up to date. Although not certain the amount of compute that would take.

Scripting the actions on github is beyond the scope of my knowledge, but it took me less than 2 hours to export from kicad and set up the scene in blender and making the model that shiny. And with the totally cranked up settings i use to render it takes 18.05 seconds and 476.18 MB ram on the CPU with Eevee (I am not a fan of Cycles).

@TheGuyDanish
Copy link
Owner

As I've mentioned before, I think a render like this is nice to have, but ultimately something we only should produce every now and then. Maybe on major revisions or release tags.

Unlike the schematic and PCB PDFs, the render can't be updated in one or two minutes by anyone who is already working on the main schematic and PCB, which is why I'm erring on putting more effort towards it. Maybe documenting the process, perhaps putting it into a documentation file, then someone can do it, as they please, when we reach a major milestone.

@Bentschi
Copy link

Bentschi commented Dec 27, 2020

It is already pretty well documented how you would go about exporting from KiCad and import that in Blender:
https://hackaday.io/project/175077-remoticon-kicad-to-blender-pcb-renders/log/185976-getting-from-kicad-render-to-blender
And yes, as mentioned in that article, I had to use an older version of Blender (2.79) to get the imported model right, and then used a newer version (2.91.0) to actually render it.
I could provide the Blender scene with all the settings I used to render and without the model, if interested, but it want look as good if the materials are not tweaked on the model.
Edit: that could potentially be done by a python script in Blender?

@volkertb
Copy link
Contributor Author

If @Bentschi can manually make such a shiny high-quality rendering of the CM4_MATX board that would blow my current rendering out of the water and make people salivate over the end product, I'm all for it! 😅

Ultimately, it would be great if we could get the render process to work with a simple Python script that we could occasionally run whenever major changes or improvements are made to the design. Full automation might be problematic, since I believe you'd need the embedded Python interpreter distributed as part of Blender.

I've tried to make such a script (with the Blender Python bindings) work standalone, with no success so far. Again, I found the documentation w.r.t. the Blender Python bindings to be quite lacking.

@Bentschi
Copy link

I tried, but not really sure... it looks a bit boring... maybe because there is so much room left and no traces yet.
Had to align the PCIe 3D model and had to remove the ethernet port to export it.

alt text

and here are the Blender files:
https://github.com/Bentschi/CM4_MATX-render/blob/main/CM4_MATX-render.zip

@Bentschi
Copy link

Bentschi commented Dec 28, 2020

I thought a little about the "boring look" of the picture.
I tried to catch the eye mostly on the upper left corner with shiny metal and the lighting, but as a whole it doesn't look "real" to me.
But it could be better if the background would actually be a atx computer case, so the eye has more to focus on the important bits.
I am not thinking of a complete case, just the important bits that are actually visible in the picture, and it would look nice i guess when a bit of lighting shines through the PCIe slots.

Edit: But if you want to use the picture or the files, just take them. I dont care about licensing that

@TheGuyDanish
Copy link
Owner

I think for now, either removing the rendered image we have already, or using a screenshot from KiCad's existing 3D viewer is a better course of action. As I mentioned, it's not like our board is in a great state to be shown off anyway, so putting effort into a nice, fancy-looking 3D render of it at this point is probably not worth it, considering how many substantial changes it is still likely to go through.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants