4 ms·
I love what this is trying to achieve; I'm a Cities Skylines fan. But why did he choose to do it in webgl in the browser of all things? At first I thought he ch
by brink 8y ago
I love what this is trying to achieve; I'm a Cities Skylines fan. But why did he choose to do it in webgl in the browser of all things? At first I thought he chose Rust for performance reasons, but then it looks like he completely negated that by choosing to run it in a browser.
- excepttheweasel 8y agoRust can compile to WASM, and I would assume would outperform vanilla JS.
- kemayo 8y agoTwo really different performance domains to be concerned about? This sort of fine-grained simulation is expensive, whereas rendering of the fairly-simple sort the screenshots imply just isn't. (I'm assuming that the backend Rust server is doing the expensive simulation stuff, and just sending the display data to the client.)
- gmueckl 8y agoThe simulation state can be huge. Streaming all of it would be pretty bad. Streaming only parts leads toneedless latency when other data is required. WebGL is not the smartest choice to me. Running things locally with only input replication between players should be the better choice. But this requires a 100% reproducible simulation.
- setr 8y agoIm not sure how WebGL would impact syncing simulation state across clients Or how opengl/vulkan/etc would be better (I also dont see why they’d impact client syncing) Unless webgl does something more than rendering..? The same data is (eventually) required for any rendering engine, regardless of how you sync the simulation
- gmueckl 8y agoSorry I meant WebGL only as a shorthand implying a web stack with a server, a browser and JavaScript. That was an bad choice of words on my part. It was not meant to single out WebGL as a rendering technology. However, more sophisticated APIs could allow more techniques for offloading more of the filtering and mapping steps of the visualization pipeline onto the GPU. Even some simulation could be accelerated, although it's often not worth it in practice.
- deleted 8y ago[deleted]
- theanzelm 8y agoThe whole idea behind dumb client/simulation server was to be able to support cities too big to be simulated on one machine (the simulation server can be distributed). I already have quite sophisticated streaming logic that basically makes sure only deltas of everything are streamed. Latency is not really an issue in this kind of game, for most player inputs I can even do simple optimistic prediction on the UI side, which works fairly well.
- gmueckl 8y agoLatency semms to be an issue to me when new data is requested that has not previously been streamed. Honestly, sending deltas always seems like a bad idea to me as this allows subtle synchronization issues to derail simulations bit by bit before the divergence is big enough to be noticable.
- untog 8y agoWebGL is just a subset of OpenGL, really. So the combination of Rust and WebGL is probably incredibly flexible in terms of the platforms it can run on. I can't think of an inherent reason why running in the browser would be a performance suck. WebGL performs wonderfully, and Rust compiles to WASM. Rough edges right now to be sure, but looking ahead it seems like a great choice.
- petepete 8y agoOriginally it was written in JavaScript, then rewritten in C++, then a few months later in Rust. https://github.com/citybound/citybound/wiki/Development-History-(Under-Construction) https://github.com/citybound/citybound/wiki/Development-Hist...
- meritt 8y agoThe simulation runs on the server. The client side (browser/webgl) is a dumb client.
- theanzelm 8y agoExactly. And I do use Rust compiled to WebAssembly to do lots of the "render preparation" work (converting streamed simulation states into render buffers), which makes it pretty fast.
- Bluecobra 8y agoThat’s pretty neat. I remember when SimCity (5) came out and being extremely disappointed that the underlying agent system was a complete farce. If I recall correctly, think they had to “cheat” because they couldn’t scale performance on lower end hardware. With this you can just spin up a faster EC2 instance if you want a bigger city or region. I can totally see small groups of hardcore players coming together to pay for a dedicated host. It sure beats swapping SC4 files on file sharing services for “region play”.
- netsharc 8y agoC:S is limited by your CPU/memory, imagine having the calculations be done on a big server. But I guess you'd have to have a subscription to the game so they can pay the cloud services, and it wouldn't be cheap if your city needs a lot of (server) CPU power.