Skip to content

Lines wider than a pixel are drawn as shifted strokes: Mario Golf: Super Rush's putting and aiming grids - #2352

Closed
secretlemur28 wants to merge 1 commit into
seedds:mainfrom
secretlemur28:wide-lines
Closed

secretlemur28 wants to merge 1 commit into
seedds:mainfrom
secretlemur28:wide-lines

Conversation

@secretlemur28

Copy link
Copy Markdown
Contributor

What and why

Mario Golf: Super Rush (0100C9C00E25C000, 4.0.0, #814) draws its aiming grid and its putting grid with SetLineWidth 4.0. Metal draws 1-pixel lines only, and the host ignored the width (SetLineWidth 4.00: Metal has only 1-pixel lines), so the grids were hairlines: on a green, the moving dashes along the grid lines, which show the slope, could hardly be seen.

The width is now recorded (OP_LINE_WIDTH) and kept in the replay's state. draw() repeats a line draw (primitive 1 or 3) of width w ≥ 1.5 with the viewport moved by whole pixels across w columns and then across w rows, 2w strokes (2w − 1 for an odd w): a plus-shaped pen, so a line of any direction comes out about w pixels across. DM_NVN_LINE_WIDTH=0 draws hairlines as before; the width is capped at 8.

What it is not: a quad expansion. Strokes overlap, so a blended line comes out heavier than one stroke would (Golf's white grid reads as solid white), and a line is not capped or mitred. It seemed the smallest change that makes the widths visible; a geometry-based version could replace it behind the same op.

Checked

Docs

  • docs/reference/rendering.md ("Image clears, dynamic stencil and line width") says what a width above 1 does now; DM_NVN_LINE_WIDTH is in docs/env_switches.tsv
  • No game files, keys or data extracted from a game in the change or the attachments

🤖 Generated with Claude Code

…s recorded, and a line of width w is drawn with the viewport moved by whole pixels across w columns and w rows (Mario Golf: Super Rush's putting and aiming grids are 4 pixels wide; as hairlines the moving dashes that show a green's slope could hardly be seen)

Metal draws 1-pixel lines only and the width was ignored. OP_LINE_WIDTH carries it to the replay; draw() repeats a line draw 2w times (2w - 1 for an odd w) with the viewport shifted, so a line of any direction comes out about w pixels across, a little heavier where strokes overlap. DM_NVN_LINE_WIDTH=0 draws hairlines as before.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions github-actions Bot added nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests) docs Documentation labels Nov 11, 2026
seedds added a commit that referenced this pull request Nov 12, 2026
The profile moved from the provisional one the NSP script wrote, with
subsdk0 in the build row (the NRO imports the movie API from it) and
no patches. Played on an M6: the opening movie, the menus and Standard
Golf on the Rookie Course's first hole at 60 fps (GPU p50 6.5 ms).
The game note lists what is open: tessellated grass, Golf Adventure's
Mii (#2361), the wide lines (#2352), an unexplained black first boot,
no IPA. Reference entries found on this game now link to the note.

Refs #814
seedds added a commit that referenced this pull request Nov 13, 2026
Mario Golf: Super Rush draws its aiming grid at the tee and its putting grid on a
green with SetLineWidth 4 and 5. Metal draws lines 1 pixel wide and the host
dropped the width, so the grids were hairlines and the putting grid's moving
dashes, which show a green's slope, could hardly be seen.

SetLineWidth is recorded (OP_LINE_WIDTH) and kept in the replay's state. A draw
of lines, a line loop or a line strip whose width rounds to 2 or more is the
game's own draw, in its own render pass, with the vertex shader's new wide-line
entry (dmsh_pull.py <entry>_wl, in the pulling library) and 6 vertices a
segment. Each vertex finds its segment's endpoints from its vertex ID and a line
block (the index buffer read on the GPU, restart, base vertex), runs the
shader's body for both endpoints, clips the segment in front of the eye with its
outputs interpolated as the clipper would, and widens its corner: OpenGL's
non-antialiased wide line (Maxwell's), a parallelogram across the minor axis,
or the rectangle across the segment when multisampling is on. Culling is off
and the polygon offset is the one for lines. Indirect arguments are read on the
CPU as the geometry path reads them; an indexed loop with restart, and a vertex
shader without the entry, stay 1 pixel wide with a [RED] line.
DM_NVN_LINE_WIDTH=0 draws every line 1 pixel wide.

Checked: t_wline.m draws through the generated entry on the GPU (lists, loop,
strip, indexed with restart and base vertex, 8-bit indices, instances, an
endpoint behind the eye, the multisampled rectangle; 22 checks).
test_dmsh_pull.py, both lints. Mario Golf on the M6: the tee and putting
grids 4 pixels wide, frame time p50 16.67 ms with and without; on the green
2 fewer passes a frame that load and store everything than a first version
that captured the endpoints in a pass of its own. regress.py check on Bastion
and Return of the Obra Dinn: nothing newly failing, 0 MSL changes, fps equal,
screenshots within their noise. Not checked: iOS, indirect wide lines (no game
seen), multisampled wide lines in a game.

PR #2352 and PR #2510 recorded the width and found the grids' SetLineWidth;
the drawing is new.

Co-authored-by: secretlemur28 <354896836+secretlemur28@users.noreply.github.com>
@seedds

seedds commented Nov 13, 2026

Copy link
Copy Markdown
Owner

Landed on main as 7eaf791, with you as co-author. Thank you: recording the width (OP_LINE_WIDTH) and finding that Golf draws its grids with SetLineWidth 4 came from this PR.

The drawing itself is new. Instead of repeating the draw with the viewport moved, a line draw whose width rounds to 2 or more is drawn as one quad per segment, in the game's own render pass. The vertex shader gets a new wide-line entry in its pulling library (dmsh_pull.py <entry>_wl). Each corner finds its segment's endpoints from its vertex ID, reading the index buffer on the GPU, runs the shader for both endpoints, and widens the line the way OpenGL and Maxwell do: a parallelogram across the minor axis, or a rectangle across the segment when multisampling is on. Blended lines are then as heavy as one stroke, segments meet without overlap, and a segment with one end behind the camera is clipped first. dm/gfx/tests/t_wline.m checks all of this on the GPU.

Checked on Mario Golf (Mac, M6): the tee and putting grids are 4 pixels wide, at 16.67 ms per frame with and without. The details are in the commit message and in docs/reference/rendering.md ("Lines wider than a pixel").

@seedds seedds closed this Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants