rg3d 0.24 Feature Highlights

I’m happy to announce that rg3d 0.24 has been released! This release has major improvements in 2D support, physics, user interface, performance, resource system, book, etc. Let’s briefly go over the most significant changes and improvements.

Improved 2D support

Since the very beginning, the engine was focused on 3D games only, but in rg3d 0.23 the situation has changed a bit, a simple version of 2D scene was added. However, in this version, 2D scenes were completely deleted from the engine and 2D functionality was integrated in standard 3D scene. Now, to create 2D game you just need to change projection mode of your camera to orthographic and put some objects in standard 3D scene. Here is the very simple 2D scene made in the editor and imported in a simple 2D game:

2d scene

This is the same scene, but in the editor:

2d scene in editor

All visual objects here are sprites (rectangles in engine terms), sprites using heavily optimized renderer so you can put thousands objects in the scene with very little performance impact. Since 2D is actually 3D, you can use standard 3D objects to create 2D games world with 3D objects in them, this is very flexible approach that allows you to mix various approaches to achieve desired results.

Standard lighting system works with 2D objects as well as with 3D, however 2D objects cannot cast shadows, this will be improved in future releases:

2d lighting

The engine now has full-featured 2D physics, here is a simple example with three dynamic boxes and static ground:

2d physics

Book

The engine now has guide book. It is still in early development stage, but should help you to start using the engine. It covers basic aspects of the engine, describes how various parts of the engine works, how they should be used. It also has four tutorials that will guide you through game development process from start to finish.

Physics integration

Physics entities (rigid bodies, colliders, joints) were integrated in scene graph, this means that you can link such objects as other scene nodes. Look closely at the editor screenshot above, as you can see there is Rigid Body 2D node with Rectangle and Collider 2D nodes. Previously physics was standalone and scene nodes were linked with the hacky “physics binder”.

Inspector and lightweight reflection

One of the major improvements in this version is the new lightweight reflection and the Inspector widget made with it. Reflection means the access to object’s properties in runtime, rg3d does this via Inspect trait with proc-macro:

#[derive(Inspect)]
struct Foo {
   bar: String,
   baz: u32
}

Proc-macro will generate property definitions for every field (unless it is marked with #[inspect(skip)] attribute), which can be accessed at once using .properties() method of Inspect trait. Keep in mind that since this is lightweight reflection, it does not let you mutate property value nor call methods and such stuff, only read information about structure fields, enum variants, etc. This may sound too restrictive, but on practice it is not. This reflection was made specifically for the editor needs. The new Inspector widget utilizes its at full capacity:

Inspector

Inspector widget shows you all available fields of an object, it supports nested structures, arrays, vectors, enumerations, custom property editors and many more. The editor uses it at 110% capacity :)

Performance

0.23 introduced custom material system which was quite unoptimized and had a bit disappointing performance. This release fixes that and improves performance by 2.5x times.

The UI layout system was heavily optimized too, some performance optimizations gave 1000x (this is not a typo) boost on complex visual trees. rg3d-ui now depends on invalidation, instead of checking everything every frame. Now it is capable of handling up to 100000 widgets at once without any significant performance loss. This is especially important when you’re editing large maps with thousands of objects on them.

Resource management

rg3d slowly improving resource management, one of the major improvement in it is import options files. Previously you have to specify how to load textures, models, sounds, etc. from code, now import options were moved to .options files. Let’s check a simple example: for example you want to change filtering from bilinear to blocky for your 2D pixel game, you can make it like so (assuming you have sprite.jpg file)

(
    minification_filter: Nearest,
    magnification_filter: Nearest,
    s_wrap_mode: Repeat,
    t_wrap_mode: Repeat,
    anisotropy: 1.0,
    compression: NoCompression,    
)

And save that to sprite.jpg.options, the engine will read this file and configure the texture accordingly. Every field in options files is optional.

The engine is now able to hot-reload textures, this is especially useful for making 2D games. The engine generates mip-maps for textures using Lanczos filter, which gives you excellent results.

Sound

Sound engine (rg3d-sound) has improved samples interpolation for cases when sample rate != 1.0, previuosly it used simplest nearest interpolation, not it is linear which sounds much better and has must fewer harmonics.

This is the previous resampling algorithm for 1 kHz sine wave:

Nearest resampling

This is the new for the same signal:

Linear resampling

As you can see the new algorithm produces much fewer harmonics.

Miscellaneous

The editor repository was merged into engine’s repository, this means that you no longer need to download both projects to run the editor.

Full list of major changes

Editor improvements

Aside already mentioned Inspector, the editor now has an ability to search for scene items by their names:

Editor search

Asset browser now allows you to edit asset import options and hot-reload assets:

Hot reload

Here is the full list of major changes:

Migration guide

It can be found in the changelog.

Support the project

If you like the project and want to see it alive, please consider doing either a monthly donation on Patreon or do a one-time donation via BuyMeACoffee.

Contributors

Huge thanks for all the contributors who helped to improve the engine!

Community

Join the Discord server

Special thanks

The engine is supported by very generous people, their donations provides sustainable development of the engine:

Bronze patrons

Brandon Thomas
Taylor C. Richberger

Patrons

Avery Wagar George Atkinson Erlend Sogge Heggen
Mitch Skinner
ozkriff
Taylor Gerpheide
zrkn
Aleks Row
Edward L
L.apz
Luke Jones
toyboot4e
Vish Vadlamani
Alexey Kuznetsov
Daniel Simon
Jesper Nordenberg
Kornel
Parham Gholami
Yuki Ishii
Joseph Catrambone
MGlolenstine
zamar lomax Gheorghe Ugrik Anton Zelenin Barugon

Former patrons

Tom Leys Jay Sistar tc
false
BlueSkye
Ben Anderson
Thomas Iulian Radu Vitaliy (ArcticNoise) Chernyshev