Skip to content

Drawing W17b: shaded views, the model drawn as a picture under the view's lines #5624

Open

Description

@CamWight

Part of the Drawings plan in #860 (package W17, after W17a's view definitions, #4816). Shaded views are part of the first ship.

What's missing

A drawing view is planned as lines only: visible edges (W06, W07) and, as an option, hidden lines. There's no way to show the part shaded, as it looks in the model, which pictorial and assembly sheets need. The PDF writer's package (W22, #4890) leaves raster shading to a separate job, and no package holds it yet.

Proposed

Tests (planned)

  • A shaded view at 300 dpi of a 100 mm frame is 1181 px wide (the study's case), and in shaded_visible its vector lines sit exactly where the line-only style puts them.
  • The same view renders the same pixels twice; an edit to the source design renders it again; a render cancelled part way leaves the last result, marked stale.
  • A view too large for its resolution is refused with the limit, never cut or shrunk.

Depends on

W17a (#4816) for the view's frame, the paper scene's picture item (#4890), and W06 for the lines of shaded_visible.

Activity

  1. added
    in progress
    on Oct 23, 2026
  2. github-actions commented on Oct 23, 2026

    @github-actions
    Contributor

    Claimed by @CamWight through #5626. The claim lapses after 14 days without pushes.

  3. added
    needs-triage
    on Oct 23, 2026
  4. CamWight commented on Oct 24, 2026

    @CamWight
    ContributorAuthor

    The plan for shaded views, after the research and the decisions on it (2026-10-24). Anyone starting near views, exports or the renderer: this is what we're following.

    How a shaded view is made

    • The CPU renderer in render draws it: the product renderer (job::image::ImageTask) reshaped into prepare, tile and sink stages, with an orthographic projection taken from W17a's view frame. The same affine map places the lines and the pixels, so they register exactly. It works the same in the app, the CLI, MCP, scripts, tests and the browser. A GPU executor can come later, only against a tolerance test with the CPU result.
    • The light is a drawing light: the viewport's shading function, with its light offset in the view's own frame, so a front, top and side view of one face print the same grey.
    • The background is transparent; colours are the model's appearances, never the theme or the selection. The picture has no raster edges: the lines are W06's exact vectors on top.
    • 300 dpi by default (a drawing setting, with a per-view override). The pixel grid snaps outward to whole pixels, so a 100 mm frame at 300 dpi is 1182 px. Anything over a cap is refused with the limit, never shrunk.
    • PNG exports re-render shaded views at their own dpi, strip by strip, up to 1200 dpi; above that they render at dpi/k for a whole number k, so registration stays exact. A 1-bit PNG dithers the picture (and says so in its report); lines stay black.
    • Each picture is kept under a key (the geometry, appearances, frame, light, dpi, crop and renderer version), is re-rendered off the UI thread when that changes, and is saved in the drawing file's results cache, so a cold open shows it at once.

    Five display styles per view
    visible, visible_hidden, shaded, shaded_visible and shaded_visible_hidden. The three shaded styles share one picture, so switching between them re-renders nothing. The names will come from one shared visual-style vocabulary with the viewport (#5219) and saved view styles (#5307), rather than a second list.

    Reference parts get their own display
    Components whose bill-of-materials type is reference (#3874) get two settings of their own on each view, in the dialog that opens when the view is double-clicked:

    • their own style, any of the five (default visible, in the drawing standard's reference line style);
    • "reference parts hide the model", on or off. Off (the default): they never cover the model; their lines behind the model become hidden lines, and their picture lies under the model's. On: everything is calculated together, so each hides the other where it's in front.

    They are also never sectioned, and they are left out of mass and of the view's default extents (a margin grows the boundary to fit them). The renderer handles "on" with a lines-only reference style by using the reference bodies for depth only, so it costs no second render.

    First carrier and slices
    W07's drawing.view (#5866) carries display_style, dpi and the two reference settings first; the saved view record (W12) follows. The slices:

    1. S1 the tile renderer (on main, shared render work), with a role per body (painted or depth only);
    2. S2 its measured speed-up (main);
    3. S3 the paper scene's picture item and pixel grid;
    4. S4 shaded views from drawing.view in the CLI, MCP and scripts;
    5. S5 shaded views in SVG, PDF and PNG;
    6. S6 on the canvas;
    7. S7 in the drawing file's cache.

    shaded_visible and shaded_visible_hidden need W06's exact lines; sections, detail crops and per-component styles come later.

    Open points, with what I'd recommend: with the hide setting off, the model still hides reference lines behind it (one way), rather than them showing through it; and "not shown" stays out of the reference style, since hiding components in a view is its own feature.

  5. CamWight commented on Oct 24, 2026

    @CamWight
    ContributorAuthor

    Two open points from the plan above are now settled:

    • With "reference parts hide the model" off, the model still hides reference lines behind it (one way). Reference lines behind the model become hidden lines and are drawn in the reference style's hidden-line setting; reference parts never cover the model.
    • "Not shown" isn't a reference style. Hiding components in a view will be its own feature (per-view visibility), so the reference style keeps the same five display styles.
  6. CamWight commented on Oct 24, 2026

    @CamWight
    ContributorAuthor

    Two changes to the plan above, from today's decisions on drawing views:

    • The picture resolution is a sheet setting, 300 dpi by default, not a per-view one. The per-view override is dropped, and the view window won't show it. PNG exports still re-render at their own dpi.
    • A view may show only reference parts. It isn't refused: its picture and lines are the reference parts, and its boundary comes from them. When it also shows model parts, the boundary comes from the model parts, with the reference margin to show more.
  7. selun3 commented on Oct 24, 2026

    @selun3
    Collaborator

    @CamWight, our shading reviewer can take a small independent acceptance child against S1/S3: picture/vector registration, outward pixel rounding and alpha composition. Would that be useful under your existing W17b claim, and which API/revision should the tests bind to once the tile renderer and picture item are available?

    We propose original asymmetric fiducials at nonzero sheet origins, exact W17a frames and two scales; fractional/negative pixel bounds at 300/1200/2400 dpi; and small transparent scenes compared across bands and two backgrounds. This follows the latest sheet-only DPI decision and would add no separate renderer, style vocabulary or exporter.

    Before runnable tests, please confirm the intended pixel-centre/grid-origin convention and the picture's alpha/color representation at the paper boundary. We are preparing the case matrix privately while those interfaces are agreed. Reference-part occlusion and the PBR drawing-light policy remain separate follow-ups with you.

  8. CamWight commented on Oct 24, 2026

    @CamWight
    ContributorAuthor

    @0xlillith, yes please. That's a useful child under W17b, and the cases you list are the right ones. The conventions come from our research for the picture item and go into S1 and S3 as written:

    • Grid origin: a picture's pixel grid is anchored at its view frame's lower-left corner. Its window is the view's paper rectangle, snapped outward to whole pixels: columns W = ceil(width_mm / p − 1e-9), where p = 25.4/dpi mm. So 100 mm at 300 dpi is 1182 px, placed at the frame's corner and 1182·p mm wide, with nothing stretched or cut.
    • Pixel centres: pixel i covers paper [x0 + i·p, x0 + (i+1)·p) and is sampled at (i + 0.5)·p, or at i + ¼ and i + ¾ with 2×2 samples. That's also what SVG <image> and a PDF image's unit square map to.
    • PNG exports re-render a shaded view on the sheet's own pixel grid, anchored at the top left as the PNG writer draws, so compositing is a pixel copy with no resampling. The rectangle-to-pixels rule is one function in geom::paper, shared by the PNG writer and the picture provider.
    • Colour and alpha: sRGB-encoded 8-bit RGBA with straight (not premultiplied) alpha and a transparent background, blended in linear light. Writers composite onto white paper, never onto a screen colour.
    • What to bind to: S1's tile renderer (render, on main) and S3's picture item in the paper scene, once their PRs are up. I'll link them here when they open.

    Agreed that reference-part occlusion and the drawing light stay separate follow-ups.

  9. selun3 commented on Oct 24, 2026

    @selun3
    Collaborator

    We have updated the A–C acceptance preparation to this contract. The local picture grid gives 1182 pixels for 100 mm at 300 dpi even when the frame origin is fractional; the PNG expectation uses the sheet's top-left grid and re-rendering, not moving or resampling that cached picture.

    An independent analytic oracle now covers frame transforms, fractional origins, outward rounding (including the 1e-9 pixel boundary), sample centres and straight-sRGB/linear-light alpha composition. Its 26 arithmetic checks pass in two independent runs. These are original expected-value fixtures: zero SolidCraft renderer tests have run, and they do not establish band equivalence, cancellation or export behavior. Rounded RGB8 examples are diagnostic, not a proposed cross-writer tolerance.

    We'll bind the applicable cases to your actual S1/S3 APIs when those PRs are available, without introducing a second renderer or a stand-in provider.

  10. CamWight commented on Oct 25, 2026

    @CamWight
    ContributorAuthor

    The plan for S1, the tile renderer (draft #6483, on main), is set. The code starts now. Here's what it is, so anyone working nearby can follow it.

    One renderer, not a second one for drawings. render.image's CPU renderer (job::image::ImageTask) becomes three steps: prepare, render a tile, then write the rows to a sink. ImageTask keeps its public face, and render.image gives the same pixels as before. A pinned hash of the rendered rows for fixed scenes proves it, in the slice's first commit.

    What's new beside ImageRequest (which doesn't change):

    • PictureRequest { projection, window, supersample, roles, background }.
    • Projection::Ortho(OrthoFrame): a geom::Plane basis whose normal points toward the viewer, a scale (paper mm per model mm) and a shift, so paper = basis.to_local(p) × scale + shift. A W17a view frame (Drawing W17a: view definitions as data (direction, first- or third-angle projection, scale) #4816) converts into it field by field.
    • Supersampling is One (pixel centres) or Two (i + ¼, i + ¾, today's).
    • Roles per body: Painted (the default) or DepthOnly, for reference parts that hide the model without being drawn.
    • background: None gives a transparent picture with straight alpha.

    The pixel grid, as one rule: geom::pixel_grid on main.

    • p = 25.4 / dpi, and W = ceil(width / p − 1e-9).
    • The grid is anchored at the frame's lower-left corner and rounds outward, so the picture covers [x0, x0 + W·p] × [y0, y0 + H·p].
    • Rows go top-down: row r covers [y0 + (H − r − 1)·p, y0 + (H − r)·p).
    • The sheet's paper code on drawings will call the same function.

    Limits:

    • a picture is at most 65,536 px on a side (A0 at 1200 dpi is 56,170);
    • each tile stays within today's RenderLimits;
    • anything over a limit is refused with the limit named, never shrunk.

    Tests:

    • the hash pin;
    • tiles stitched in uneven windows give the same bytes as one whole picture;
    • a 100 × 50 mm frame at 300 dpi is 1182 × 591 px;
    • registration to 1e-9 mm;
    • the roles, alpha at an edge, and each limit;
    • ten planted faults.

    @0xlillith, the names above are what your acceptance cases can bind to: PictureRequest, Projection::Ortho and geom::pixel_grid. I'll post the commit here once it's on #6483.

    Out of S1: per-tile bins and the speed-up (S2), the picture item (S3), the drawing light, and 4× supersampling.

  11. added this to the Drawings milestone on Oct 25, 2026
  12. 180 remaining items

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

Metadata

Metadata

Assignees

Labels

in progressneeds-triage

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions