[Video] Render 3D images of EAGLE PCB projects

 Posted by:   Posted on:   Updated on:  2023-01-07T21:27:33Z

Render realistic images of EAGLE circuit board projects using POV-Ray and HDR lighting on Linux.

This is a video follow-up of my previous tutorial about EAGLE and POV-Ray. I will outline below the main steps that you will see in the video and I will continue to improve the result at the end of this post.

If you haven't read about this before, EAGLE is a schematic capture and circuit board design software. The circuit boards can be processed with a set of scripts and converted into POV-Ray files. In this way you can render great looking 3D pictures of the circuit boards. All used software is available for all major operating systems. The video presents only Linux Ubuntu installation and configuration.

EAGLE circuit board rendered with POV-Ray HDR lighting
Here are the main steps required to generate the images:
  1. Download and install CadSoft EAGLE.
  2. Download and unarchive Eagle3D.
  3. Fix Eagle3D bug in 'e3d_special.inc' (replace 0.6.5 with 0.65).
  4. Install POV-Ray (from repositories).
  5. Copy user configuration files (from system-wide folders).
  6. Download an HDRI image.
  7. Download a background texture.
  8. Create the 'e3d_hdr.inc" file.
  9. Edit '3d50.ulp' to:
    • change POV-Ray file version;
    • add include directive for 'e3d_hdr.inc';
    • change light definitions default value (lgt1_inf[10]);
  10. Open EAGLE PCB project and run '3d50.ulp'.
  11. Launch the generated script.
  12. Wait for the rendering process to complete.
Steps 1-9 are the configuration steps. Follow 10-12 each time you want to render a image.



At the end of this video I ended up with the following image:

POV-Ray rendered circuit board

OK. So what can be improved here?
  • There are four missing parts (two electrolytic capacitors and two preset resistors).
  • Improve the saturation for the transistors body and the pinheaders.
  • Replace the 1N4148 diode model with a better one.
  • Adjust a bit the board color.

Missing parts

If you missed the information dialog displayed when you run 3d50.ulp you can find the message in the *.pov.none.txt file which should be in the same folder with the POV-Ray file and the bash script. My file looks like:
Parts not found in 3dpack.dat or 3dusrpac.dat are:
//C8 1u/16V E2-4
//C9 1u/16V E2-4
//P1 2k5 LI10
//P2 1k LI10
This situation can be easily solved because the missing parts are defined by POV-Ray macros but are not assigned to EAGLE packages. The assignments list is 3dpack.dat (in the ulp folder) and if we open it we will find lines like below:
E2-5:0:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:CAP_DIS_ELKO_2MM_5MM(:Elko 2mm Pitch, 5mm Durchmesser, 11mm Hoehe:Elko 2mm Pitch, 5mm  Diameter, 11mm High
E2,5-5:0:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:CAP_DIS_ELKO_2MM5_5MM(:Elko 2,5mm Pitch, 5mm Durchmesser, 11,2mm Hoehe:Elko 2,5mm Pitch, 5mm  Diameter, 11,2mm High
In these lines, E2-5 and E2,5-5 are EAGLE package names and CAP_DIS_ELKO_2MM_5MM and CAP_DIS_ELKO_2MM5_5MM are POV-Ray macro names. Suppose I want to modify the electrolytic capacitor, I will look for CAP_DIS_ELKO_2MM_5MM in all the included files from povray folder (it will be in e3d_cap.inc).

I want an E2-4 capacitor but I cannot simply duplicate one of these lines and use the macro CAP_DIS_ELKO_2MM_4MM. It probably doesn't exist and I will end up with an error. So let's look it up in e3d_cap.inc.
#macro CAP_DIS_ELKO_2MM_5MM(value)
CAP_DIS_ELKO_GRND(<6.39,20,6.39>,1,2,5/2,11,0.5/2,value)
#end
#macro CAP_DIS_ELKO_2MM5_5MM(value)
CAP_DIS_ELKO_GRND(<6.39,20,6.39>,1,2.5,5/2,11.2,0.5/2,value)
#end
#macro CAP_DIS_ELKO_2MM5_6MM3(value)
CAP_DIS_ELKO_GRND(<8.04,22,8.04>,1,2.5,6.3/2,11.2,0.5/2,value)
#end
We can see that all capacitors macro call a generic macro with different parameters. I guess for the E2-4 capacitor I could write:
#macro CAP_DIS_ELKO_2MM_4MM(value)
CAP_DIS_ELKO_GRND(<6.39,20,6.39>,1,2,4/2,11,0.5/2,value)
#end
Feel free to experiment with these. You're editing text files and you can come back anytime later if the result is not as expected.

Now I have a macro for my part. But I must tell Eagle3D that I have it. So I add a new line in 3dpack.dat like this:
E2-4:0:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:CAP_DIS_ELKO_2MM_4MM(:Elko 2mm Pitch, 5mm Durchmesser, 11mm Hoehe:Elko 2mm Pitch, 5mm  Diameter, 11mm High
Now let's move to the preset resistors. I guess that LI10 is the same as PT-10 so all I do is duplicate PT-10 line and replace it with LI10 like this:
PT-10:0:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:RES_DIS_TRIM_PT10_H_10(:PT10:PT10
LI10:0:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:RES_DIS_TRIM_PT10_H_10(:PT10:PT10
First line is the original one and the second is my modified copy of it. Let's hope for the best and re-run the 3d50.ulp script (from EAGLE!). Any modification made to files in the ulp folder require re-running the script from EAGLE. Modifications made to POV-Ray include directory require only a new render.

Note: In the video, it is said you shouldn't check that box to automatically call POV-Ray and render the image. I just did it and it works great (unless there are syntax errors or not found included files).

EAGLE PCB rendered with POV-Ray HDRI

Well, so far so good. Missing parts fitted perfectly. Note that certain numbers from those strange lines in 3dpack.dat represent parts coordinates that cab be used to place the part correctly on the PCB.

Things won't always work as smooth as here. Sometimes, you will have to create the macro from scratch. For this you will need some knowledge of POV-Ray language.

Colors

I don't like presets, pinheaders, ceramic capacitors and transistors. I need to find their macros and see what color/texture they use and change it.

Open the main pov file (the one resulted after running the ULP) and search for #if(pcb_parts=on). Everything that's between this and the first #end represents parts included in the current board. Here is how one part declaration looks like:
#ifndef(pack_IC1) #declare global_pack_IC1=yes; object {TR_TO92_G("78L05Z",)translate<0,0,0> rotate<0,0.000000,0>rotate<0,-180.000000,0> rotate<0,0,0> translate<18.415000,0.000000,93.980000>}#end  //TO92 bend vertical IC1 78L05Z TO92
I emphasized macro name which I will look up in e3d_transistor.inc (if it isn't there, where else should it be?). Looking at the code, the author left some useful comments:
// plastic body
 difference{                                                                                  //Transistorkoerper
  cylinder{<0,14,0><0,19.2,0>2.4 pigment{ Gray30}translate<0.12,0,0>}
            box{<-3,13.9,-1><3,20,-3> pigment{ Gray30}}}
All I have to do is replace Gray30 with a darker shade of gray. Let's try with Gray10. it looks good. Now I have to do the same for the pinheaders (in e3d_connector.inc, macro #macro PH()) and presets (in e3d_resistor.inc, macro #macro RES_DIS_TRIM_PT10_BODY(value)).

Ceramic capacitors and the other transistor need this too. For the transistor (BFY90) I used the col_silver texture that is used for solder too. I replaced pigment{P_Silver3} with texture{col_silver}. For the capacitors I replaced the Yellow pigment with Orange.

I will also edit board colors using Jaime Vives Piqueres instructions. They are declared in e3d_tools.inc. This is the preliminary result:

EAGLE PCB rendered with POV-Ray HDRI lighting

Parts

I don't like the diode capsule so I will replace it. I got the macro from here. The original macro name is DIODE_DIS_DO35_076MM_H and EAGLE package is DO35-7. The new macro is DIODE_DO35_7_UVEG. I will just copy the entire macro code to my e3d_diode.inc and replace name in POV-Ray file.

Other tweaks

  • Rotated board: #local pcb_rotate_y = -10;
  • Set resistor color to blue: #declare global_res_col = 2;
  • Added focus blur to camera: focal_point < 0, 0, -3> aperture 0.7 blur_samples 20
The result is the first image in this post. Here is another one with a different HDR:

EAGLE PCB rendered with POV-Ray HDRI lighting

What's next? POV-Ray can be configured to render successive images with a variable parameter in order to make a short video.

11 comments :


  1. very good
    Is the tutorial can be applied on windows 10 master ??
    Thank you

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. I want to try to make a 3D electronic library model that produces pov images, but I don't know the software ?? Is there any software that designs a good 3D ,,,, please master that information ?? thank you

      Delete
    2. To design 3D models you need to know POV-Ray language. Then you can design your parts in any text editor and render them with POV-Ray. I guess Blender can be used too for design of 3D parts.

      Delete
  3. Thank you for the answer ??
    And I really hope that in the future the Master will make a video tutorial "How to make 3D model parts"
    I really look forward ...

    ReplyDelete
  4. master ...
    I tried to follow the tutorial that the master posts, but here I failed to render and always error when I render
    the error is always // library file #include "e3d_special.inc"
    Which part of the error is master ... please guide ...
    thank you

    ReplyDelete
  5. Hello master Cornellus?
    I'm interested in you ... How do I edit the pcb board as you do ,,, which file should I change?
    on the web where do I have to find traces of lights, hdr for example?
    Thank you....

    ReplyDelete
    Replies
    1. I no longer use these tools to generate 3D images of PCB projects. If I remember, I think PCB colors could be edited in e3d_tools.inc. There were 4 or 6 presets for PCB color palette.

      Delete
  6. Thank you for the information ... and I tried to find the file on e3d _toll .inc

    ReplyDelete
  7. Hello ... master Cornelius
    Have you ever made a 3D library for Eagle Povray? ..
    I tried to make it, but to this day I always fail to render ,,,,, povray Messages (parse warning: should have at least 2 objects in csg)
    I use 3d modeling freeCAD 0.17
    Can you help?

    ReplyDelete