Mu

Multistate – Save and restore WebGL state like in a 2D canvas

Hacker News

Multistate – Save and restore WebGL state like in a 2D canvas

This project is a side effect of my other project, and I thought it's something that could be used for many other purposes. I've been working for three and half years, mostly in my spare time but also two dedicated months this year on https://font.skin (originally called Fonted). It requires using certain WebGL features that are not available in Three and most importantly I wanted the project to be universal to create plugins for Three, Babylon and PlayCanvas. By not using any framework but writing a small, bespoke renderer, every text effect can be exported to i.e. React and only takes a few kilobytes + 30kb shared player (gzipped). A few weeks ago the time had come to build a Three plugin and this is when I realised that using the same context as the current Three one is going to be difficult. Using separate contexts is prohibitively slow due to not being able to share textures between them. When using the same context I realised that Three renderer reset is too nasty for an already-busy environment and can't be used in between draw calls. Three does not provide any way of interacting with low level state like binding textures, but in the worst case scenario I thought I'd just make a plugin that only works with my modified version of Three and add whatever is necessary to the core. (I use it for my game engine running https://bad,city and it was used by a friend of mine for a couple of art exhibitions in London.) Having the text effects working only in my modified version wouldn't be ideal because I wanted to not only use them in my projects but make them available for everyone using any rendering engine. "What if after the webgl work all the state changes can be restored to where they were?" I thought. The regular 2D HTML Canvas has such a functionality with "save" and "restore" functions, but 3D WebGL context doesn't. Having these would be way too complicated. Or would it? So why not: 1. create a snapshot of the WebGL state(not going deep into individual textures or buffers, just all global settings and bindings) 2. Run Fontskin renderer which will alter WebGL state 3. Restore the state from the snapshot And that's it. Save and restore was born. It also allows having multiple snapshot containers i.e. to create presets. At this point it's well-optimized and saving the snapshot is extremely cheap. Restoring the snapshot is checking the cache so it's not creating any redundant WebGL API calls. Multistate can be used for interop between multiple WebGL frameworks i.e. Three and Pixi without having to use their nuclear reset functions. It can also be used for more predictable programming with pure WebGL and to debug issues by creating zones of isolation.

Share card

Actual performance

2points
Did not reach leaderboard

Launch Intel predictions

Analyze your own launch →
Indie HackersFits the IH revenue-focused audience · Strong signals: para · Missing: supports, reddit linkedin, podcasting
92%92% predicted probability of success on Indie Hackers, based on ML models trained on real launch data.
best fitHighest predicted score across all platforms for this description.
Product HuntOn track for Day 1 leaderboard · Strong signals: context, using · Missing: mac, agents, macos
90%90% predicted probability of success on Product Hunt, based on ML models trained on real launch data.
Hacker NewsStrong engagement from HN community · Strong signals: ide, game engine, io · Missing: https docs, excited, just released
57%57% predicted probability of success on Hacker News, based on ML models trained on real launch data.
nativeThis product was originally launched on this platform.
TrustMRRLess likely to generate early MRR · Strong signals: month, way, para · Missing: mobile apps, ios, personal
45%45% predicted probability of success on TrustMRR, based on ML models trained on real launch data.
AppSumoMay struggle as an AppSumo deal · Strong signals: calls · Missing: plus, platform, intuitive
39%39% predicted probability of success on AppSumo, based on ML models trained on real launch data.
Acquire.comPre-revenue stage for this audience · Missing: arr, mrr, revenue
13%13% predicted probability of success on Acquire.com, based on ML models trained on real launch data.
BetaListMay not resonate with beta-testers · Missing: web3, chat, crypto
0%0% predicted probability of success on BetaList, based on ML models trained on real launch data.

Incorrect prediction on native model

Similar products

ca
canvas_ity - A tiny, single-header canvas-like 2D rasterizer for C++68%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

canvas_ity - A tiny, single-header canvas-like 2D rasterizer for C++

Hacker News8
Sp
SpacePigeon – Save and Restore macOS Workspaces35%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

SpacePigeon – Save and Restore macOS Workspaces

Hacker News2
Sa
Save/Restore Games of 204830%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Save/Restore Games of 2048

Hacker News3
49
49 IDE – 2D Canvas for Agents65%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

49 IDE – 2D Canvas for Agents

Hacker News18
Si
Simulating Galaxies in 2D67%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Simulating Galaxies in 2D

Hacker News4
8Land
8Land9%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

8Land is a 2D pixelart metaverse

Indie Hackers1art
La
Last System State Before OOM49%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Last System State Before OOM

Hacker News1
Ti
Tileroot – save/restore tiling WM layouts (sway, Hyprland, i3)23%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Tileroot – save/restore tiling WM layouts (sway, Hyprland, i3)

Hacker News2
Ex
Experiment: Toggle interactive 2D canvas using Fullscreen API66%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Experiment: Toggle interactive 2D canvas using Fullscreen API

Hacker News1
Ko
Konva.js – html5 2d canvas framework72%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Konva.js – html5 2d canvas framework

Hacker News3