Hacker Newsnew | past | comments | ask | show | jobs | submit | cepacked's commentslogin

I use SDFs on my render engine to render text. It allows me to debug values inside shaders. (I can print value of an uniform, texture value etc.)

(It's a combination of line segments for each letter and digit)


Are you aware of Valve's paper[0] for glyph rendering via SDFs? You can get amazing results from a low res glyph atlas.

[0] https://steamcdn-a.akamaihd.net/apps/valve/2007/SIGGRAPH2007...


From what I understand, that paper was extremely influential and the technique has been widely adopted.


UE4/5 implement fonts this way.


In a context where you have thousands of entities, it's very rare that you'll loop all over them from 0 to N. In such context entities are always partitioned in space. You interact with one entity and you update the entities around it. For which you'll query the spatial partition to get list of entities around, and they won't be contigious in memory.

You may have one loop to update all entities but that's it. And will you even update all of them ? What about the ones that are not visible ? Maybe you want to update only the visible ones .. in that case you query the partition to get the ones visible around your camera

So practically you never query the ecs registry to loop over all of them


In a naive ECS system this might be true, but mature ECS systems use archetypes which partition based on usage to maintain the contiguous memory.

I've written about the details here: https://taintedcoders.com/bevy/archetypes/

The gist is that instead of partitioning by type you sub partition by usage. Bevy does this by optimizing your storage based on the bundles (groups of components) you create. Flecs does the same but I'm not sure of the exact mechanism.


Lately I've been under the extreme temptation to rewrite my game engine in Rust.

I crave the ergonomy of rust development. I use Rust at my job (not game dev) and it sucks to switch back to C++ for my side projects

But I resist for the moment, because I fear it won't be easy as I predict and it would delay my projects.

I already started using this list of features and refactored most of my code for c++20. I hope C++ will continue on that path and catch up Rust. But there are still so many things missing

In the meantime I refactor little by little my C++ projects to be "rust ready": hierchical ownership, data oriented with minimalist oop. So the day I can't resist no more I will be able to quickly rewrite it in Rust


Rust doesn't allos dynamic libraries in general, so it isn't going to work where (right or wrong) the code is based on plugins. You can work around this with C api interfaces, but that limits you if both sides are rust. (unsafe for what should be safe as I understand.)


Instead of literally loading the plugin into the same address space as the host process, you could launch it as a separate process and use sockets or shared memory to communicate. With a slight shift in API design this might actually be better than traditional dynamically loaded plugins. It will tend to level the performance playing field across languages (e.g. no JNI penalty for plugins written in a JVM language). And it will prevent plugins crashing the host.


And the dispatch overhead will be a few orders of magnitude higher.


Passing a message via a shared memory queue (twice) is not 1000x slower than a non-inlineable function call.


You're right, but that's also not the entire workload. You have to also wake up the remote process in some way and, depending on the expected duration, probably wake up for the response. On pretty much all major platforms that work is measured in 10s of microseconds, which puts you easily into the 1000x slower than a non-inlineable function call category.


With the associated context switch it's bigger, if anything. Busy looping to wait if some memory changes isn't really viable for many scenarios.


That actually seems about the right order of magnitude.


Wdym doesn't allow dynamic library in general? You can have `dylib` as crate type.


We wrote some Rust *.so files, but had to use a C (not even C++) ABI to communicate between them. It's definitely possible, but quite clunky.


is it any better in C++, though? IIRC C++ doesn't have a stable ABI either.

If you either commit to dylib or C++'s DLLs, you still have to recompile everything on version change, unless you also use the C ABI in C++.


One common use case for DLLs in gamedev is for code hotloading. You can just recompile your game DLL and unload / reload the library, patch up some globals and vtable pointers and voila, your game logic has been updated without restarting the game. And all that you get just writing normal C++.

This is only for development. Shipping builds will usually statically link everything.


> And all that you get just writing normal C++.

But, as far as I understand, the boundary layer has to still be C (the side that loads DLLs and stuff), because of the natural limitations of templated languages and linkers.

And as soon as you change any interface you'd need to recompile more parts of the code. The same can be applied with Rust using dylib. At the end, the glue code always end up being C.


On any given compiler you can make C++ have a stable ABI. You can even do this commonly in practice across compiler versions, even, the standard library typically tries to achieve this.

It's easier to have a long term cross version cross compiler stable C ABI, but if you're talking a single toolchain that simplifies the problem tremendously and you can absolutely do that with C++ in practice at that point


C++ hes weird ABI rules, but if you follow them you can change implementations.


It's pretty similar, yes.

If you don't care about the ABI being stable then you can use a Rust-based ABI, but you're essentially just static linking everything then. Not sure how that works out for the game developers.


it really depends on what type of game you're making


Does this mean more and more developers could easily make GTA like games now that they have access to this source code ?


No. It's more like a writer describing their creative process. Knowing how someone else gathers ideas or structures text may help you improve your own writing, but that is still a very small part of publishing an original work.


not by much, usually I review the data models to absorb their design and translate into lessons


If they can extract the game engine code into a reusable framework, yes.

No game created from it could ever be legally released though.


If it's a closed source release, how could anyone prove which code/framework they reused ?


I'd imagine a complex game engine has some bugs or weird behaviours in specific conditions. If it can be proven that the closed source game has a lot of the same bugs/behaviours, that is likely enough to win a lawsuit.


>Reverse engineers have entered the chat room.

Finding this would be pretty trivial depending on how much was stolen. And proving this would be more of a matter for Rockstar lawyers


Decompile it and see things work exactly the way the original game does, bugs and all


Can’t you decompile it?


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: