Skip to content

Directional lights are 4800x dimmer than point lights and spot lights  #8369

@fintelia

Description

@fintelia

Bevy version

2ec38d1 (but also happens on 0.10.x and probably others).

What you did

Delete the environment map lighting from the PBR example, then compare point light and directional light strengths.

The point light is sqrt(50^2 + 50^2 + 50^2) ≈ 86 meters from the origin and has a strength of 600K lumens. Which means 600,000 / (4 * PI * 86^2) ≈ 6.5 lux reaching the origin.

Point light

image

Same strength directional light

commands.spawn(DirectionalLightBundle {
    transform: Transform::from_xyz(50.0, 50.0, 50.0).looking_at(Vec3::ZERO, Vec3::Y),
    directional_light: DirectionalLight {
        illuminance: 6.5,
        ..default()
    },
    ..default()
});

image

4800x scaled directional light

commands.spawn(DirectionalLightBundle {
    transform: Transform::from_xyz(50.0, 50.0, 50.0).looking_at(Vec3::ZERO, Vec3::Y),
    directional_light: DirectionalLight {
        illuminance: 6.5 * 4800.0,
        ..default()
    },
    ..default()
});

image

Additional information

The bug is caused by this code which dims the strengths of directional lights by 4800x, but leaves point lights and spotlights unchanged:

// convert from illuminance (lux) to candelas
//
// exposure is hard coded at the moment but should be replaced
// by values coming from the camera
// see: https://google.github.io/filament/Filament.html#imagingpipeline/physicallybasedcamera/exposuresettings
const APERTURE: f32 = 4.0;
const SHUTTER_SPEED: f32 = 1.0 / 250.0;
const SENSITIVITY: f32 = 100.0;
let ev100 = f32::log2(APERTURE * APERTURE / SHUTTER_SPEED) - f32::log2(SENSITIVITY / 100.0);
let exposure = 1.0 / (f32::powf(2.0, ev100) * 1.2);
let intensity = light.illuminance * exposure;

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-BugAn unexpected or incorrect behaviorM-Needs-Migration-GuideA breaking change to Bevy's public API that needs to be noted in a migration guide

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions