Skip to content

Add --flip-normals to vc_render_tifxyz (issue #1044)#1079

Open
robert-kofler42 wants to merge 1 commit into
ScrollPrize:mainfrom
robert-kofler42:feat/render-flip-normals
Open

Add --flip-normals to vc_render_tifxyz (issue #1044)#1079
robert-kofler42 wants to merge 1 commit into
ScrollPrize:mainfrom
robert-kofler42:feat/render-flip-normals

Conversation

@robert-kofler42

Copy link
Copy Markdown

Why

Closes part of #1044. grid_normal computes surface normals with the right-handed convention N = dP/dU × dP/dV. When a segment's text is readable (not flipped in UV space), that normal points away from the scroll centre, so the offset/w sampling direction is the opposite of what's usually wanted. Per the issue this "comes to bite us ever so often," and the reporter notes they'd "just add a flag in vc_render_tifxyz to flip the normals, which I will always enable."

What

  • New core helper flip_surface_normals(cv::Mat_<cv::Vec3f>&) in Geometry — negates each normal in place, leaving NaN-sentinel (invalid) normals untouched so validity is preserved.
  • New --flip-normals switch in vc_render_tifxyz, applied at the single normal-processing chokepoint (prepareBaseAndDirs, used by all three render paths). Off by default → existing behavior unchanged.

Scope is deliberately the lightweight per-render option the issue asks for. It does not change grid_normals globally or attempt auto-orientation — that's scroll/handedness-dependent (the issue itself flags the exceptions, see scrollprize.org/faq#/scroll-2) and is better decided by the team; left as future work.

Verification

  • test_flip_surface_normals (4 cases): negation of finite normals, double-flip identity, NaN-sentinel preservation, empty-matrix no-op — all pass.
  • vc_render_tifxyz compiles with the new option wired through.

grid_normal computes surface normals with the right-handed convention
N = dP/dU x dP/dV. When the segment's text is readable (not flipped in UV
space), that normal points away from the scroll centre, so the offset/w
direction is the opposite of what's usually wanted. This recurs often enough
to bite people (ScrollPrize#1044).

Add a core helper flip_surface_normals(normals) that negates each normal in
place while leaving NaN-sentinel (invalid) normals untouched, and a
--flip-normals switch to vc_render_tifxyz that applies it in the single
normal-processing chokepoint (prepareBaseAndDirs, used by all render paths).
Off by default, so existing behavior is unchanged.

This is the lightweight per-render option the issue asks for; it does not
change grid_normals globally or attempt auto-orientation (which is
scroll/handedness dependent, per the issue) — those remain future work.

Adds test_flip_surface_normals covering negation, double-flip identity,
NaN-sentinel preservation, and the empty-matrix case. vc_render_tifxyz
compiles with the new option.
@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the scroll Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant