3D rendering
How the NEO engine draws a 3D world: cameras, meshes, materials, lights, shadows, the environment, post-processing and what works in web builds.
The NEO engine renders 3D scenes with a physically based renderer. You describe what to draw with ordinary components (a camera, meshes with materials, lights) and the renderer does the rest each frame. Effects such as bloom, fog and anti-aliasing are components you add to a camera.
This section is for creators who write Rust game code. Every type on these pages is in neo::prelude::* unless a page shows a longer path such as neo::post_process::bloom::Bloom.
A minimal 3D scene#
A camera, a light and a mesh with a material are enough to see something:
use neo::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.run();
}
fn setup(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
// the ground
commands.spawn((
Mesh3d(meshes.add(Circle::new(4.0))),
MeshMaterial3d(materials.add(Color::WHITE)),
Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)),
));
// a cube
commands.spawn((
Mesh3d(meshes.add(Cuboid::new(1.0, 1.0, 1.0))),
MeshMaterial3d(materials.add(Color::srgb_u8(124, 144, 255))),
Transform::from_xyz(0.0, 0.5, 0.0),
));
// a light that casts shadows
commands.spawn((
PointLight { shadow_maps_enabled: true, ..default() },
Transform::from_xyz(4.0, 8.0, 4.0),
));
// the camera
commands.spawn((
Camera3d::default(),
Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),
));
}Example: cargo run --example 3d_scene. Run examples from the engine core's workspace (the folder of the engine source that holds the neo crate's Cargo.toml).
Pages in this section#
| Page | What it covers |
|---|---|
| Cameras | Camera3d, projections, viewports, render order, render targets and lower render resolutions. |
| Meshes | Mesh3d, the built-in shapes, building your own meshes and meshes from glTF files. |
| Materials | StandardMaterial: colour, roughness, metal, textures, emission, transparency and decals. |
| Custom materials and shaders | The Material trait, WESL shaders and extending the standard material. |
| Lights | Point, spot, directional, area and ambient lights, and light units. |
| Shadows | Shadow maps, cascades, biases, filtering and contact shadows. |
| Environment | Skyboxes, environment maps, light probes, lightmaps, fog and the atmosphere. |
| Post-processing | HDR, tonemapping, exposure, bloom, colour grading, depth of field, motion blur and lens effects. |
| Anti-aliasing | MSAA, FXAA, SMAA, TAA and sharpening. |
| Screen-space effects | Prepasses, deferred rendering, SSAO, SSR, transmission and order-independent transparency. |
| Visibility | Visibility, culling, render layers, visibility ranges and occlusion culling. |
What runs where#
NEO's desktop builds (macOS, Windows, Linux) run every effect on these pages that's compiled in. Web builds draw with WebGL 2, which has no compute shaders and few storage buffers, so some effects are off or limited there. Each page says which; in short:
| On the web (WebGL 2) | Status |
|---|---|
Meshes, StandardMaterial, point, spot and directional lights, shadows, skyboxes, environment maps on the camera, distance fog, bloom, tonemapping, colour grading, MSAA, FXAA, SMAA | Work. |
| Directional lights | One per view, with one shadow cascade. |
| Point and spot lights, light probes | Up to 204 per view in total (the desktop allows far more). |
| SSAO, SSR, depth of field, auto exposure, the atmosphere, reflection probes, generated environment maps, order-independent transparency, wireframes, occlusion culling, clustered decals | Not available. The renderer skips them, logs a message where it can, and the game keeps running. |
Some effects also need a cargo feature that NEO's builds don't turn on, for example area lights (area_light_luts), soft shadows (experimental_pbr_pcss), extra material texture slots (pbr_*_textures), meshlets (meshlet) and ray-traced lighting (neo_solari). See Cargo features.