News for hackers. Stuff that matters.
Re:I still use Flash in 2022 by rogual on Wednesday December 21, 2022 @07:02AM (#34079545)
Hey HN, I haven't done a lot of technical postmortem blogpost-style writing so I'd welcome any feedback or tips on how to improve. Is it too long, too short, too technical, not technical enough? Boring? Interesting? Is it enlightening or does it just come off like content marketing? I literally have no idea how good I am at this.
Re:I still use Flash in 2022 by wila on Wednesday December 21, 2022 @07:56AM (#34080104)
Keep on writing! I enjoyed reading what you tried and why you ended up with what you did. It is fine to mention your game, I do not consider that content marketing at all.
Re:I still use Flash in 2022 by civilized on Wednesday December 21, 2022 @07:58AM (#34080120)
I don't think anyone here is going to complain about a post where you make a game work by reverse engineering Bezier splines encoded in XML by Adobe Flash.

If that's not "Hacker" News, what is?

Re:I still use Flash in 2022 by bambax on Wednesday December 21, 2022 @09:20AM (#34081022)
Indeed! ;-)

However I wonder why the OP didn't try to keep vector graphics and use to SVG for instance? That would allow for infinite scalability. It is mentioned that "GPUs don't like vectors" but if the game doesn't change too often it should not make a lot of difference?

Re:I still use Flash in 2022 by rogual on Wednesday December 21, 2022 @11:39AM (#34082933)
I did consider it. Infinite scalability isn't required during runtime; the scene doesn't ever zoom or scale in the games, because that was always so slow in Flash, so the only real benefits would be 1) supporting higher resolutions and 2) reducing file size.

For 1) I decided I'd rather just release an update with larger textures if these ones ever start to look dated. That way I get to keep the runtime code simple. Less code means fewer bugs. I don't want to spend a lot of time fielding support requests from users who hit edge cases in the rasterizer. As for not changing too often, that's true, but taking advantage of that means doing change tracking with dirty-rectangles or similar, which not only adds complexity but also feels like it would make performance less predictable.

And for 2) the game as it stands now is under 50MB so I didn't feel a pressing need to make it smaller, although a tiny executable would be cool in a satisfying, demoscene kind of way.

Re:I still use Flash in 2022 by bambax on Wednesday December 21, 2022 @03:39PM (#34086102)
Ah, thanks. That could maybe go into the article as well? Although it's already pretty thorough as it is.
Re:I still use Flash in 2022 by kmeisthax on Wednesday December 21, 2022 @11:51AM (#34083092)
So, I think I need to elaborate on "GPUs don't like vectors". What the OP meant was "GPUs have literally no support for rendering anything other than pixels on triangles and getting them to efficiently draw Bezier curves and fills is an active area of research". You'd need specific hardware support for rasterizing them, and as far as I'm aware no such hardware exists.

When Adobe hacked on "HTML5 support" to Animate, they did exactly the same thing the OP did. It renders every shape in the FLA to a sprite sheet and then draws it to a canvas tag. If you have knowledge over what will be drawn ahead of time, this is the most reasonable thing you can do.

Even before HTML5 support, the AS3 Starling framework that let you "use the GPU" would pre-render all your vector assets to bitmap textures at runtime. And that was a framework built for Flex developers; if you were accustomed to building things on the timeline, you rendered on CPU, because that's where all of Flash's very particular rendering logic has to live.

Ruffle gets around this by tesselating every shape into a GPU-friendly triangle mesh. This lets us render stuff that's technically vectors on GPU. But as you can imagine, this creates its own problems:

- Flash has very specific stroke-scaling rules. If a stroke is smaller than 1px[0], it will be rounded up to 1px. This is how Flash's "hairline stroke" feature works: it actually asks for a 1/20px[1] stroke, and that gets rounded up to whatever the current scaling factor for that shape is. When your stroke is a polygon mesh, you can't vary the stroke to match Flash without retesselating, so hairline strokes on shapes that stretch don't animate correctly.

- Likewise, any stretch of a stroke that changes the aspect ratio also distorts the stroke, since its baked into the tesselated mesh. There's a minigolf game that does this to hairlines and it will basically never look right in Ruffle.

- Tesselated vectors lose their smoothness, so we have to sort of guess what scale the art is drawn at and add enough detail polygons for things to render correctly. Most of the time we get it right. However, there are some movies that do crazy things like store all the art at microscopic scale and blow it up. This provides a compression benefit, because it quantizes the points on the art with little visual difference on Flash Player. On Ruffle, however, the art becomes very low-poly.

- All the tesselation work takes a significant amount of time. There are certain movies (notably, a lot of Homestuck) that would hang the browser because of how much ridiculously complicated vector art was being processed before the movie even loads. We had to actually limit how much art could tesselate per frame, and expose that to movies as bytesLoaded, which is why Ruffle movies have preloaders even though we don't support streaming download.

There's another approach to drawing Beziers on GPU: drawing the hull of control points with a procedural texture that calculates the underlying polynomial. This is especially simple for quadratic curves (the ones with one control point), which is what all Flash timeline art[2] is.

However, strokes are more complicated. You'd think we could just take the hull of the stroke and draw that as a fill, but you can't. This is because the offset of a Bezier curve is not a Bezier curve. Drawing the stroke in a pixel shader would make sense, except you still need to define a polygon mesh around your stroke with a reasonable texture coordinate system to make the math work. And the polygonal outlines of Bezier curves can get really funky; there's no obvious way to quickly say "here's a curve, now give me the polygon that encloses a 5px stroke around it". Remember how tesselation takes so long that it would hang Ruffle?

[0] I'm not sure if this is virtual or device pixels.

[1] Flash specifies vectors in fixed-point units called twips. That's why the zoom factor on Flash movies was locked to 2000%.

[2] Flash can draw cubics - the two-control-point curves you think of when you think Bezier - but only in response to an AS3 graphics command. We haven't implemented this in Ruffle yet.

Re:I still use Flash in 2022 by bambax on Wednesday December 21, 2022 @03:40PM (#34086109)
Thanks for this! Very informative!
Re:I still use Flash in 2022 by detritus on Wednesday December 21, 2022 @03:53PM (#34086241)
> "GPUs have literally no support for rendering anything other than pixels on triangles and getting them to efficiently draw Bezier curves and fills is an active area of research"

Well fuck me, I had no idea. I figured that 'simple 2D vectors' would be beyond piss-easy for modern GPUs. I'd never considered that it wasn't the actual math space that was accelerated, rather the fast memory mapping of everything on presumably comparatively simple geometries. You've just turned my view of the world upside down :(

Re:I still use Flash in 2022 by ChuckMcM on Wednesday December 21, 2022 @04:04PM (#34086382)
Yeah, this is something that many many people assume (vectors are "easy" on GPUs) and then are amazed (like I was!) that they aren't even in the function set. My thought was that if you were "accelerating" desktops you'd really want vectors right? But no.
Re:I still use Flash in 2022 by jcelerier on Wednesday December 21, 2022 @04:20PM (#34086554)
> they aren't even in the function set.

they are, but on nvidia only... https://developer.nvidia.com/gpu-accelerated-path-rendering

Re:I still use Flash in 2022 by ChuckMcM on Wednesday December 21, 2022 @06:27PM (#34087754)
Re:I still use Flash in 2022 by int_19h on Wednesday December 21, 2022 @07:30PM (#34088223)
The interesting thing is that graphics cards in the 90s - which were "desktop accelerators" past the low end - specifically supported accelerated 2D primitives, including Bezier curves for the more powerful ones. It was all gradually dropped as cards focused on 3D games specifically.
Re:I still use Flash in 2022 by DonHopkins on Wednesday December 21, 2022 @06:50PM (#34087950)
Rendering vectors on the GPU is possible, just quite tricky.

But signed distance fields work well and easily on GPUs.

Here's a recent article and discussion about it:

Vector graphics on GPU (gasiulis.name)

235 points by mpweiher 4 months ago | hide | past | favorite | 95 comments

https://news.ycombinator.com/item?id=32384016

https://gasiulis.name/vector-graphics-on-gpu/

Re:I still use Flash in 2022 by karteum on Wednesday December 21, 2022 @04:16PM (#34086516)
I though that there were some "GPU accelerated path rendering" already 10 years ago ? https://developer.nvidia.com/nv-path-rendering https://developer.nvidia.com/gpu-accelerated-path-rendering

(OK those links are for NVidia, but if they can do it I guess others can too ?) (also see https://www.researchgate.net/publication/262357352_GPU-accel... )

Re:I still use Flash in 2022 by Nihilartikel on Wednesday December 21, 2022 @04:52PM (#34086868)
Riffing off of other recent HN posts, I'm wondering if signed distance fields might be a contender for 2d strokes.

I've seen some font rendering work that has already embraced them for high perf rasterization.

Still, may be hard to get flash equivalency.

Re:I still use Flash in 2022 by karteum on Wednesday December 21, 2022 @05:04PM (#34086994)
Also, as far as I understood, both GNU Gnash and Lightspark were using OpenGL for rendering. So I always expected that GPU would still bring some sort of acceleration for 2D path rendering ?
Re:I still use Flash in 2022 by Asooka on Wednesday December 21, 2022 @05:52PM (#34087444)
Have you tried splitting the area covered by each shape into several 8x8 pixel rectangles, then running a compute shader over each one that executes the exact same rasterisation algorithm as Flash did? That's more or less how triangles are rasterised on the GPU anyway.

It's definitely not a simple solution, but might enable you to do runtime rasterisation with a good framerate on the GPU rather than pre-rasterising all the vector art.

Re:I still use Flash in 2022 by HanClinto on Wednesday December 21, 2022 @08:19AM (#34080336)
I really enjoyed it! It didn't come off as content marketing at all. Well done!!
Re:I still use Flash in 2022 by unsafecast on Wednesday December 21, 2022 @08:29AM (#34080449)
I liked it a lot! It doesn't feel like marketing at all, and I think it's a good balance between technical and non-technical (though I wouldn't mind more details).

Keep writing!

Re:I still use Flash in 2022 by pie_flavor on Wednesday December 21, 2022 @08:29AM (#34080455)
This is pretty great writing, I'd love to read more of it.
Re:I still use Flash in 2022 by kulor on Wednesday December 21, 2022 @08:40AM (#34080559)
There's a gem of a hidden narrative here for more junior developers that you don't always need to start over (which 9/10 fails) but instead be resourceful within your constraints and to be mindful of what your constraints actually are, which don't have to be new and shiny.
Re:I still use Flash in 2022 by darkwater on Wednesday December 21, 2022 @08:58AM (#34080791)
I think you nailed it at every layer, it was a very entertaining, nostalgic and instructive read. Thank you!
Re:I still use Flash in 2022 by bjackman on Wednesday December 21, 2022 @09:04AM (#34080860)
It was great, loved the concise writing style, and it was a cool story.
Re:I still use Flash in 2022 by rogual on Wednesday December 21, 2022 @10:51AM (#34082223)
Thanks! It's actually great to hear you describe it as concise, I was worried it was a bit waffly to be honest.
Re:I still use Flash in 2022 by mastersummoner on Wednesday December 21, 2022 @12:28PM (#34083614)
It was long because there were a lot of steps to describe. But for each, the writing was concise, interesting and entertaining.
Re:I still use Flash in 2022 by log101 on Wednesday December 21, 2022 @09:12AM (#34080935)
It was a pretty insightful article, I didn't know how a flash game worked internally and how it could be reimplemented! I think it is also relevant for those migrating their projects to newer technologies, I always found this process fun(except there is a deadline) :)

(Edit: I love your games and used to play a lot when I was a kid)

Re:I still use Flash in 2022 by Tepix on Wednesday December 21, 2022 @09:20AM (#34081023)
It's interesting for sure, I'm left wondering if it was less work to make flash continue to work somehow instead of re-authoring the original games.

I mean you've probably learned a lot, but you could have learned to author games using a more modern tool than flash instead and that would have been useful in the future, right?

Re:I still use Flash in 2022 by replwoacause on Wednesday December 21, 2022 @09:27AM (#34081107)
I thought it was great, and I have no interest in games or game development, but I read the whole thing top to bottom and came away thoroughly impressed. Excellent post and work!
Re:I still use Flash in 2022 by dontwearitout on Wednesday December 21, 2022 @09:51AM (#34081402)
Flash was my 2nd programming language (after VB6) back when it was still Macromedia. I had a lot of fun making really crappy minigames and learning the basics of coding. This article brought some good nostalgia and plenty of astonishment at the lengths you went to.

Your writing itself is great. A lot of writing linked by HN seems too verbose because people try to sound smart. Yours is succinct while engaging. Right length, just technical enough, and interesting. I really enjoyed this, thanks for writing it!

Also:

> Object-orientation is not fashionable right now in gamedev circles

Can you elaborate on this?

Re:I still use Flash in 2022 by BlueTemplar on Wednesday December 21, 2022 @10:44AM (#34082130)
Probably how OO teachers and mentors failed horribly (AFAIK we still don't warn new students about the pitfalls of inheritance ?), so ECS got popular as a better alternative to shitty OOP code ?

https://www.gamedev.net/blogs/entry/2265481-oop-is-dead-long...

Re:I still use Flash in 2022 by stelonix on Wednesday December 21, 2022 @12:04PM (#34083283)
Not only that, but due to CPU caches and memory alignment issues, ECS have better performance than inheritance; also because most ECS systems ditch virtual function calls.
Re:I still use Flash in 2022 by cogman10 on Wednesday December 21, 2022 @04:20PM (#34086552)
> ECS have better performance than inheritance

Can have.

Whether or not an ECS will actually be faster depends entirely on the type of game and access patterns of the inheritance structure. Further, it matters how you are doing inheritance (LTO can eliminate a lot of the pitfalls even if you use virtual function calls).

This is nothing against ECS. I just find the current claims of performance dubious and potentially flat out wrong given modern compiler optimizations and changes in CPU caches (mainly that they got a LOT bigger).

Re:I still use Flash in 2022 by stelonix on Tuesday December 27, 2022 @09:37AM (#34149014)
I believe claims of "compilers getting faster/bigger enough" are the exact reason we have ECS now. It surely depends of the kind of game, but games with any kind of entity which isn't unique should feel the performance improvements.

Ideally, compilers should be able to transform classes into ECS layout when generating code. Shouldn't be hard to have a pass before compilation, if we use clang.

Re:I still use Flash in 2022 by japhib on Wednesday December 21, 2022 @01:05PM (#34084136)
Object-orientation is kind of the old-school way of doing things, these days it's all about ECS - entity component system. This is a more data-oriented approach that has the potential for much higher performance when you have thousands of objects that need updating in your game. It's similar to how OO languages like Java/C# are going out of style and more (nominally, at least) data-oriented languages such as Go or Rust are in style.
Re:I still use Flash in 2022 by pjmlp on Thursday December 22, 2022 @04:06AM (#34091306)
Unity isn't going anywhere, and programming to interfaces is just as doable in Java and C#.
Re:I still use Flash in 2022 by whostolemyhat on Thursday December 22, 2022 @05:17AM (#34091851)
Unity's been working on an ECS option for a while now
Re:I still use Flash in 2022 by pjmlp on Thursday December 22, 2022 @06:24AM (#34092283)
Written in C#.
Re:I still use Flash in 2022 by lewispollard on Thursday December 22, 2022 @07:56AM (#34092795)
Yeah, "OO is going out of fashion" is a common phrase in gamedev, but what's actually meant is "deep class hierarchies defining the behaviour of game objects is going out of fashion". Most ECS code is still written in OO languages and makes heavy use of OO features.
Re:I still use Flash in 2022 by throwaway2037 on Thursday December 22, 2022 @10:22AM (#34094190)
Is ECS similar to Data Oriented Programming?

I watched this talk years ago: CppCon 2014: Mike Acton "Data-Oriented Design and C++"

I was very impressed by the ideas presented.

Java/C# can be used to write a program with "just a bunch of structs + static methods". Isn't that data-oriented enough? Ya, I know we can do 72 levels of inheritance also... for ignore that for a moment.

Re:I still use Flash in 2022 by thor_molecules on Wednesday December 21, 2022 @10:07AM (#34081599)
Very interesting, and frankly inspiring to see you get this creative.
Re:I still use Flash in 2022 by jonathanyc on Wednesday December 21, 2022 @11:20AM (#34082659)
Great post! No complaints at all from me. The mix of your thought process + screenshots + examples is perfect.
Re:I still use Flash in 2022 by robertlagrant on Wednesday December 21, 2022 @11:24AM (#34082722)
Just to say: thank you for these games. I loved them when I was in my 20s.
Re:I still use Flash in 2022 by lsferreira42 on Wednesday December 21, 2022 @12:28PM (#34083613)
You are very good at this, i'll follow your site from now on hoping for more publications like that!
Re:I still use Flash in 2022 by sh4rks on Wednesday December 21, 2022 @01:30PM (#34084465)
This was a great read. I distinctly remember playing Hapland as a kid. Armour games or Crazymonkeygames, can't remember which one it was. So this was a great nostalgia trip.
Re:I still use Flash in 2022 by namuol on Wednesday December 21, 2022 @03:22PM (#34085912)
It was perfect! Full of low-key wisdom and fun observations. Doesn’t feel like “content marketing” in the slightest.

I wish the Hapland series was coming to Mac, but I respect your decision to snub Apple.

Re:I still use Flash in 2022 by JoeyJoJoJr on Wednesday December 21, 2022 @03:38PM (#34086081)
Great article! I also still use Flash by using a custom runtime that interprets the oily of the “Export as texture atlas” feature. I was wondering if you had attempted to use this feature in order the rasterize the graphics?
Re:I still use Flash in 2022 by rogual on Friday December 23, 2022 @06:53AM (#34104815)
Thanks!

Looks like that feature was added in Animate CC, which I don't use, so I haven't tried it.

Looking at the docs, it looks like something I would have at least tried. Might have saved me writing the rasterizer, though I'd still have wanted to atlas everything together into bigger atlases, and make binary animation files.

One downside vs the .fla parsing approach I went with is that even if you can script away the GUI clicking, you'd still have to have Flash open while the build script runs. I quite like having an exporter that is just a CLI program you can run without Flash, though it's not a massive deal.

I'd be interested to see what exactly Animate puts into the animation.json file it generates. The docs don't seem to mention it, and I couldn't find any example ones online.

Your tool looks great, by the way — have you made any games with it?

Re:I still use Flash in 2022 by Jasper_ on Wednesday December 21, 2022 @03:44PM (#34086162)
Worth noting that there is a spec for the custom XML file, it's known as FXG. S starts a cubic Bezier curve in absolute coordinates: https://web.archive.org/web/20110611002637/http://opensource...
Re:I still use Flash in 2022 by enumjorge on Wednesday December 21, 2022 @06:40PM (#34087861)
I’ll add to the chorus and say that this was a wonderful post and the type of content I hope to find when I come to HN.

I enjoyed how you explained certain technical concepts succinctly and using simple language. For example, as someone who never used Flash, you explained the 1000 ft view of how Flash works. When I’m looking at a new tool or framework, I try to star by understanding the mental model behind it. Yet, a simple explanation of it is often difficult to find.

I was also struck by how much technical work was involved here—you made it sound easy. How long did this project take you?

Re:I still use Flash in 2022 by ficklepickle on Wednesday December 21, 2022 @10:18PM (#34089329)
> you explained the 1000 ft view of how Flash works

I second that. I find the better someone knows a subject, the harder it is for them to provide this perspective, making it all the more impressive.

Re:I still use Flash in 2022 by Const-me on Wednesday December 21, 2022 @07:33PM (#34088242)
This was awesome.

Also, the idea of using text/assembly as an intermediate format of binary files is pure genius. I will probably use that occasionally for similar use cases.

Re:I still use Flash in 2022 by plasticeagle on Wednesday December 21, 2022 @08:38PM (#34088676)
Your writing is clear and concise. You don't indulge in run-on sentences, or hyperbole.

It's an impressive piece of writing. You're definitely good at this.

Re:I still use Flash in 2022 by cpeterso on Wednesday December 21, 2022 @09:07PM (#34088852)
As someone who worked on Macromedia’s and then Adobe’s Flash Player team, I thank you for sharing your experience preserving your Flash content!

Did you investigate Haxe or OpenFL?

Re:I still use Flash in 2022 by andai on Thursday December 22, 2022 @03:36AM (#34091139)
Can you comment on why Adobe let Flash die? Did it just become unprofitable compared to their other projects?
Re:I still use Flash in 2022 by andai on Friday December 23, 2022 @05:59AM (#34104440)
Or did Apple give them a nice deal in exchange? ;)
Re:I still use Flash in 2022 by Multicomp on Friday December 23, 2022 @12:29PM (#34108391)
I guess we will never know hehe
Re:I still use Flash in 2022 by cpeterso on Saturday December 24, 2022 @07:18PM (#34122666)
Adobe couldn’t figure out how to monetize Flash, other than selling the Flash authoring tool to Flash designers, a dying breed, for a few hundred bucks or bundled in Adobe’s Creative Suite. Adobe tried selling Flash video DRM, which got undercut by Google Widevine, and selling licenses to unlock Flash opcodes for advanced 3D and C++ cross compilation, which was undercut by web technologies like WebAssembly.

Also, I think Flash was more expensive to maintain than Adobe’s other design applications because the Flash Player needed constant security patches. Adobe was usually happy to milk cash cow products, such as Director and Shockwave, transferring maintenance to remote teams in India.

Re:I still use Flash in 2022 by andirk on Thursday December 22, 2022 @01:55AM (#34090613)
It depends on how one looks at it. For example, I didn't read it.
Re:I still use Flash in 2022 by djmips on Thursday December 22, 2022 @09:18AM (#34093471)
I might have missed this in the article but are you sharing any of your work? I know that a lot of the work was manual but some of your tooling might be useful for anyone else who want to go this craftsman route of converting a flash game.
Re:I still use Flash in 2022 by throwaway2037 on Thursday December 22, 2022 @10:17AM (#34094124)
Your blog post was excellent. Thank you to share.

    Is it too long, too short, too technical, not technical enough? Boring? Interesting? Is it enlightening or does it just come off like content marketing
Long, but well-organized and not ranty. You can quit after a few sections and still learn interesting things. Technical enough with enough screenshots to keep it from being "wall of text". It is a good way to share some eye candy from your games. [E]nlightening? Yes. [C]ome off like content marketing? Yes, but this is the kind that we want to read -- basically, interesting content marketing. Don't be ashamed that you need to hustle a little bit as a small software shop.

Oh, and you forgot funny. This part made me laugh:

    Flash stores its vector graphics in XML format. You might argue that XML is a poor choice for graphics data, but you weren't a product manager at Macromedia. Behold: ...
Re:I still use Flash in 2022 by pmontra on Thursday December 22, 2022 @01:57PM (#34096996)
It is perfectly balanced. It can be read top to bottom in a few minutes. If you feel like to expand a part you can write a new post and link it from the original one.

Some other posts are born with all the tiny details, are too long to be read on one session and I end up missing even the key points because that second session never happens.