Since then I've actually met these two and had to conclude that:
- They didn't have any use-cases in mind that weren't cosmetic
- They don't quite understand how being part of an advertising company shapes how they build and conceive of web tech
- They react quite poorly to reactions that aren't cheerleading
The answer for curved elements was handwaving and "just approximate it with flat projective transforms" which tells you this is not a serious attempt to expose mature UI internals, but just another shiny epicycle on the creaky leviathan that is the HTML5 web api.
The list of features that "automatically work" rests on assumptions that are only valid for minor visual adjustments. The moment you try to use HTML-in-Canvas as a more basic building block, a lot of that falls away.
e.g. Suppose I render a piece of text and then use that as a mask for visual effects. If the browser now draws a text selection highlight into that mask, the text becomes unreadable.
I've read your blog enough times to recognize it instantly, yet it's the first time I notice that you blog header is an animated and interactive 3D demo. Very cool!
The new API confuses me because I can't see what it can really do that you couldn't already achieve by adding some position:absolute elements that float above the canvas. I mean, yes, since it's rendered as a texture, you can apply an arbitrary visual transform… but apparently the input handling is outside your control, so what's even the point? You won't be able to interact with the element properly. I also assume you can't even really occlude things properly? It doesn't make any sense to me.
As a point of comparison: Win32 has APIs that let you draw things like buttons and text input fields without having to instantiate windows (~= DOM elements) for them. Though I'm not quite sure what you can do in the way of input handling without having an actual window. Regardless, browsers manage to contort native controls into funny shapes on behalf of web pages, so the API there definitely offers more possibilities.
The long/lat globe has a bizarre projection that has incorrect perspective. Neither orthogonal nor inverse Z.
The "utah" teapot is not the utah teapot. The handle is also oriented with backfaces showing, and is disconnected from the teapot body.
The "glenzing" example is just regular alpha blending and fill whereas the original glenz effect was about mimicking alpha blend using bitwise tricks on a purposely designed 256 color palette (iirc in Second Reality).
Etc etc.
I don't understand why this stuff is supposed to be impressive when what it really represents is the inability of the person who posted it to spot and fix the errors, ranging from blatantly obvious to subtly historically inaccurate.
Calling this a "museum" is a misnomer. Museums do curation and restoration, not kitschy knock offs.
The plasma effect, for example, uses vertex shaders to calculate in the order of 8 sines per pixel, and then adds some squares and square roots.
Originally, for a plasma effect, one would calculate a sine based value only for each row and each column. For a 320x240 pixel effect, only 320+240 "complicated" calculations were necessary per frame. To combine these at the pixel level, simple adds and bit shifts were enough. This was necessary, because it was entirely impossible to do so many calculations (or even memory lookups) per pixel on old hardware.
The actual effect is nice, but it has little to do with the old demoscene effect :)
I have written many old school plasmas and that does look pretty good to me. Here's one I wrote that looks quite similar https://youtu.be/oX-cepvvQds?t=50 You don't do it once per row or column, and you don't call sine/cosine at all except at init time. You generate lookup tables for cosine, and for each pixel of a (typically mode 13h VGA) 320x200 screen you step through the tables with several counters at different rates and sum the values.
As the post says, beziers are everywhere so we are stuck with them. It's worth trying to improve them for that reason alone.
Additionally B-splines (like Catmull-Rom) have the issue that moving one point affects a larger area of the spline than an equivalent bezier. The local control of beziers makes them more desirable for precise illustration.
As for the formula you cited, it tells you where to put the control point for continuity in function of two scalars, but those scalars don't directly map to intuitive controls. It also doesn't help when moving a curve point while preserving curvature on both sides because it only tells you one side in function of the other. I.e. continuity of curvature is a weaker constraint than having the desired curvature.
I initially experimented with something similar but found that numerical drift would steadily accumulate during interactive editing. The post shows this with the last example before curvature handles: rotating the tangents there preserves curvature continuity but the curve tends to blow up for certain angles, because the tangent is a poor proxy for indicating desired curvature.
Oh Béziers are great and not going anywhere, and I’m not suggesting they should. It’s all about your specific goals. I think B-splines are misunderstood and underutilized, and your comment might be exemplifying that a little. ;) For one, Catmull-Rom is not a B-spline. For two, it’s easy to achieve local control of a B-spline wherever it’s needed (there are two separate ways to do this). For three, and most importantly - note that the goal of the article is to get a smooth join, and the technique in the article is to drop localized control (!) by imposing constraints on both sides of a join point. Using a Bézier for this is more complicated than using a B-spline, for no additional benefit that I can see. Also worth mentioning that uniform B-splines and Béziers are mathematically shape equivalent - it’s trivial to convert between them, so they provide identical levels of control, they’re just slightly different interfaces for the same shape.
Minor edit here to note, it just occurred to me that the curvature constraint affects the curve over a span of 7 control points, whereas editing a B-spline control point affects the curve over a span of 4 control points. B-splines are strictly more localized than Curvature Béziers…
One reason B-splines aren’t well known & used is because seemingly most/all online content launches into the math and discussion of knots. The uniform B-spline doesn’t need knots, and I wish more tutorials would start there rather than intimidating people with the math.
BTW yes you’re right about the ‘scalars’ (the beta parameters) in the G2 curvature matching equation. I haven’t tried this and I don’t know what they do. I was wondering if these might have a relationship to the ‘heuristic’ the Acko article derives? That was kind of my question.
To clarify, I meant B-splines _lack local control_ like Catmull-Rom splines, not that the latter is an instance of the former. Though indeed, all cubic splines are just cubic polynomials.
I disagree with your characterization that the proposed solution lacks local control, because edits only affect the segments in question, just like with a classic bezier. From the point of view of curvature handles, the handles you don't touch don't change. (The splitting of a curvature bezier is imo the best illustration of this.)
Re: the meaning of the scalars, I imagine they are derived similarly as the perpendicular-distance diagram in the post. If you plug bezier formulas into curvature formulas, a lot of terms cancel out.
Ah hehe gotcha, I missed you’re author, and you were saying CatRom and B-splines have similar locality. I feel like talking about local control’s a bit iffy. In a spline with multiple cubic segments, I think a control point edit is going to affect about the same span of arc length with all three bases Bézier, CatRom, and B-spline, no?
My claim that the Curvature Bézier has less locality, of course, was based only on editing one of the Bézier’s shared join points. When you edit a shared point’s position (by moving an anchor) or tangent (by moving either of the interior control points), you are affecting 2 segments, not just one, hence the 7 control point span. I’m being a bit sloppy but I’m sure you understand what I mean there - the portion of curve affected by a single control point edit technically affects a section of the curve that’s fully determined by exactly 7 consecutive control points. (Assuming cubic!)
Re-thinking B-spline, I believe I goofed - editing a control point affect 4 consecutive curve segments, which is the non-locality you’re referring to, but which is also a span of 7 control points, so very similar to editing one of the constrained Bézier’s shared anchor points. The window of which 7 control points slides smoothly with B-spline: the edited control point is the middle of the 7 control point span. With a curvature-constrained Bézier, each shared anchor and its two surrounding control points affect the curve defined by the same 7 control points.
So yes cubic Bézier segments that aren’t constrained in any way (i.e., the “cusp” and “corner” types), sure those have a kind of ‘locality’ in that editing the two interior control points affects only the 1 segment defined by 4 control points. But as soon as you add constraints on the tangents, neighboring segments affect each other, and your control naturally becomes less ‘local’, right?
So anyway, given that adding constraints to Bézier splines will cause neighbors to affect each other and control point edits are no longer confined to a single segment, are there other reasons to stick with Bézier?
Sorry but you're missing the forest for the trees here.
The locality of a bezier, even with symmetric constraints, amounts to the fact that the user's specified positions (the endpoints) and tangent directions are preserved exactly and can be modified independently. This makes detailed edits easy. And because curvature beziers only differ from classic beziers in the tangent lengths (not directions), the same properties hold.
The "7 control point span" you talk about is really a 5 point span, because adjusting the lengths of the bezier tangents at the far ends serves to explicitly preserve the user's intent, namely the radius of curvature.
Catmull-Rom e.g. ties together the tangent at a control point with the position of the previous and next control point. And B-splines don't guarantee going through any control point at all except the endpoints, with the tangents not even independently controllable.
It is likely I’m missing something, that’s why I’m asking. ;) I don’t have any experience with curvature Béziers. I don’t understand what you mean about the 5 point span, could you elaborate? With a symmetric tangent Bézier constraint, adjusting either a shared anchor, or adjusting a tangent direction or length, will result in some amount of non-zero movement in two Bézier segments, not one, right? I believe a curvature preserving constraint will do exactly the same, no? Preserving the user’s curvature intent across Bézier segments anchors is a worthwhile goal, but that does come at the cost of always modifying two Bézier segments at a time, doesn’t it? Are you suggesting that meeting the user’s curvature intent across segments doesn’t affect spline locality? And BTW we are talking about spline locality, right? I should have asked for clarification earlier. Control points within in a Bézier segment don’t have any locality, technically; move one and the entire segment must be recomputed. This is how I ended up at 7 control points - it’s all 4 control points of 2 consecutive segments with 1 shared anchor. I don’t understand how an edit to a cubic Bézier spline could correspond to a 5 point span.
It’s true B-splines are approximating and Béziers are considered interpolating (even though 50% of the control points are approximating), and that very well might be the primary or even only reason to choose Bézier for many design goals. It’s also true that with uniform B-splines you can choose to interpolate any given control point at the small cost of duplicating control points (and of course non-uniform B-splines have additional ways).
My only observation, of course, is just that B-splines have the built-in property that curvature is smooth across segments, so if that’s your main goal for a given task, they seem like a decent choice if you can accept the tradeoffs. It is, of course, possible to mix and match curve types.
Placing points at X/Y extremes is by itself useless because beziers are rotation invariant. i.e. If that's the best place for the control points, then by the same argument if you rotated the curve by 45° the points would need to be on diagonal extremes. It's only useful with typography where many letters are oval. IIRC this rule originated because buggy rendering code assumed the curve would never extend beyond the XY bounding box of the control points.
Placing nodes at inflection points is actually a bad idea because there are very few configurations where curvature remains continuous. It's better to construct S bends with the inflection point in the middle, because then you always get a smooth transition.
Picking a specific spacing between control points makes it more likely that equal tangents represent approximately the same curvature on both sides, but it's not guaranteed either.
A notable context where the the on-curve node placement rules do matter is font design where the node placements interact with hints and are useful for ensuring consistency and consistent rounding when filling in pixels.
Further, these rules facilitate using the shift key to constrain off-curve node placement to in-line w/ the matching on-curve node horizontally or vertically.
By line you mean a Bézier curve with no acceleration? As opposed to (say) a cubic with control points [(1,1),(2,1),(8,1),(9,1)] which makes a straight line but has a non-uniform parameterization?
You can try to make the WebGPU API more declarative, but the issue that you still run into is that individual draw calls and passes are a poor abstraction level to express modern rendering in.
To reach the quality of a modern PBR renderer with shadows, SSAO, temporal denoising and the like, you need to lower one conceptual draw into multiple concrete draws, sequenced in a particular way, to their own targets, and I haven't seen a lot of success in this space because the shaders need to become polymorphic.
these are very good points, with my attempt the only run-time polymorphism is a switch inside a shader. Maybe we can exploit the pipeline constants and then branch on them, still feels like a hack, but could work for a poor man approach.
I have never done advanced/modern rendering things, just 2D/vector/sdfs and hacks, but your comment is food for thought, in that in this level of abstraction these are somewhat open problems.
But we are still in the dark ages where industrial standards are not public.
reply