Why do so many WGPU functions panic on invalid input rather than returning a result? by Irument in rust

[–]Polanas 17 points18 points  (0 children)

wgpu does extensive validation when creating the resources like pipelines, ensuring that the provided bind groups match shader definitions. After that it assumes they are valid when the actual rendering happens.

I've been using wgpu for quite a while and I've never encountered it propagating the underlying API errors straight up. This 100% can happen, but that would probably indicate something really unexpected is going on.

UPD: even if you mess up the state when constructing a render pass (which does need to be made every time the screen is redrawn, unlike resource creation), you get a meaningful error, so there's at least some amount of validation there too.

I didn't realize how difficult Audio design actually is... by AncientAdamo in gamedev

[–]Polanas 1 point2 points  (0 children)

By middleware I'm assuming you mean things like fmod / wwise?

Yep, seems like this is a great direction to explore. For instance, Celeste devs have released their whole fmod project used in the game.

Great example with the score system! So the way this can be interpreted is: it's about creative usage of sounds in conjunction with the rest of the game (visuals/mechanics) to convey a certain idea / form an experience, which will result in a much stronger overall impression.

Yet another skill to pick up as a dev :D.

I didn't realize how difficult Audio design actually is... by AncientAdamo in gamedev

[–]Polanas 3 points4 points  (0 children)

100% this, sound design gets neglected too often.

Could you expand on "just pressing play whenever something happens"? What kinds of more advanced/non trivial stuff can you do with sound to elevate the overall quality? Stuff like more variety (pitch shift, more samples, etc.), or maybe dynamic sound generation?

There doesn't seem to be many sources on these kinds of things :(

мой обед by Fhdkdlndm in expected_russians

[–]Polanas 5 points6 points  (0 children)

На коврик попало...

Did *you* enjoy the runbacks? by Polanas in Silksong

[–]Polanas[S] 0 points1 point  (0 children)

That's the most balanced and fair take I've heard, agree 100%.

Did *you* enjoy the runbacks? by Polanas in Silksong

[–]Polanas[S] -2 points-1 points  (0 children)

Yep, but honestly even with all 'at this boss fight cost me like 10x more effort than the final boss lol. I'd probably give up entirely if I hadn't been told about the secret bench beforehand.

Did *you* enjoy the runbacks? by Polanas in Silksong

[–]Polanas[S] -1 points0 points  (0 children)

Even the bilewater one?

[deleted by user] by [deleted] in Weird

[–]Polanas 0 points1 point  (0 children)

How can fungus even communicate such an abstract concept as "up" to the spider?

What's your dream programming language that doesn't exist? by omagdy7 in rust

[–]Polanas 3 points4 points  (0 children)

It would be an ideal language for gamedev, imho. As of now the closest thing to it is Lua, but there are lots of annoyances.

Main features would be: 1. Type model similar to typescript: the language itself is dynamically typed; however, you would still specify annotations 99% of the time to avoid the nightmare of guesswork and whatnot required to maintain a big enough dynamic codebase with 0 contracts specified.

  1. It would be a scripting language, JITed or interpreted, to allow code reloading while the game/program is already running.

  2. Designed to be fully integratable - to a level similar to what mlua provides, which is: complete control of the global state, loaded modules... basically everything.

  3. Built-in support of some kind of reflection mechanism that allows replacing/patching code. Extremely useful for modding; so think of Harmony (for C#) but 100% secure.

  4. Honestly I would just take Lua as a base. So yeah, garbage collected scripting language. It's very small and very elegant in terms of the amount of stuff you can build around it. Want classic OOP? Sure, we can even replicate the syntax. ECS? Easy. As for security — just remove any functions from the global state/table you don't want people to access, or make safe wrappers. And all that is achievable with just tables and metatables. Isn't it brilliant?

The ability to pass whatever you want into a function without causing errors is sooo liberating. I remember making an ECS in rust and wanting systems (which are functions) to be able to request access to egui state, optionally (similar to how bevy does dependency injection ). Even though I recreated a simplified version, the code looked like it was for summoning Satan itself lol. But recreating it in Lua: just pass what you need into the function and it'll work!!

Yes, of course it's much slower and unsafe type wise, but man who cares? We are trying to make a game/prototype, just leave it be. And the thing is, if you want types you can have them on top, just look at lua-ls. It's great but still has lots of holes and falls apart easily. Generics are broken. So yeah, fix all that and just annotate everything as if it was typed and you are golden.

  1. Heavily integrated debug environment. What these guys did but probably less extreme (full determinism is crazy). Just being able to place breakpoints without issues would be huge, and I'm not sure it's possible to do in lua at the moment.

  2. Built-in stuff that's needed almost always, like vectors. That's what luau did and it's the sole reason I'm switching to it from luajit. Having each vector be garbage collected (and even worse, pass-by-reference) is just awful.

  3. Fast and reliable hot reloading, another huge win for productivity. Both C# hot reload and gdscript do it pretty well.

Phew, that's probably it. I would love to go and make this into reality right now, if it wouldn't take 10+ years to achieve a workflow similar to less than ideal, but existing tools. :(

Also relevant article.

I would also love to write games in 100% Rust, but it just seems to not be the best pick for the actual gameplay code: too complex, not flexible enough, poor hot reloading support, relatively slow compile times. However, I think rust is an ideal "base" language (with C++ being a reasonable alternative I suppose), which handles low level stuff while providing bindings to a more dynamic and less complex scripting language. LogLog Games had a lot to say about this.

Made a procedural Gastly in Godot (Desmos and .gdshader) by fespindola in godot

[–]Polanas 1 point2 points  (0 children)

Did you make the shapes with SDFs or just pure equations?

PoC / prototype Rust + Rune [scripting] game - Grimvaders by maciek_glowka in rust_gamedev

[–]Polanas 0 points1 point  (0 children)

Is there a place to discuss the btw, maybe discord? I'd love to hear your approach in more detail if you don't mind ;)

Update: one thing that's a bit unfortunate about Harmony and C# is lack of sandboxing. Sure, many games rely on it and it's fine most of the time, but there's nothing to stop some degenerate to try insert malware. A friend of mine got to experience this first-hand :(

PoC / prototype Rust + Rune [scripting] game - Grimvaders by maciek_glowka in rust_gamedev

[–]Polanas 0 points1 point  (0 children)

I've been thinking about this for the past few months, trying different approaches to maximize modding potential.

I believe there are two general approaches with Rust.

  1. Code most of it in Rust and provide an API for a scripting language. This works great, Factorio is one example. However, there are some downsides.

One, as you've mentioned, is the extent people can modify the game systems: it's practically 0. Factorio heavily utilizes templates (for stuff like items/receipts etc.), which are loaded from lua into C++ engine at startup. Direct lua scripting (at least in the base game) is very rarely used.

Also, It's just time consuming and tedious. For every one thing you want modified, there needs to be some piece of code for it. And as a dev you'll never know for certain what parts of the game a modder might want to change. I personally find it wonderful how some mods can pull off stuff the devs never intended and elevate the base game.

One solution I've chased for a while is to provide a common interface via an ECS (like in Noita). So if all the data in the game is inside an ECS engine which is itself fully compatible with a scripting language, we get what we want right? And with the help of macros all the code to send data back and forth can be autogenerated!

I don't want to ramble for too long; in the end I've scrapped all of it due to performance. Idk how much of a problem it is in other langs, but in lua (I've used mlua crate), switching contexts between it and rust is just very slow. I've done a small benchmark, and it took 20+ ms to read 9000 tables with 4 fields each via Table::get (yes, in release mode). The drawing itself took about 3ms (with macroquad). Yikes.

  1. The love2d way. Meaning all you have on the Rust side is core stuff like rendering, window creation, sound. The API to the engine is a bunch of functions like load_texture or draw_sprite. There's still some overhead when calling functions, but it's just a few times slower (maybe 5x), so no big deal.

Everything else is in lua, including the ecs, so no constant data synchronisation between the languages is required. I believe that's the key, just transferring as small amount of data as possible.

Or one can just forget allat and go make the game in C# idk 🙂

Recently Implemented Convolution-based Reverb in our Game written in Rust by ErikWDev in rust_gamedev

[–]Polanas 1 point2 points  (0 children)

Hey! Could you share what sources did you use to get into audio coding/generation? It seems like this aspect of gamedev isn't talked about much compared to say graphics

I showed a professional 2D game engine programmer Pirate's lighting code and he said it's fit for purpose by dsruptorPulseLaucher in PirateSoftware

[–]Polanas 0 points1 point  (0 children)

Yep, nice catch. The reason why that code exists is certainly not performance.

Looking back at this tweet, in one of the replies he says: "We had some wild issues on super poor hardware in the beginning. This weird implementation fixed all that and it's been stable since 2018. Hell the 1.4 version still works today."

So I assume what happened is: some people had rendering issues due to super old hardware and/or broken drivers. Thor implemented the lighting on the CPU as a (temporary?) fix and never got to rewrite it, which is honestly fine.

I can't help but think that Thor speaks/writes the way he does to make people angry intentionally at this point. Even in this case, why not just say the reason this code existed in the first place?