Skip to content

Halftone lines shader - #234

Open
uuuulala wants to merge 96 commits into
mainfrom
halftone-lines
Open

Halftone lines shader#234
uuuulala wants to merge 96 commits into
mainfrom
halftone-lines

Conversation

@uuuulala

@uuuulala uuuulala commented Dec 2, 2025

Copy link
Copy Markdown
Member

Note

Medium Risk
Adds a new public shader API and a non-trivial GLSL fragment shader with image sampling and many uniforms. Risk is mainly visual correctness and GPU performance, not security.

Overview
Adds Halftone Lines, an image filter that redraws a photo as a luminance-driven line grid.

The shader supports seven grid types (lines, linesIrregular, waves, wavesIrregular, zigzag, truchet, radial), stroke width/contrast/softness, optional original-image colors vs a two-color palette, grid contouring/noise, and grain mixer/overlay. It is exported from @paper-design/shaders and @paper-design/shaders-react as HalftoneLines with six presets.

Docs get a /halftone-lines playground (Leva controls, sample-image cycling, upload) plus registry and shader-def entries.

Reviewed by Cursor Bugbot for commit 20adf8c. Bugbot is set up for automated code reviews on this repo. Configure here.

grainOverlay: 0,
grainOverlaySize: 0.5,
},
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presets use contain not cover

Medium Severity

All halftoneLinesPresets spread defaultObjectSizing without overriding fit, so they keep contain. Sibling image filters (halftone-dots, halftone-cmyk, fluted-glass) set fit: 'cover', so the default and preset demos letterbox the source image instead of filling the canvas like the other filters.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d9803b7. Configure here.

Comment thread packages/shaders/src/shaders/halftone-lines.ts Outdated
Comment thread docs/src/app/(shaders)/halftone-lines/page.tsx Outdated
Comment thread docs/src/app/(shaders)/halftone-lines/page.tsx Outdated
Comment thread docs/src/shader-defs/halftone-lines-def.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

There are 5 total unresolved issues (including 3 from previous reviews).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 903487f. Configure here.

float offsetScale = u_gridType < 5.5 ? 1. : cellsPerSide;
float contouringPower = abs(u_gridContouring) * ((u_gridContouring > 0. ? contouringLum : 1. - contouringLum) - 1.);

vec3 contouring = vec3(6., .5 * smoothstep(length(uv), 0., 1.), -5.) * contouringPower;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contouring smoothstep args inverted

High Severity

smoothstep(length(uv), 0., 1.) passes edge0 >= edge1 for nearly every fragment, which is undefined in GLSL ES 3.00. That value feeds contouring.y and thus grid rotation whenever gridContouring is non-zero, so contouring rotation becomes driver-dependent instead of a defined falloff.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 903487f. Configure here.

float lum = dot(vec3(0.2126, 0.7152, 0.0722), color);
lum = mix(1., lum, tex.a);
return u_strokeInverted ? (1. - lum) : lum;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stroke invert flips palette colors

Medium Severity

toLum always applies u_strokeInverted, and inkMix uses toLum to blend colorMid and colorFront. Enabling strokeInverted therefore swaps the palette assignment, even though docs say inversion only affects stroke width and leaves colors unchanged.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 903487f. Configure here.

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