bevy-hikari
is an implementation of global illumination for Bevy.
After Bevy releasing 0.8, the plugin moves to deferred hybrid path tracing.
For the old version (0.1.x) which uses voxel cone tracing with anisotropic mip-mapping, please check the bevy-0.6
branch.
| bevy
| bevy-hikari
|
| ------ | ------------- |
| 0.6 | 0.1 |
| 0.8 | 0.2 |
| 0.9 | 0.3 |
HikariPlugin
to your App
after PbrPlugin
HikariSettings
component to the cameraOne can configure the renderer through HikariSettings
component on the camera entity.
Available options are:
rust
pub struct HikariSettings {
/// The interval of frames between sample validation passes.
pub direct_validate_interval: usize,
/// The interval of frames between sample validation passes.
pub emissive_validate_interval: usize,
/// Temporal reservoir sample count is capped by this value.
pub max_temporal_reuse_count: usize,
/// Spatial reservoir sample count is capped by this value.
pub max_spatial_reuse_count: usize,
/// Half angle of the solar cone apex in radians.
pub solar_angle: f32,
/// Count of indirect bounces.
pub indirect_bounces: usize,
/// Threshold for the indirect luminance to reduce fireflies.
pub max_indirect_luminance: f32,
/// Clear color override.
pub clear_color: Color,
/// Whether to do temporal sample reuse in ReSTIR.
pub temporal_reuse: bool,
/// Whether to do spatial sample reuse in ReSTIR.
pub spatial_reuse: bool,
/// Whether to do noise filtering.
pub denoise: bool,
/// Which temporal filtering implementation to use.
pub taa: Taa,
/// Which upscaling implementation to use.
pub upscale: Upscale,
}
If you are unsure about some terms in these options, you could check render passes for details.
Notes:
- Please run with --release
flag to avoid the texture non-uniform indexing error
- Supported meshes must have these 3 vertex attributes: position, normal and uv
```rust use bevy::prelude::; use bevy_hikari::prelude::; use std::f32::consts::PI;
fn main() { App::new() .addplugins(DefaultPlugins) .addplugin(HikariPlugin { removemainpass: true, }) .addstartupsystem(setup) .run(); }
fn setup(
mut commands: Commands,
mut meshes: ResMut
// Only directional light is supported
commands.spawn(DirectionalLightBundle {
directional_light: DirectionalLight {
illuminance: 10000.0,
..Default::default()
},
transform: Transform {
translation: Vec3::new(0.0, 5.0, 0.0),
rotation: Quat::from_euler(EulerRot::XYZ, -PI / 4.0, PI / 4.0, 0.0),
..Default::default()
},
..Default::default()
});
// Camera
commands.spawn((
Camera3dBundle {
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
..Default::default()
},
// Add [`HikariSettings`] component to enable GI rendering
HikariSettings::default(),
));
} ```
Here are the screenshots of examples.
Just like Bevy, all code in this repository is dual-licensed under either:
at your option.