Skip to content

Render preview shades simple colours darker than the exported PNG #5761

Closed

Description

@kravens

What happened

In the Render workspace, a body with a simple colour (the look every body starts with, no PBR) does not look the same in the integrated preview as in the PNG that Start Render → Export PNG writes from the same camera. The preview's shadows and mid-tones are darker; the exported image is lighter and flatter. A body with an opaque PBR look does match (there is a test for that); simple colours have no such test.

Cause: the GPU preview draws simple colours with the Design viewport's shader (lit_color in assets/shaders/viewport.wgsl), which applies the key/fill/specular factor to the sRGB-encoded colour. The CPU product image (crates/render/src/job/image.rs) decodes the colour to linear light, applies the same three terms, and encodes once. Same lights, different colour space. For a mid grey #808080 in shadow (factor 0.42) the preview writes 54/255 and the export 103/255. docs/render-jobs.md records the gap: "Native GPU preview and CPU export can differ in shading and transparency."

Steps to reproduce

  1. Three bodies with simple colours:
    [{"command":"solid.box","params":{"length":40,"width":40,"height":30,"corner":[-70,-20,0],"body_name":"Grey box"}},
     {"command":"solid.cylinder","params":{"radius":18,"height":40,"base":[0,0,0],"body_name":"Orange cylinder"}},
     {"command":"solid.sphere","params":{"radius":20,"center":[60,0,20],"body_name":"Blue sphere"}},
     {"command":"appearance.assign","params":{"bodies":["Grey box"],"color":"#808080"}},
     {"command":"appearance.assign","params":{"bodies":["Orange cylinder"],"color":"#b47846"}},
     {"command":"appearance.assign","params":{"bodies":["Blue sphere"],"color":"#2040c0"}}]
  2. Switch to the Render workspace. Start Render with the viewport's size and the current camera, then Export PNG.
  3. Put the preview and the PNG side by side.

Expected: the preview shows what the export writes for the same camera and size.
Actual: the bodies are shaded differently (pictures below). Measured over the bodies' pixels, the mean channel difference is 14/255 (maximum 102/255); the biggest differences are in the shadow sides. The same comparison through the test harness (render_product_offscreen against ImageTask, a sphere in #b47846) gives a mean of 12.9/255 with 66% of the interior pixels more than 12/255 apart.

SolidCraft version and OS

Current main (e1bf784, workspace 0.21.0-rc.2), Linux x86_64, NVIDIA Vulkan. 0.20.0 cannot show this: there the Render preview is the frozen Design frame (#5119, fixed by #5187).

Screenshots

Preview (left) and the exported PNG (right) of the same camera, on main and with the fix (#PR follows). The shadow sides of the box and the cylinder, and the sphere's dark half, are the obvious differences; the lit top faces nearly agree.

Before and after: Render preview beside Export PNG

The Render workspace on main with the three bodies, as captured:

Render workspace on main

Activity

  1. added
    area:render
    needs-triage
    in progress
    on Oct 24, 2026
  2. github-actions commented on Oct 24, 2026

    @github-actions
    Contributor

    Claimed by @kravens through #5762. The claim lapses after 14 days without pushes.

  3. github-actions commented on Nov 8, 2026

    @github-actions
    Contributor

    No draft PR showed up within 72 h, so this one is free again. Anyone can /claim it.

  4. removed
    in progress
    on Nov 8, 2026
  5. kravens commented on Nov 8, 2026

    @kravens
    ContributorAuthor

    Fixed: #11087 made the Render preview shade simple colours in linear light, as the exported image does, and #13219 made near-black colours decode the same way the export does.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:renderneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions