Skip to content

[Render 3D][Fixed] Avoid --use-board-stackup-colors consuming INPUT_FILE#944

Open
Wol wants to merge 1 commit into
INTI-CMNB:devfrom
Wol:fix_render3d_stackup_colors_arg_order
Open

[Render 3D][Fixed] Avoid --use-board-stackup-colors consuming INPUT_FILE#944
Wol wants to merge 1 commit into
INTI-CMNB:devfrom
Wol:fix_render3d_stackup_colors_arg_order

Conversation

@Wol

@Wol Wol commented Jul 6, 2026

Copy link
Copy Markdown

With kicad-cli 10.0.4, --use-board-stackup-colors tries to greedily accept an argument after it, so if it's the last argument in your kicad-cli call, then it greedily consumes INPUT_FILE and kicad-cli errors out saying you've not passed a filename.

This change forces --pan / --pivot / --rotate to be the last in the chain, as we know those always have a parameter value after it.

The error was showing:

ERROR:Running ['kicad-cli', 'pcb', 'render', '--output', '/builds/render.png', '--width', '3856', '--height', '2176', '--side', 'bottom', '--background', 'transparent', '--quality', 'basic', '--preset', '_kibot_preset', '--pan', '0,0,0', '--pivot', '0,0,0', '--rotate', '0,0,0', '--use-board-stackup-colors', '/builds/board.kicad_pcb'] returned 1 (kibot.gs - gs.py:937)

But, from the kicad-cli help:

--use-board-stackup-colors Colors defined in board stackup override those in preset [nargs=0..1] [default: false]

the "nargs 0..1" tries to capture the final INPUT_FILE

With kicad-cli 10.0.4, --use-board-stackup-colors tries to greedily accept an argument after it, so if it's the last argument in your kicad-cli call, then it greedily consumes `INPUT_FILE` and kicad-cli errors out saying you've not passed a filename.

This change force --pan / --pivot / --rotate to be the last in the chain, as we know those always have a parameter value after it
@set-soft

set-soft commented Jul 6, 2026

Copy link
Copy Markdown
Member

Hi @Wol !
Didn't notice it while testing, thanks!
Looking at the issue closer I think we can just remove the --use-board-stackup-colors option.
When I implemented it I though it was a good idea to use it, but I found some issues and decided to just transfer the colors, look here:

        # Colors
        if self.force_stackup_colors:
            colors = self.cli_stackup_colors()
        elif not self.realistic:
            colors = self.cli_gui_colors()
        else:
            colors = self.cli_user_colors()

So I think we can safely remove this option from kicad-cli invocation, can you try it?

@Wol

Wol commented Jul 6, 2026

Copy link
Copy Markdown
Author

It does seem to pull through the board stackup colours at least without that option in, but the colours are a lot brighter than normally rendered. What was a dark/mid green is now a much brighter lime green. A board which was a purple soldermask and was quite dark, is now a lot lighter.

I'm guessing the reason why my boards now look more lime green compared to before is because without that "force-stackup-colors" option which is getting kicad-cli to choose the colours it's reverting back to the preset from KiBot which is telling it the colours?

image

versus

image

from KiBot.

use board stackup colours = true -> looks right, follows stackup colours correctly.
use board stackup colours = false -> looks too bright, but still gets the correct hue (so a purple board shows up light purple, a green board shows up light green)

@set-soft

set-soft commented Jul 8, 2026

Copy link
Copy Markdown
Member

I'm not sure I understand, if I get it correctly what you say is normal, KiBot "default" colors looks brighter when rendered by KiCad, and looks ok when rendered by PcbDraw.
The force_stackup_colors uses the colors from KiCad source code, some of them slightly fine tuned. The idea is that this option will generate something closer to what you get in the GUI.

set-soft added a commit that referenced this pull request Jul 8, 2026
- Currently not needed, we do the color translation
- This switch has a bug, can take an extra parameter

See #944
@Wol

Wol commented Jul 8, 2026

Copy link
Copy Markdown
Author

At the moment it's that the KiBot render which uses kicad-cli looks brighter than it does when I just load up KiCad directly on my desktop, unless I pass in that --use-board-stackup-colors on the kicad-cli command line.

Even with kicad-cli renders being native now, should I be looking to migrate to a third party solution like the pcbdraw export rather than using render_3d?

Annoyingly the render which KiCad produces on desktop is perfect for what I want, just it seems to behave differently to the kicad-cli! 😂

@set-soft

set-soft commented Jul 8, 2026

Copy link
Copy Markdown
Member

Without something to test is really hard to determine the reasons.
Here is an example using the current git code:
test.zip

KiCad 9
test-3D_top

KiCad 10
test-3D_top

KiCad 9 GUI:
image

The renders looks quite similar to the GUI, there are some illumination differences.

If you are looking for the best results and quite good repeatability use blender_export output.

@Wol

Wol commented Jul 8, 2026

Copy link
Copy Markdown
Author

I've stuck a minimal reproducable example at: https://github.com/Wol/kibot-render-bug-testing It should just checkout and ./run_render.sh to reproduce.

My KiBot config file is simply:

kibot:
  version: 1

outputs:

  - name: 'render_3d_top_force_stackup_colors_false'
    type: 'render_3d'
    dir: 'outputs/png'
    output_id: '_force_stackup_colors_false'
    options:
      force_stackup_colors: false
      realistic: true
      view: 'top'

  - name: 'render_3d_top_force_stackup_colors_true'
    type: 'render_3d'
    dir: 'outputs/png'
    output_id: '_force_stackup_colors_true'
    options:
      force_stackup_colors: true
      realistic: true
      view: 'top'

I've had to patch in the actual python file from the repo just to get around kicad-cli grabbing the option incorrectly as per the original report.

The README.md file there shows what I'm seeing between the different versions - if I don't use the force_stackup_colors: true option, my PCBs end up bright lime green!

I guess this is more of a kicad-cli thing underneath, but hopefully that shows why I'm currently reliant on KiBot passing the --use-board-stackup-colors option!

@set-soft

Copy link
Copy Markdown
Member

Ok, lets clarify a couple of things:

  1. Yes, you need to use the force_stackup_colors: true option in the KiBot config in order to get the colors used by KiCad according to the stack-up
  2. No, you don't need --use-board-stackup-colors option, you just need the current git code, i.e. a fresh dev image

I get the same results you show using the current git code. No extra patch needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants