Custom VRML export pcb colors

Bug #1544924 reported by m
32
This bug affects 5 people
Affects Status Importance Assigned to Milestone
KiCad
Expired
Wishlist

Bug Description

export VRML function doesn't conserve the colors of board, tracks, solder mask, silk screen as selected in 3d-viewer

Revision history for this message
Joan (joanthesparky) wrote :

IHMO incomplete report.. needs detailed kicad version and some steps to reproduce, preferable the pcbnew (ini) file excerpt of the settings for the 3d viewer elements (colors, etc).

Revision history for this message
m (easyw) wrote :

sorry,
here the details:
- kicad all releases from stable on
- OS: all platforms
- the color of the exporting board is hard-coded in
http://bazaar.launchpad.net/~kicad-product-committers/kicad/product/view/head:/pcbnew/exporters/export_vrml.cpp
line 176 and following...

how to reproduce the problem:

open a board, export the board to VRML through the menu
- File
    - Export
       - VRML
the VRML model of the board will have
PCB color, PCB Tracks color, SILK color as coded (green, dark green, white)

change the color to display the board in 3d-viewer (Realistic Mode ON) with the menu
- Preferences
    - Choose Colors
       - Solder Mask Color
change the Solder Mask color e.g. to Blue
display the nice Blue board

then export your VRML to the above File menu, and you'll get a green board instead of blue ...

xzcvczx (xzcvczx)
summary: - VRML export with wrong pcb colors
+ Custom VRML export pcb colors
Changed in kicad:
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
Jan-Åke Larsson (jalar) wrote :

Still present in latest nightly.

Revision history for this message
kerem (kekat) wrote :

I have tried to implement this feature but I cannot find which colors to take and pass to the VRML exporter for consumption. My best guess is:

const CINFO3D_VISU& settings = viewer->GetSettings();

const auto to_vrml_color = []( SFVEC3D color ) {
    return VRML_COLOR( color.r, color.g, color.b );
};

colors[VRML_COLOR_PCB] = to_vrml_color( settings.m_BoardBodyColor );
colors[VRML_COLOR_TRACK] = to_vrml_color( settings.m_CopperColor );
colors[VRML_COLOR_SILK] = to_vrml_color( settings.m_SilkScreenColor );

which gives a seemingly low-quality rendering as attached.

I think the current VRML exporter does not support solder mask color.

Revision history for this message
Seth Hillbrand (sethh) wrote :

@kekat- I'm not sure what errors you were seeing when compiling that, but it wouldn't compile cleanly because VRML_COLOR() takes 12 parameters:
-RGB in diffuse
-RGB in specular
-RGB emission
-Ambient level
-Transparency
-Reflectivity (shiny-ness)

Using only 3 will definitely get you weird results. For decent results, set the color to the diffuse color, the specular color to ~10-15% of the diffuse color, emission to 0,0,0, ambient to ~0.8, transparency to 0 and shiny-ness to 0.01-0.04.

Revision history for this message
kerem (kekat) wrote :

@sethh, I only included part of the patch that is relevant for matching CINFO3D_VISU colors to VRML_COLORs.

I am attaching the full diff, unfortunately, I have renamed _clangformat to .clangformat and all of the file is auto-formatted with it. If it would be appropriate to continue with it, I can clean it up.

Diff includes this constructor:

+ VRML_COLOR( float r, float g, float b, float tr = 0 )
+ : VRML_COLOR( r, g, b, 0.1 * r, 0.1 * g, 0.1 * b, 0, 0, 0, 0.8, tr, 0.02 )

Revision history for this message
m (easyw) wrote :

Is there any update on this?
It would be nice to have at least the option to export among few presets for Mask and Tracks...
https://hackadaycom.files.wordpress.com/2018/05/colorswatchback.jpg

Revision history for this message
m (easyw) wrote :

the related Green preset is:
        // pcb green
        colors[ VRML_COLOR_PCB ] = VRML_COLOR( .07, .3, .12, .01, .03, .01,
                                                  0, 0, 0, 0.8, 0, 0.02 );
        // track green
        colors[ VRML_COLOR_TRACK ] = VRML_COLOR( .08, .5, .1, .01, .05, .01,
                                                  0, 0, 0, 0.8, 0, 0.02 );
        // silkscreen white
        colors[ VRML_COLOR_SILK ] = VRML_COLOR( .9, .9, .9, .1, .1, .1,
                                                  0, 0, 0, 0.9, 0, 0.02 );
        // pad silver
        colors[ VRML_COLOR_TIN ] = VRML_COLOR( .749, .756, .761, .749, .756, .761,
                                                  0, 0, 0, 0.8, 0, 0.8 );

Jon Evans (craftyjon)
Changed in kicad:
assignee: nobody → Jon Evans (craftyjon)
milestone: none → 6.0.0-rc1
Revision history for this message
KiCad Janitor (kicad-janitor) wrote :

KiCad bug tracker has moved to Gitlab. This report is now available here: https://gitlab.com/kicad/code/kicad/-/issues/2009

Changed in kicad:
status: Confirmed → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.