11 ms·
rg3d: Rust 3D game engine with an FPS demo game and scene editor
- adamnemecek 6y agoIt'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 6y agoAgreed, 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 6y agoI agree. Dmitry used to work on tools at Larian (studio behind Divinity: Original Sin) so he had a decent amount of experience.
- swalsh 6y agoWhat 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.
- adamnemecek 6y agoI agree, it's a really clean codebase.
- Eikon 6y agoIt's indeed very pleasing to read. I love rust but one pet peeve of mine is that projects can unfortunately get very hard to follow / libraries very hard to use once too much generics start to get poured into.
- skohan 6y agoGenerics, and also heavy use of traits and macros can make code hard to follow IMO.
- mrec 6y agoI can't quantify it, but I get the impression that the Rust community is starting to turn against unnecessary use of generics and proc macros of late, albeit largely because of their impact on compile/link times rather than readability.
- skohan 6y agoI think macros are incredibly powerful when used parsimoniously, but can make code completely inscrutable and surprising when overused. There's probably an unavoidable trade-off between the flexibility and expressiveness of a language and readability (and possibly compile times). It's part of the reason I would recommend a more restrictive language like Go in a professional setting, even if I would rather program in Rust at home.
- Thaxll 6y agoThat's the case for most engine side project, they're a lot of C++ example like that. Once you start adding a lot of features its another story ...
- adamnemecek 6y agoI think that Rust's features allow for cleaner code bases.
- Thaxll 6y agoI don't see why Rust would be cleaner than modern C++ codebase.
- leetcrew 6y agoc++ is a bit more verbose than rust. think about all the stdlib functions that take begin and end iterators for containers. there's an overload for std::set_difference that takes six arguments, five of them being iterators.
- pjmlp 6y agoRanges and fold expressions take care of that.
- adamnemecek 6y agoThere is a lot more than just those two.
- pjmlp 6y agoI was replying to the provided examples, more examples get more counterexamples.
- leetcrew 6y agothat's true and I am very excited for ranges. sadly I am still waiting for c++17 to be switched on in my build system :/ still there's lots of other stuff that's more verbose in c++ than rust, often because it was bolted on much later. think about getting individual elements out of a tuple. in c++: `std::get<0>(tuple)` for each desired element or `std::tie(elt0, std::ignore, elt2) = tuple;` in rust: `tuple.0`, not sure if there's an equivalent to the std::ignore/std::tie combo
- keldaris 6y agoThe 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 6y agoThanks 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
- bufferoverflow 6y agoThe graphics looks like it's from 15-20 years ago. Modern game engines are so far ahead of this, rg3d has a lot of catching up to do.
- surfsvammel 6y agoThat might be true for the most cutting edge 3D shooters. But nowadays that’s not all that matters. I’m sure this can find a niche.
- bufferoverflow 6y agoI'm not talking about shooters. I'm talking about what it looks like. The lighting, specifically.
- adamnemecek 6y agoThat's something that can be improved.
- bufferoverflow 6y agoThat's an empty platitude. Almost anything can be improved.
- adamnemecek 6y agoOK, look at how good of a foundation it is.
- cycloptic 6y agoHave you considered collaborating with the author to improve the lighting? I'm sure they wouldn't mind help.
- mrDIMAS 6y agoTo be honest I'm not trying to implement "bleeding edge" renderer, it would just take enormous amount of time which can be put into other more important parts (there are plenty of them).
- adamnemecek 6y agoThis 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 6y ago> 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 6y agoI 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 6y agoWhy?
- pjmlp 6y agoECS is also OOP. I guess someone needs to provide examples in Objective-C, Eiffel and CLOS to settle it up.
- DecoPerson 6y agoECS is not OOP. In ECS, one system can touch the innards of multiple kinds of components directly, and one kind of component can be touched by multiple systems. Components only hold data and no logic, so in most ECS designs systems will know about the internals of components intimately. This shows a design can ECS-compliant while violating a key part of OOP methodology: encapsulation. You can use ECS and OOP in tandem by re-introducing encapsulation, as well as any other parts of OOP lost, but you need to be careful not to violate key parts of ECS, such as component not being allowed to have any “logic” (I out logic in quotes because it’s not well-defined: does logic mean ANY code or just... non-boilerplate code?) One must consider how a codebase will evolve over time, which requires putting yourself in the shoes of those who will be working on the codebase. What benefits does strictly confirming to both ECS and OOP bring? Does the introduction of ECS bring enough structure that the codebase can remain clean, performant, maintainable, portable, etc even without OOP? Is there some kind of hybrid of ECS and OOP where the rules of each are relaxed to create an even better structure? How do all of these potential designs actually look in practice, and is there clear mappings from problems in the problem domain to the philosophical structure being imposed? In games, it’s hard to map some of the problems to OOP structures (while remaining conformant, clean, performant, maintainable, portable). ECS isn’t perfect, but it’s much better. I find using C-style, OOP, Actor model, and ECS structuring for different bits of code the best solution. There isn’t a one-size-fits-all when it comes to those things, unfortunately. Though I believe there will be one day (that is: a language arrives which has a model that everything maps to nicely and we’re all happy using and we all say “Wow everything’s so simple now”)
- Narann 6y agoWhat 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.
- deleted 6y ago[deleted]
- mrDIMAS 6y agoThe 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 6y agoAs they say, you don't write an engine - you write a game, and the engine comes out of it. Impressive work!
- kleiba 6y agoNot if you write Handmade Hero.
- codetrotter 6y agoHMH 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.
- angrygoat 6y agoVideo of the demonstration FPS here: https://www.youtube.com/watch?v=UDn8ymyXPcI https://www.youtube.com/watch?v=UDn8ymyXPcI
- shripadk 6y agoLooks like the author loves Quake 3. This looks so similar to pro-q3dm6 (The Camping Grounds)! Love it!
- meheleventyone 6y agoWow, 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.
- adamnemecek 6y agoI have alerted him of this post so he'll get your message.
- mrDIMAS 6y agoThanks a lot for the kind words!
- smusamashah 6y agoIs there 2d drawing support, line drawing and other 2d shapes, bezeir curves?
- adamnemecek 6y agoNot 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
- j-james 6y agoParticularly relevant: https://arewegameyet.rs/ https://arewegameyet.rs/
- mcintyre1994 6y agoThis 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?
- brundolf 6y agoThe graphics code would have to be ported to WebGL, and then there might be an extra hurdle getting WASM to talk to WebGL directly. But it's doable, yes.
- pjmlp 6y agoReferences are almost in, by next year you can probably already talk directly to WebGL.
- steveklabnik 6y agohttps://rustwasm.github.io/wasm-bindgen/examples/webgl.html https://rustwasm.github.io/wasm-bindgen/examples/webgl.html
- kettlecorn 6y agoRust with WebGL is pretty seamless today. I wrote a game for a gamejam using Rust, Wasm, and WebGL without any engine: https://kettlecorn.itch.io/wonder https://kettlecorn.itch.io/wonder It makes use of ‘glow’, a Rust library that lets you write regular OpenGL code that runs across desktop, mobile, and web: https://github.com/grovesNL/glow https://github.com/grovesNL/glow
- deleted 6y ago[deleted]
- mrDIMAS 6y agoThere 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 :(
- deleted 6y ago[deleted]
- TrueDuality 6y agoWow, 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.
- eggy 6y agoI 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 6y agoBevy right now has little to show for itself besides a somewhat clean ECS api.
- adamnemecek 6y agoIf 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
- pjmlp 6y agoQuite cool! This is the kind of stuff that might drive adoption among game devs.
- badsectoracula 6y agoI 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)
- 6y ago
- sabujp 6y agolooking 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/surface.rs#L577 https://github.com/mrDIMAS/rg3d/blob/master/src/renderer/sur... . Better to read some books on computer graphics math : https://foundationsofgameenginedev.com/#fged1 https://foundationsofgameenginedev.com/#fged1
- canada_dry 6y agoThat 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 6y agowell 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?
- detaro 6y agoWhat are you responding to? Better for what?
- BookPage 6y agoThis 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 6y ago`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
- deleted 6y ago[deleted]
- beefsack 6y agoIn 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
- ensiferum 6y agoShameless 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
- jedimind 6y agoThis is a excellent project, you should also make support via github possible for those who don't want to use patreon.