
rg3d: Rust 3D game engine with an FPS demo game and scene editor - adamnemecek
https://github.com/mrDIMAS/rg3d
======
Narann
What I like is that this engine actually have a demo which is more than few
cubes and sprite: A full tiny game. Game engine should have more tiny games as
it's a good way for newcomers to have something they can start to hack (change
gravity/texture/lighting effects) and understand what a game engine is and how
it work.

The code is quite clean and it also provide scene editor with dedicated UI
widgets.

[https://github.com/mrDIMAS/rusty-editor/](https://github.com/mrDIMAS/rusty-
editor/)

[https://github.com/mrDIMAS/rg3d-ui](https://github.com/mrDIMAS/rg3d-ui)

Truly impressive.

~~~
mrDIMAS
The game and the editor are massively helps to find right approaches in
development. All my previous attempts to write engines (in other languages)
were bad because all they had is just some very simple demos with some meshes
and lights. You never know which features engine should have until you need
them. Many engines trying to have best possible graphics and does not pay
attention to other very important things, like sound, animation, physics,
resource management, save/load, editor, etc.

~~~
submain
As they say, you don't write an engine - you write a game, and the engine
comes out of it. Impressive work!

~~~
kleiba
Not if you write Handmade Hero.

~~~
codetrotter
HMH is kind of special though in that its author, Casey Muratori, has many
years of experience in gamedev. I think the saying of the parent commenter to
yours is mostly applying to people who are trying to make game engines for the
first time with little or no past experience in actually shipping complete
games.

~~~
marta_morena_25
Not really... All great game engines were spawned out of AAA titles. You
should never try to build an engine without a set of games that stretch its
limits in all directions, otherwise something will always go wrong. There
isn't a single person alive who can manage the complexity of a game engine. As
soon as you start splitting things up, you run into problems of distributed
development. Getting this right without eating your own dog food is unlikely,
at best, no matter how experienced your team is...

What makes the difference between an experienced engine developer, like CryTek
and Unreal, and a hobbyist or a company who does it for the first time, is
mostly that while both of them will definitely build a game with the engine
while creating the engine, the experienced team will actually produce a re-
usable, well designed engine, while the inexperienced team will produce a hunk
of junk that doesn't fit together and doesn't extend past the game they were
trying to develop.

~~~
Aeolun
Did Unity come out of a game?

~~~
sprafa
[https://techcrunch.com/2019/10/17/how-unity-built-the-
worlds...](https://techcrunch.com/2019/10/17/how-unity-built-the-worlds-most-
popular-game-engine/)

Seems like it. Still the tons of games that are and have been MADE with Unity
over time have led it to become what it is now.

"Unity was founded in Copenhagen by Nicholas Francis, Joachim Ante, and David
Helgason. Its story began on an OpenGL forum in May 2002, where Francis posted
a call for collaborators on an open source shader-compiler (graphics tool) for
the niche population of Mac-based game developers like himself. It was Ante,
then a high school student in Berlin, who responded.

Ante complemented Francis’ focus on graphics and gameplay with an intuitive
sense for back-end architecture. Because the game he was working on with
another team wasn’t going anywhere, they collaborated on the shader part-time
while each pursued their own game engine projects, but decided to combine
forces upon meeting in-person. In a sprint to merge the codebases of their
engines, they camped out in Helgason’s apartment for several days while he was
out of town. The plan was to start a game studio grounded in robust tech
infrastructure that could be licensed as well."

------
meheleventyone
Wow, this is a lovely, pragmatic, no nonsense game engine! And it has a non-
trivial example project and an editor! This is such a breath of fresh air for
game engine announcements.

I don't know if mrDIMAS is on HN but big congrats to him for this great
project.

~~~
mrDIMAS
Thanks a lot for the kind words!

~~~
smusamashah
Is there 2d drawing support, line drawing and other 2d shapes, bezeir curves?

~~~
adamnemecek
Not yet but there's a project that might be of your interest. It's a rust
nanovg clone
[https://github.com/cytecbg/gpucanvas](https://github.com/cytecbg/gpucanvas)

------
adamnemecek
This project is what I would call data oriented, as discussed yesterday on hn
[https://news.ycombinator.com/item?id=24506744](https://news.ycombinator.com/item?id=24506744).

It takes some parts of ECS but the UI is OOP-ish. I wonder if there is a good
ECS UI architecture. I have been exploring this lately in Rust, and right now
I have settled on jquery style selectors (don't laugh) where you have a
generic entity builder and associate a selector (id + class list) with each
entity. When an event fires, you check what selectors are associated with the
focused entity and call the associated callbacks. I also do this for
rendering. I'm not too crazy about this though. But I'm having a hard time
figuring out how to do behavior composition in Rust.

~~~
the_duke
> I wonder if there is a good ECS UI architecture.

orbtk [1] is based on ECS. I have not used it, so I can't comment on the the
quality of the architecture.

[1] [https://github.com/redox-os/orbtk](https://github.com/redox-os/orbtk)

~~~
adamnemecek
I am not crazy about orbtk. I don't think it's not quite ecs, and I'm not
crazy about the overuse of macros.

~~~
bronson
Why?

------
swalsh
What I love about this engine, is that I can really easily read the code and
reason what it does. I'd guess that given an hour or so of study I would feel
reasonably confident in trying to modify it.

~~~
keldaris
The same is also true of the author's previous engine [1], written in C99.
Would love to get the author's take on the costs and benefits of switching to
Rust on the basis of what's effectively a reasonably sized real world case
study, at least as far as individual projects go.

[1]
[https://github.com/mrDIMAS/DmitrysEngine](https://github.com/mrDIMAS/DmitrysEngine)

~~~
eggy
Thanks for the link! I am going to look more into rg3d, but the C99 engine is
interesting to me, because I use Raylib[0] for my C gamedev explorations. I
will never fully leave C, because I will be dead before C is fully, or
largely, displaced by the likes of Rust or another PL. I have also been
playing with Zig, and there is a Tetris demo done by Andrew Kelley the creator
of Zig, but no game engine I know of yet [1,2].

[0] [https://www.raylib.com/](https://www.raylib.com/)

[1] [https://ziglang.org/](https://ziglang.org/)

[2]
[https://github.com/andrewrk/tetris/blob/master/build.zig](https://github.com/andrewrk/tetris/blob/master/build.zig)

------
adamnemecek
It's a really impressive project. Also check out the associated scene editor
[https://github.com/mrDIMAS/rusty-editor](https://github.com/mrDIMAS/rusty-
editor)

Check out the UI framework that it uses
[https://github.com/mrDIMAS/rg3d-ui](https://github.com/mrDIMAS/rg3d-ui)

~~~
angryredblock
Agreed, this feature set looks like an incredible amount of work for a year.

Interestingly it seems it started as a shooter game more than an engine —
explains why the feature set is tailored towards that.

~~~
adamnemecek
I agree. Dmitry used to work on tools at Larian (studio behind Divinity:
Original Sin) so he had a decent amount of experience.

------
eggy
I have started playing with Bevy [1], so I wonder how this compares from an
ECS point of view?

I am a beginner at Rust, so any insight would be appreciated. Thanks!

Great to see gamedev taking off on Rust!

[1] [https://bevyengine.org/](https://bevyengine.org/)

~~~
adamnemecek
Bevy right now has little to show for itself besides a somewhat clean ECS api.

~~~
hoot
This feels a little harsh. A huge community effort has gathered behind Bevy,
and there are a lot of interesting projects that people have made with it so
far. Check out the showcase channel of the Bevy discord.

------
mcintyre1994
This looks really impressive! Given that Rust -> WebAssembly is at least a
thing, would it be plausible for someone to make that rusty-shooter demo work
in a browser?

~~~
mrDIMAS
There is also a problem with rg3d-sound - it supports only Windows and Linux
right now. So there will be no sound on other OSes. I've tried to add at least
macOS backend by myself, but I failed all attempts to install macOS on virtual
machine :(

~~~
korpiq
Hey what about someone donate a Mac to mrDIMAS? Might pay back =)

~~~
VWWHFSfQ
you're someone

------
TrueDuality
Wow, there are a lot of solid game engines coming out in Rust. Most are still
pretty early, but it's really impressive how much of the gamedev community has
such an interest in Rust.

------
adamnemecek
If you'd like to support the development of this engine, the author has a
patreon [https://www.patreon.com/mrdimas](https://www.patreon.com/mrdimas)

Unfortunately, Github sponsorships is not available in Russia.

Also, there's a discord channel dedicated to the project
[https://discord.gg/xENF5Uh](https://discord.gg/xENF5Uh)

------
angrygoat
Video of the demonstration FPS here:
[https://www.youtube.com/watch?v=UDn8ymyXPcI](https://www.youtube.com/watch?v=UDn8ymyXPcI)

~~~
shripadk
Looks like the author loves Quake 3. This looks so similar to pro-q3dm6 (The
Camping Grounds)! Love it!

------
beefsack
In Rust projects where you want to be developing multiple highly related
modules in tandem with each other, it can be helpful to just use a single
repository and a Cargo workspace[1].

You can still build and publish them individually, but it can make development
and testing much simpler.

[1]: [https://doc.rust-lang.org/book/ch14-03-cargo-
workspaces.html](https://doc.rust-lang.org/book/ch14-03-cargo-workspaces.html)

------
j-james
Particularly relevant: [https://arewegameyet.rs/](https://arewegameyet.rs/)

------
ensiferum
Shameless plug currently working on a 2d game engine +editor. Not release
ready yet but if its your cup of tea have a look and please share Feedback.

[http://github.com/ensisoft/gamestudio](http://github.com/ensisoft/gamestudio)

------
BookPage
This is awesome!!!! It would be cool if there were some binary releases, at
least for the shooter example. I'm not sure if there's anything huge blocking
that though?

Also I'm admittedly not rust-proficient yet but would the cargo run command be
cross-platform dependent, or is this a windows-only thing right now?

~~~
TheDesolate0
`cargo` is like `make` but fancy. so `cargo build` is the same as say running
`make`

it is very much cross platform, and actually much easier to get working under
GNU/Linux, *nix, or (ick) JobsOS.

[https://rustup.rs/](https://rustup.rs/) has the install scripts

------
jedimind
This is a excellent project, you should also make support via github possible
for those who don't want to use patreon.

------
pjmlp
Quite cool! This is the kind of stuff that might drive adoption among game
devs.

~~~
badsectoracula
I doubt projects like this would help. For big developers, 99.99% of the time
they are already riding on existing codebases (even when they call it by
different names for marketing reasons) - the last two AAA games i worked at
have codebases more than a decade old, one actually two decades old. While
technically they could add rust as an extra language, in practice this wont
happen both because the vast majority of game developers are conservative in
terms of languages but also because it creates extra barriers (most people who
write C++ code in games barely know C++ - the wizkids that everyone has in
mind when hearing about high octane game engines are a tiny minority compared
to _everyone else_ who touches a game's codebase) which make it harder to hire
new people (unlike other disciplines in gamedev, decent programmers aren't as
easy to find). Also everyone hates how slow C++ is to compile and last time i
checked rust is even worse.

For smaller developers projects like this still wont help drive adoption since
smaller developers have the freedom to decide on their own what language
they'd use (assuming they aren't already using an existing codebase, some of
the stuff above also apply to smaller developers) and they'd already be using
rust if they thought it'd help. In general i believe that developers who have
enough knowledge to make their own engine in other languages and be able to
make their engine in rust, would be able to tell if rust is a good choice or
not.

Or to put it in another way, i doubt projects like this will help drive
adoption for rust among game developers because the developers have either
already decided what language to use (be it rust or something else) or are not
in a position to decide what language to use.

(yeah sure, there might be an exception or two out there, but there are
hundreds -if not thousands- of engines... after all Remedy, a AAA studio, used
D in their engine yet you do not see much of an uptake of D among game
developers even though technically D would be easier to grok by C++
programmers, integrate with existing engines with its C++ interop and even
provides features like compile time code evaluation and generation for
features that i've seen C++ projects use overcompilated macros and external
build time generators that rely on brittle code comments to work)

~~~
adamnemecek
How would it not help? Someone might see this and realize that Rust is a
viable game dev option and adopt it for their next game.

In my experience, Rust is relatively fast on recompilation, possibly faster
than C++.

Rust is a much younger language so you have to wait.

~~~
badsectoracula
Anyone who has enough knowledge to build a game engine like rg3d also has
enough knowledge to be able to judge if Rust is capable of building an engine
like rg3d even if they haven't built an engine in Rust themselves.

If after reading abour Rust a programmer cannot figure out if Rust can be used
to make a game engine then that programmer is incapable of making a game
engine in the first place so in the grand scheme of things this chances
nothing.

~~~
adamnemecek
OK they do, so what.

------
sabujp
looking at the actual engine code, it's still all math and it looks like C++.
The programming language here doesn't make the math easier to understand,
example :
[https://github.com/mrDIMAS/rg3d/blob/master/src/renderer/sur...](https://github.com/mrDIMAS/rg3d/blob/master/src/renderer/surface.rs#L577)
. Better to read some books on computer graphics math :
[https://foundationsofgameenginedev.com/#fged1](https://foundationsofgameenginedev.com/#fged1)

~~~
canada_dry
That example code is quite readable though. Are there any languages that make
math more readable? Even purpose build code like matlab is about the same.

~~~
sabujp
well matlab can probably abstract much of the math away. You still have to
know what high level functions to use but I think I was looking for a
demonstration of the use of the libraries, e.g. how is collision detection
done? How do I draw primitives. How do i move the lighting, etc?

