Skip to content

SpotLight / PointLight artifacts in FogVolume #18371

@TimiSillman

Description

@TimiSillman

Bevy version

0.15.3

[Optional] Relevant system information

AdapterInfo { name: "NVIDIA GeForce RTX 3060 Ti", vendor: 4318, device: 9353, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "570.124.04", backend: Vulkan }

What you did

use bevy::{
    color::palettes::css::RED,
    core_pipeline::{bloom::Bloom, tonemapping::Tonemapping},
    pbr::{FogVolume, VolumetricFog, VolumetricLight},
    prelude::*,
};

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(Startup, setup)
        .add_systems(Update, move_camera)
        .run();
}

fn setup(mut commands: Commands) {
    commands.spawn((
        Transform::from_xyz(-2., 0., 0.),
        SpotLight {
            intensity: 5000.0, // lumens
            color: RED.into(),
            shadows_enabled: true,
            ..default()
        },
        VolumetricLight,
    ));

    commands.spawn((
        Transform::from_xyz(2., 0., 0.),
        SpotLight {
            intensity: 5000.0, // lumens
            color: RED.into(),
            shadows_enabled: true,
            ..default()
        },
        VolumetricLight,
    ));

    commands.spawn((
        FogVolume::default(),
        Transform::from_scale(Vec3::splat(35.0)),
    ));

    commands.spawn((
        Camera3d::default(),
        Camera {
            hdr: true,
            ..default()
        },
        Transform::from_xyz(0., 0., 5.),
        Tonemapping::TonyMcMapface,
        Bloom::default(),
        VolumetricFog {
            ambient_intensity: 0.,
            ..default()
        },
    ));
}

fn move_camera(
    mut query: Query<&mut Transform, With<Camera3d>>,
    input: Res<ButtonInput<KeyCode>>,
    time: Res<Time>,
) {
    for mut transform in query.iter_mut() {
        if input.pressed(KeyCode::ArrowUp) {
            transform.translation.z -= 10. * time.delta_secs();
        }

        if input.pressed(KeyCode::ArrowDown) {
            transform.translation.z += 10. * time.delta_secs();
        }

        if input.pressed(KeyCode::KeyZ) {
            transform.translation.z = 5.;
        }

        if input.pressed(KeyCode::KeyX) {
            transform.translation.z = 130.;
        }
    }
}

What went wrong

Using SpotLights or PointLights creates weird artifacts and is not always rendered. See video below

Additional information

First half of the video shows camera at z position 5. and creates weird artifacts. In second half of the video camera is positioned at z 130. lights are rendered and when moving camera back or forward lights disappear.

untitled.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-BugAn unexpected or incorrect behaviorS-Needs-InvestigationThis issue requires detective work to figure out what's going wrong

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions