14,081 karma · joined Mar 7, 2014 (12y ago) · 1,887 submissions
comment 5y ago · link · parent
comment 5y ago · link · parent
994.
The Hyperbezier Pen Tool(cmyr.net ↗)
120 points · by raphlinus · 5y ago · 22 comments
comment 5y ago · link · parent
comment 5y ago · link · parent
For the most part, when looking at a monitor, chromatic adaptation is pretty good. In other words, RGB #FFFFFF looks white, not light blue, and #808080 looks gray, not bluish-gray. It does start falling apart when you mix different lighting, for example holding a white piece of paper to the screen under normal room light.
I think the main reason D65 is chosen for the sRGB white point is that it is fairly accurate, in other words it's pretty close to the actual white point of the monitor I'm looking at now (Dell P2415Q).
I have yet to find a source on chromatic adaptation that I consider a really excellent tutorial. Certainly the Wikipedia page is cursory and abstract, which is a shame.
comment 5y ago · link · parent
The tl;dr as I understand it is that there may be something there, but it is too early to tell for sure.
comment 5y ago · link · parent
I think doing this right will require some imagination, not just playing greatest hits from previous decades, only in a new language.
comment 5y ago · link · parent
Rust makes it easier to bind platform capabilities at a low level than most other languages. As an example, we do cut'n'paste cross-platform, supporting complex media types, not just plain text, so we can round-trip a vector glyph from Runebender to other font editors. I think that's a taste of being able to take on these more ambitious challenges.
Also, "native" UI toolkits are a lot less actually native than they used to be. On Windows, the old HWND-per-control and GDI drawing model (long considered the standard for "native" Windows UI) is long obsolete, and there are actually a whole bunch of toolkits that people use, with UWP the most actively supported. Apple has a stronger story, but even there you have AppKit + SwiftUI, and technically Catalyst is officially supported, though nobody would argue it's actually a good experience.
And the fact is, a lot of people are using Electron, because it actually solves the business problem of delivering good-enough UI. I think we have a good shot at competing against that niche, and also that building it on Rust is a more solid foundation than any other language ecosystem.
comment 5y ago · link · parent
I obviously consider Druid to to be one of the most promising approaches, but even that aside there are other projects that could become a solid GUI toolkit, including Iced. I also encourage people to look at Makepad, as it does a lot of innovative things and emphasizes priorities such as small binary size and fast compile time.
comment 5y ago · link · parent
And also thanks for the kind words about my writing. I consider education to be a pretty big part of my personal mission, and take care to write clearly, explicitly trying to minimize controversy and misunderstanding (if you optimize for clicks or number of comments, it often takes you in a different direction). And sometimes my blog posts take a long time to gestate. "The compositor is evil" was 18 months from concept to publication, 11 of which were in my private repo. It's nice to hear that people appreciate the effort.
comment 5y ago · link · parent
I'll not speak to OSS generally, as I'm sure other people have more insight than I do, but specifically within the Rust ecosystem, I can confidently predict corresponding numbers increasing significantly.
comment 5y ago · link · parent
It's definitely possible to build something yourself using Allsorts and other pieces, but making it all work well is a highly nontrivial task. Part of the problem is that there are a bunch of projects out there, each with their own subset of requirements, rather than one good one.
I'd like to mentor work to make this situation better, but it's too much for me to take on single-handedly.
I'm also hoping that WebGPU catches on, and we'll be able to run piet-gpu on it (through wasm). That would, I think, be compelling for a lot of interesting use cases.
comment 5y ago · link · parent
I wrote about this a bit in a sibling comment, but making piet-gpu real is a major goal and probably the main reason I got the gig. It's speculative in some ways because it's trying to do things in a new way, but if it works out as well as I hope, it's pretty easy to see why it's worth doing.
comment 5y ago · link · parent
But I'll give a brief teaser here anyway. The new spline is a hybrid between Spiro and cubic Béziers, with (I hope) the best features of both. Spiro is good for smooth curves but not so good when you need to crank up the tension. Béziers, by contrast, can do tension just fine, but aren't very smooth (one technical manifestation is that curvature maxima tend to happen near the segment endpoints, but rarely on them, especially for S-shaped curves).
Something that's particularly difficult for Béziers is a smooth transition from a straight line segment into a curve, which is important for U-shaped letters. Unless you take special care, the curvature jumps right up to some nonzero value at the join point. But with the new spline, it's continuous by default, unless you explicitly drag the control handles to make it not so.
It's difficult for people to learn to draw well with cubic Béziers, but obviously people climb that learning curve (so to speak) and get great results. Even so, I wonder if there's a bit of Stockholm syndrome, of being attached to that way of working just because of the amount of pain that's gone into the process of learning it.
comment 5y ago · link · parent
comment 5y ago · link · parent
But as long as we're here, feel free to AMA, and I'll do my best to answer.
comment 5y ago · link · parent
My current target is a GPU that can do compute shaders, and also has descriptor indexing. That includes DX12, Metal 2.0, and most desktop Vulkan. It leaves out DX11 and OpenGL. Mobile is complicated; I don't expect it to work on most legacy Android devices.
The need for descriptor indexing can be worked around, which I think in practice brings Android with Vulkan back in the fold, and it's possible DX11.
It's more a function of API and driver than actual hardware, except for very old and low-spec stuff. I suspect that Raspberry Pi up to 3 is off the table without massive work, but that Vulkan drivers on the 4 will catch up. (I have a Raspberri Pi 4 and intend to use it as a compatibility target, along with a Pine64)
I hope that clarifies the situation. GPU compute was not mainstream at all (aside from CUDA, which has been around a while) and until quite recently, targeting it would seriously limit an app. I do think that's changing, even on inexpensive hardware.
comment 5y ago · link · parent
I think a good blog post that motivates some of the main differences between 2D and 3D in the GPU context is this one: https://blog.mecheye.net/2019/05/why-is-2d-graphics-is-harde...
comment 5y ago · link · parent
For GPU programming, I have a list of resources here: https://raphlinus.github.io/gpu/2020/02/12/gpu-resources.htm..., and also a talk here: https://www.janestreet.com/tech-talks/a-taste-of-gpu-compute...
Re 2D graphics, a long term ambition of mine is to write a book on the topic (and I have a repo started with a rough, bullet point outline), largely because I don't know of any source that brings the concepts together. I don't think I'll be able to spend significant time on it, though, as I have my hands pretty full. I am hoping to do more explaining and public communication as part of my piet-gpu work.
A good snapshot of GPU font rendering work from 3 years ago is: https://aras-p.info/blog/2017/02/15/Font-Rendering-is-Gettin... . The linked papers are quite good and have informed my thinking, though of course I hope to advance the state of the art even further.
comment 5y ago · link · parent
A few things might help put this in context. First, Druid well predated Runebender, though Runebender is now the "hero app" (before, it was xi-editor, now on the back burner).
Second, I have a lot of experience doing high performance 2D and font rendering, from libart to working on the PDF 1.4 blend modes in Ghostscript to font-rs. I've also been curious about GPU for a while, not least because that was what was actually painting the text on Android, and I worked on the Android UI team for almost 5 years. So now that GPU compute is becoming mainstream, I see an almost unique opportunity to apply my skills there.
Third, I'm not doing all this by myself. I'm deliberately trying to cultivate open source community involvement and, really, building a team, though it has diffuse borders. Now is also a good time to acknowledge my long-time collaboration with Colin Rofls, who does a huge amount of the day to day work on both Runebender and Druid.
Lastly, I published this in advance of a career move, which is becoming a research software engineer on the Google Fonts team. I believe this is a perfect position for me to continue pushing this research agenda forward, and I'm hoping will bring more resources and focus.
There is no chance of me getting bored doing this. Burnout is something I'm watching carefully, as I have experienced it (it was the end of my time on Android), but one thing I discovered in my 2.5 years away from being a full-timer at Google is that graphics research is what I love the most, and would probably be doing even if it wasn't also a good career move.
comment 5y ago · link · parent
I'm going to expand on this a bit, possibly against my better judgment. I believe Paul Graham has a point here, and it's a good one. In intellectual pursuits, there's a spectrum from dealing purely with nature and facts, to dealing with human perceptions. To pick what I hope is a reasonably neutral example, doing the science to get containment of a fusion reaction is on one end of the spectrum. Planning and engineering a project to do it is in the middle. And making the case that carbon-based energy production poses an existential threat to humanity and that we should be investing hundreds of billions into fusion energy is on the other. All these inform each other, and I (personally) don't make a value judgment on which is most virtuous or most important.
The salient thing is that Paul Graham did not choose a somewhat neutral example. Rather, he chose one that is perhaps at the very center of the culture wars, and has done so using a highly emotionally loaded word. Because he is someone who knows how to use words, I can fairly confidently conclude that he is effectively declaring his position on the issue.
comment 6y ago · link · parent
I'll also do my best to answer your questions, though I won't be able to do them justice in this space.
A pretty good model for GPUs is remote procedure calls. When you want to do something like draw some triangles, you call a function in the GL API on the client side, and what the driver actually does under the hood is serialize the parameters of that call into some binary sequence, then at some point that "command buffer" is uploaded to the GPU, and a combination of hardware and software on the GPU side decodes it and uses it to set up the hardware pipeline that actually draws a triangle.
There's a lot more to it than that, obviously. A very big deal is that if you did an actual RPC for every triangle draw, it would be hopelessly inefficient. So a large part of what OpenGL drivers do is use heuristics for batching up a bunch of calls into one actual request. In OpenGL, the details of that batching, and the way the command buffer is encoded, are completely hidden from the application.
Shaders are basically small pieces of code that get run on the GPU hardware as part of the rendering pipeline. A vertex shader is a program that gets run every vertex in a mesh, and a fragment shader is another program that gets run for every fragment (pixel) that gets rasterized. There are other shaders that are run for other tasks, but those are the two biggies. In the early days of OpenGL, lighting calculations and so on were done by "fixed function" hardware, but these days it's programmable.
In classic OpenGL, you call a function to compile a shader from a string containing GLSL source code, and the driver compiles it to machine language for the GPU hardware. You can use Radeon Shader Analyzer (available online at http://shader-playground.timjones.io/) to see what that assembly language looks like.
Even just to understand OpenGL better, it might make sense to learn about Vulkan. A good (though somewhat daunting) resource is "API without Secrets: Introduction to Vulkan": https://software.intel.com/content/www/us/en/develop/article... . In Vulkan, the batching and other aspects of resource management are much more explicit and under control of the application, though other details are still abstracted by the driver. For example, there is no one standard binary format for encoding command lists. Also, instead of the driver compiling shaders all the way from source, the application is responsible for compiling the shader into an intermediate language (SPIR-V), then the driver compiles that to the actual GPU machine language.
There are some other low level GPU resources here: https://raphlinus.github.io/gpu/2020/02/12/gpu-resources.htm...
Best of luck, I find GPUs to be a fascinating journey!