- 381
- 698 250
sphaerophoria
Приєднався 16 жов 2011
Building square wheels to better appreciate the round ones.
Extracting glyphs from a font file (it's not easy)
Stream from November 22, 2024 at twitch.tv/sphaerophoria
Join on youtube for happy hour vods ua-cam.com/channels/XzL31BCxf8En1KT34gSK6g.htmljoin
Or on patreon patreon.com/sphaerophoria
00:00 Intro
06:40 Find glyph points
01:24:55 Extract curves
Join on youtube for happy hour vods ua-cam.com/channels/XzL31BCxf8En1KT34gSK6g.htmljoin
Or on patreon patreon.com/sphaerophoria
00:00 Intro
06:40 Find glyph points
01:24:55 Extract curves
Переглядів: 1 004
Відео
Font files are kinda whack
Переглядів 2,9 тис.2 години тому
Stream from November 22, 2024 at twitch.tv/sphaerophoria Join on youtube for happy hour vods ua-cam.com/channels/XzL31BCxf8En1KT34gSK6g.htmljoin Or on patreon patreon.com/sphaerophoria 00:00 Intro 02:45 List tables 27:30 Find the glyph for A
Generating 3D geometry to draw a 2D picture
Переглядів 1 тис.7 годин тому
Stream from November 22, 2024 at twitch.tv/sphaerophoria Join on youtube for happy hour vods ua-cam.com/channels/XzL31BCxf8En1KT34gSK6g.htmljoin Or on patreon patreon.com/sphaerophoria 00:00 Intro 09:15 Generate some cones 46:50 Generate some tents 01:11:30 Use cone in opengl 01:51:50 Use the cone a lot of times
Distance fields, paintbrushes, shaders, and OpenGL hell
Переглядів 1 тис.12 годин тому
Stream from November 20, 2024 at twitch.tv/sphaerophoria Join on youtube for happy hour vods ua-cam.com/channels/XzL31BCxf8En1KT34gSK6g.htmljoin Or on patreon patreon.com/sphaerophoria 00:00 Intro 06:10 Add a drawing view 40:20 Make a distance field 57:20 OpenGL wants to see me hurt 01:42:40 Back to distance fields
Auto-generating UI for editing shader uniforms
Переглядів 1,3 тис.14 годин тому
Stream from November 19, 2024 at twitch.tv/sphaerophoria Join on youtube for happy hour vods ua-cam.com/channels/XzL31BCxf8En1KT34gSK6g.htmljoin Or on patreon patreon.com/sphaerophoria 00:00 Intro 05:13 Find uniforms in shader 19:08 Add UI to edit shader image uniforms 01:04:45 Floating point uniforms 01:30:00 Color/vec3 uniforms
I wrote an image editor to make this thumbnail
Переглядів 1,5 тис.16 годин тому
Stream from November 18, 2024 at twitch.tv/sphaerophoria Join on youtube for happy hour vods ua-cam.com/channels/XzL31BCxf8En1KT34gSK6g.htmljoin Or on patreon patreon.com/sphaerophoria 00:00 Intro 02:54 Fix broken scaling behavior 34:20 Implement rotation 01:42:50 Eat some dog food
Scaling items in my image editor was way harder than I expected
Переглядів 97421 годину тому
Stream from November 16, 2024 at twitch.tv/sphaerophoria Join on youtube for happy hour vods ua-cam.com/channels/XzL31BCxf8En1KT34gSK6g.htmljoin Or on patreon patreon.com/sphaerophoria 00:00 Intro 03:50 Composition editing 36:38 Oops, we have to refactor 01:28:08 Implementing scaling
My love hate relationship with coordinate transforms
Переглядів 1,1 тис.День тому
Stream from November 15, 2024 at twitch.tv/sphaerophoria Join on youtube for happy hour vods ua-cam.com/channels/XzL31BCxf8En1KT34gSK6g.htmljoin Or on patreon patreon.com/sphaerophoria 00:00 Intro 05:10 Aspect ratio fix 40:00 Background checkerboard 58:25 Viewport zoom/pan 01:20:20 Composite view fixes 01:36:10 Path generation fixes 02:04:00 Tracing the queen
Implementing cut/paste for my image editor
Переглядів 2,2 тис.День тому
Stream from November 13 2024 at twitch.tv/sphaerophoria Join on youtube for happy hour vods ua-cam.com/channels/XzL31BCxf8En1KT34gSK6g.htmljoin Or on patreon patreon.com/sphaerophoria 00:00 Intro 04:02 Render any path 48:00 Find closest path point 58:00 Edit path points 01:03:47 Add path points 01:16:50 Save support 01:23:00 Mask from path 02:26:20 Apply mask
Our image editor is starting to resemble something useful
Переглядів 1,7 тис.День тому
Stream from November 12 2024 at twitch.tv/sphaerophoria Join on youtube for happy hour vods ua-cam.com/channels/XzL31BCxf8En1KT34gSK6g.htmljoin Or on patreon patreon.com/sphaerophoria 00:00 Intro 07:15 Add a composition object 46:45 Render object list in UI 01:22:04 Add metadata view 01:33:24 Add shader objects
Using GIMP is hard. Writing my own GIMP from scratch is easy.
Переглядів 4,4 тис.14 днів тому
Stream from November 11 2024 at twitch.tv/sphaerophoria Join on youtube for happy hour vods ua-cam.com/channels/XzL31BCxf8En1KT34gSK6g.htmljoin Or on patreon patreon.com/sphaerophoria 00:00 Intro 07:30 Make a window 21:15 Render a quad 28:32 Load an image 49:30 Apply some transforms 01:02:38 Move object around screen 01:52:25 Save/Load
The linux clipboard is kinda whack
Переглядів 3,3 тис.14 днів тому
Stream from November 9 2024 at twitch.tv/sphaerophoria Join on youtube for happy hour vods ua-cam.com/channels/XzL31BCxf8En1KT34gSK6g.htmljoin Or on patreon patreon.com/sphaerophoria 00:00 Intro 05:30 Get anything from the clipboard 01:04:10 Proper image handling
Our PNG decoder actually works
Переглядів 1,2 тис.14 днів тому
Stream from November 8, 2024 at twitch.tv/sphaerophoria Join on youtube for happy hour vods ua-cam.com/channels/XzL31BCxf8En1KT34gSK6g.htmljoin Or on patreon patreon.com/sphaerophoria 00:00 Intro 04:35 Fix up filter 09:40 Understand paeth filter 47:20 Implement paeth filter
Our PNG decoder is better, but not good
Переглядів 1 тис.14 днів тому
Stream from November 7, 2024 at twitch.tv/sphaerophoria Join on youtube for happy hour vods ua-cam.com/channels/XzL31BCxf8En1KT34gSK6g.htmljoin Or on patreon patreon.com/sphaerophoria 00:00 Intro 04:45 Manufacture some PNGs 01:03:50 Try sub() filter 01:45:30 Implement up() filter
I wrote a cursed PNG decoder
Переглядів 3,2 тис.14 днів тому
Stream from November 6, 2024 at twitch.tv/sphaerophoria Join on youtube for happy hour vods ua-cam.com/channels/XzL31BCxf8En1KT34gSK6g.htmljoin Or on patreon patreon.com/sphaerophoria 00:00 Intro 02:30 Figure out overall structure 25:35 IHDR 40:42 IDAT 01:49:55 Interpret image data
My GPU rendered it's first 3D opengl app (poorly)
Переглядів 1,4 тис.21 день тому
My GPU rendered it's first 3D opengl app (poorly)
Our gpu's first attempt at a real 3d opengl pipeline (owie)
Переглядів 1,4 тис.21 день тому
Our gpu's first attempt at a real 3d opengl pipeline (owie)
Perspective corrected triangle interpolation
Переглядів 71821 день тому
Perspective corrected triangle interpolation
Happy hour: Massive XML parser internal improvements
Переглядів 1,9 тис.28 днів тому
Happy hour: Massive XML parser internal improvements
40 days later, our fake GPU finally drew a triangle
Переглядів 2,3 тис.28 днів тому
40 days later, our fake GPU finally drew a triangle
My GPU driver finally ran a shader on some vertices
Переглядів 1,3 тис.Місяць тому
My GPU driver finally ran a shader on some vertices
My software lets me re-watch tv shows now :)
Переглядів 2,1 тис.Місяць тому
My software lets me re-watch tv shows now :)
I can't watch TV until I write more code
Переглядів 2,5 тис.Місяць тому
I can't watch TV until I write more code
OpenGL actually does something on my (virtual) GPU
Переглядів 1,2 тис.Місяць тому
OpenGL actually does something on my (virtual) GPU
You implement specs just like I do - by passive-aggressively ignoring them. But jokes aside, I love your channel and the projects you do. Keep up the good work!
Yeah I think I mentioned it on your stream but I did an rudementary font renderer/parser no curves just lines. Legit took me a week or two. It's not just you who got the shapes upside down and pretty much all the issues you encountered.
Awesome video! Have you committed to trying content full time yet, or are you still just on a break? If on a break, best of luck trying to go full time on this!
We've extended the experiment a little :).
Another banger. Btw, I was wondering, what theme do you use in your terminal / vim / nvim? Looks pretty good on the eyes.
it's kinda f'd up. I think I'm using alacritty defaults + sonokai in nvim + termguicolors off lol
@@sphaerophoria Classic. Even if you want to get the themes synced up, sometimes they just don't match between nvim / terminal / vscode/ etc. distributions. Kind of sad. Anyway, keep up the good work, very inspiring!
I love your videos man, You've been a great inspiration
Bro just found the most complicated way to do min(distance(uv, p)).
I'm explicitly trying to avoid calculating the distance to all points on all lines for each pixel :)
@sphaerophoria that's fair - I was curious and implemented this solutions on a 1000x1000 webgl canvas I can draw a poly line with 1000 points at 150 fps. Pretty slow yes but you can in theory save the result to a framebuffer and redraw only when you update the points. I wanted to mention it on today's stream but it's not 100% working yet.
Yeah, it's likely "good enough" to do it the stupid way, but this is also just kinda neat :D
Sebastion lague made a video on this a little bit ago, it was a very interesting topic. Never realized how much goes into the rendering of fonts
i swear to god font files are a mess. ttf, otf, woff, and woff2, all of them are a pain in the ass. i'm working on a font manager, and trying to get all data from the font files is just painful.
off topic but just wanna say I love having your videos on as background noise for while I program, they are oddly very motivational lol
Does this example assume ASLR was disabled so that the function address would be the same on each run 🤔
WIP code up at github.com/sphaerophoria/font-rendering/blob/master/src/main.zig Some extra proof that the version of the code that returned A == 1425 is correct. If we run that for all letters we see what seem to be sane offsets with some form of semi-sane incremental movements/glyph table ranges glyph index for A is 1425 (233324..233424) glyph index for B is 12 (1636..1836) glyph index for C is 13 (1836..1996) glyph index for D is 18 (3204..3328) glyph index for E is 22 (3896..3988) glyph index for F is 31 (5556..5636) glyph index for G is 32 (5636..5840) glyph index for H is 37 (7036..7116) glyph index for I is 39 (7252..7336) glyph index for J is 48 (8924..9052) glyph index for K is 49 (9052..9140) glyph index for L is 51 (9252..9308) glyph index for M is 56 (9684..9784) glyph index for N is 57 (9784..9864) glyph index for O is 63 (10780..10940) glyph index for P is 75 (13756..13884) glyph index for Q is 77 (14028..14212) glyph index for R is 78 (14212..14392) glyph index for S is 82 (15088..15312) glyph index for T is 87 (16512..16576) glyph index for U is 91 (17032..17208) glyph index for V is 102 (19884..19952) glyph index for W is 103 (19952..20076) glyph index for X is 108 (21088..21184) glyph index for Y is 109 (21184..21264) glyph index for Z is 114 (22032..22120) glyph index for [ is 623 (122028..122100) glyph index for \ is 580 (115536..115584) glyph index for ] is 624 (122100..122172) glyph index for ^ is 1402 (230796..230872) glyph index for _ is 600 (118576..118636) glyph index for ` is 1418 (232540..232604) glyph index for a is 118 (22768..23032) glyph index for b is 129 (28548..28772) glyph index for c is 130 (28772..28920) glyph index for d is 135 (29848..30072) glyph index for e is 139 (30856..31028) glyph index for f is 150 (33464..33572) glyph index for g is 151 (33572..33980) glyph index for h is 156 (35988..36096) glyph index for i is 158 (36228..36368) glyph index for j is 169 (38116..38248) glyph index for k is 170 (38248..38340) glyph index for l is 172 (38456..38548) glyph index for m is 177 (39088..39292) glyph index for n is 178 (39292..39424) glyph index for o is 184 (40408..40536) glyph index for p is 198 (43516..43700) glyph index for q is 200 (43864..44056) glyph index for r is 201 (44056..44184) glyph index for s is 205 (44688..44848) glyph index for t is 211 (46216..46336) glyph index for u is 215 (46868..47008) glyph index for v is 226 (49440..49508) glyph index for w is 227 (49508..49604) glyph index for x is 232 (50188..50284) glyph index for y is 233 (50284..50412)
By coincidence I just found a project somebody made that implements a disassembler for an 8-bit CPU as a font using all these crazy font rules!
That sounds pretty sick, I've seen another one where a guy bakes an LLM into one
2:02:00 unless I'm missing something that was a difference of 100, not 0. Another victim of doing live math. Weird for "A" to be so far out but it also is in the glyph table somehow.
Oh my god you're right. I've been double checking my work and keep getting that exact same value with different methods, so it seems likely to be correct. I just thought it was wrong because I thought 100 == 0 Thank you for the shout
Fonts are one of those things that you go like: "ahit is just some text in a screen that is probably easy as fuck, we discovered how to do this like in the 90s" and then you regret everything you said
Well they discovered how to do that in the '70s (output was to printers before then). The crazy shit started to appear at the start of the '90s but most people ignored most of it until... emoji!
The impossible task, at least for me, has been achieving subpixel-perfect rendering through hinting. There are so many subpixel layouts, and while standards like EDID (DDDB) exist to access the layout, not all manufacturers include them. This makes it nearly infeasible to support every layout unless the user manually specifies the subpixel geometry or uses grayscale antialiasing.
here is a "fun" fact: the PDF standard has still not been updated with support for continously variable fonts, and a bunch of those have been shipping with Windows/Office since like 2018... I found out the hard way myself, also there is a bug in Adobe Acrobat (a bug in Adobe software? shocking, I know...) where PDFs with custom fonts embedded as vector graphics are not rendered correctly (which is the only workaround for the standard not getting updated).
Also "Ubuntu" font supremacy.
As someone who watched a dense 2 hour documentary on how font rendering works. I wish you luck, it fucking sucks lol
You got the name of the doc, sounds interesting
Could be Sebastian Lague's video on Rendering Text. It's a great video. It could be called "edge cases: the movie".
@@aspzx ahh yeah watched that one before, really enjoyed it
zig's reader has functions to read values with a given endianness instead of doing bigToNative
Oh reader.readStructEndian does seem a lot like what I want
me: please tell me how to parse your file format also me: k but don't use words to do it
If you need words any old LLM can do that.
I too would like to be able to beam abstract concepts directly into my brain, I get what you mean... Slogging through all the words is THE #1 pain for me.
First
To stutter and speaking with lightning speed is not a good combination. And telling every minute not knowing something do not help to create confidence at the audience that this video may be helpful. You lost me after 10 minutes....
believe it or not, not every video on the internet is a course tailor made for you
2:19:44 the way you can see the individual cones reminds me how people created drawing programs in scratch or something by just drawing a bunch of circle sprites when you click lol
I'm all for abusing the 3d pipeline but this is domestic violence. 😨
You have width * height pixels*number of propagation steps and only n points depending on your stroking technique. I don't know how many but I assume less so if you need a distance field just send all the points in a buffer to the vs and evaluate all the points for every pixel. You can also have your data in buckets based on the screen position, bucket[point_x % bucket_width, point_y % bucket_height], in the vs you would classify that pixel in a bucket and you would evaluate the distance to all the points in it. Empty buckets get closes points from neighbors. If all of them are empty you expend the search.
You can rasterize the distance field as a depth map with a specific set of instancing of cones and tents. Search for the publication "Fast Computation of Generalized Voronoi Diagrams Using Graphics Hardware"
Oh that's very clever. Thanks for the info, I'll definitely be looking into this
cracked
this an awesome project.
bro. how the hell do you even learn this stuff? this is awesome.
Trial and error I guess. Working with anything 3d kinda opens the door for a lot of this. A good starting point is ua-cam.com/video/wiYTxjJjfxs/v-deo.html After this, just working with manipulating objects in 3d and playing with some opengl is basically all the pre-reqs to anything we've done here
@@sphaerophoria thanks for sharing the context for this. Were you into game development at some point?
bro reading in 2x speed
s/reading/making stuff up while the docs happen to be open/
1:50:20 awesome haha
Thinking about it more, and watching the VOD back, I think that we kinda accidentally invented a "world" coordinate system. There are three transformations we were talking about a lot here 1. Take plane of [-1, -1]->[1,1] and scale one dimension to match the aspect ratio of the image it represents 2. Position the object after aspect ratio correction within the composition 3. Squish everything to make it aspect correct within the composition render 2. is essentially a model -> world transformation 3. is essentially a world -> view transformation The only odd thing here compared to when we work in 3d is that the input object has these weird broken coordinates. Since all images are rendered in the [-1, 1] -> [1, 1] plane, we have to fix them when we convert them into world space. We could probably merge matrices 1 and 2, but it might be beneficial to keep them separate. That way we can easily completely reset the transform to mean "fill a 1x1 box in world space in whatever way takes up the most space"
11:13 😂
You can reuse path code for scaling, create rectangular path for scaling and then you can get scale as <original obj dimensions>/<path dimensions>
Wide Cersi is new best meme
This guy is a freaking programming terminator!
you are doing it to yourself by having object space normalized to -1..1 instead of counting pixels like a normal person
In Soviet Russia coordinate transforms love hate you.
This seems like its going to be really good for fanbox enjoyers
What happened to the ball machine?
I haven't found a succinct way to explain the project, so there isn't space on the side
It was too mesmerizing 😂
a cool functionality would be scaling the image (super-resolution) without degrading the image quality
this is unfortunately not how image rescaling works, doing scaling will always require some level of interpolation. You can get 'better' upscales with more complex interpolations like bicubic etc, but the best method often depends on the specific image and output your are looking for.
I've heard super resolution in the past refer to AI based upscaling, which could give you something that has more pixels with "more detail". I could see that being useful in cases where you don't really care about reality Either way I won't do it :)
@@sphaerophoria ok
Is there any prerequisite to this like i know C/C++ and rust?
Hey man, I've been really enjoying your vids. I'm shocked that your viewership and comments are so low. I don't know if maybe you could collab with Tsoding or ThePrimeagen? I think you and Tsoding would have a pretty major overlap in viewership.
The UA-cam alg brought me here after watching tsoding and Andreas kling for a while.
Just wondering, if the "flat" nature of the project an artefact of getting to a working product fast or a design choice ? (By flat, i mean that the only textures are loaded image and the window background)
I dont think I understand the question
@sphaerophoria I was under the impression that this kind of app would have a lot of intermediate texture (shader on texture A, texture A get feed on a second shader to render on texture B, which becomes input for another shader rerendering over texture A,... Eventually binding to the window) ((Some kind of "nesting" of the renderer)) From what I understand, your app has one texture for each image and the buffer for the window. I was wondering if this was a design choice or just an early stage of the app.
~ 1:23:00 (still watching at the time of commenting) - i was expecting an even dumber/easier/faster solution: let opengl render the polygon and use the output as the mask 😅 you could also use shaders to modify the edges and such (for feathering and whatever) right at mask creation
I could be wrong about this... Last time I looked this up it seemed non trivial to go from an arbitrary set of points to a set of triangles. This seemed like the easiest way in the like 35s i thought about it lol
@@sphaerophoria oooh, right.. they deprecated GL_POLYGON. sad times
you always have fun projects but I just don't have the time. Sacrificial comment for the algo
Hello sir Sphaero ! It's me again, from the breakout chamber ! Unfortunately the version of the chamber you accepted was using partial rendering, as I thought it would work given the comment of the render function, but the main simulation apparently requires a full render instead. So I have submitted a new version doing a full render each frame, hope this one will work ! Regards, thank you for your nice explorative videos and fun programming projects !
I assumed it was a bug on my part, it worked fine in chamber testing so there's something wrong that I have to look into. Sorry for the pain! Thanks again for the submission!
Clipboard is something I've looked at briefly to implement in the future in my terminal text editor. Of course, I'll only need text ,but it seems obnoxiously complex, especially when taking into consideration multiple OS's. It's a problem I haven't seriously tackled yet, but also one I have no idea how to solve, becuase there's also security to take into consideration as well.
These streams really are exceptionally inspirational, and unusually tied to real world uses in the space of recreational programming. Thank you for all this content
Yo Yo Yo never can be there when u stream but ur vids from the streams a good, guess we have the same kind of humor, im really wondering what ur cooking become when ur done
there are far too few people creating cool shit with such wisdom, mad respect