Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spotlights do not work for orthographic projections #9605

Closed
itsybitesyspider opened this issue Aug 28, 2023 · 0 comments · Fixed by #9614
Closed

Spotlights do not work for orthographic projections #9605

itsybitesyspider opened this issue Aug 28, 2023 · 0 comments · Fixed by #9614
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior

Comments

@itsybitesyspider
Copy link

Bevy version

commit 4f1d9a6 (HEAD -> main, origin/main, origin/HEAD)
Date: Sun Aug 27 07:33:49 2023 -0700

[Optional] Relevant system information

cargo 1.70.0 (ec8a8a0ca 2023-04-25)
Debian 12

2023-08-28T00:41:15.115702Z  INFO bevy_render::renderer: AdapterInfo { name: "AMD Radeon RX 6600 XT (RADV NAVI23)", vendor: 4098, device: 29695, device_type: DiscreteGpu, driver: "radv", driver_info: "Mesa 22.3.6", backend: Vulkan }
2023-08-28T00:41:15.389897Z  INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Linux 12 Debian GNU/Linux", kernel: "6.1.0-1-amd64", cpu: "AMD Ryzen 9 5900 12-Core Processor", core_count: "12", memory: "15.5 GiB" }

What you did

Tried to add spotlights (car headlights) to my game project, but they never show up. Finally I added a test spotlight which strangely appeared only toward the bottom of the screen (not across most of the rest of the screen). I think what matters is probably not the bottom of the screen, but the fact that the "ground" is naturally closer to the camera in that region of the screen.

Replicated this problem in the spotlight example (cargo run --example spotlight) by replacing the camera in setup with this camera:

    commands.spawn(Camera3dBundle {
        transform: Transform::from_xyz(-4.0, 5.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y),
        projection: OrthographicProjection {
            scale: 5.0,
            scaling_mode: ScalingMode::FixedVertical(2.0),
            ..default()
        }.into(),
        ..default()
    });

What went wrong

Expected: The spotlight should illuminate the scene in the same way it does with a perspective camera.
Actual: It does not illuminate the scene at all, or only some areas of the screen. Correct behavior is demonstrated in the example: https://bevyengine.org/examples/3D%20Rendering/spotlight/

Additional information

Other information that can be used to further reproduce or isolate the problem.
This commonly includes:

  • screenshots: I made a gif. The bright flash is the spotlights. If you see a dark flash, that is the gif looping, it doesn't appear outside of the gif.

bevy_spotlights

I wonder if this screenshot is informative. I captured this by taking video and then screen-shotting one frame of the video. It flashes like lightning.

Screenshot from 2023-08-28 00-40-00

  • logs: don't see any interesting logs
  • workarounds that you used: Spotlights work fine in perspective projection, point lights work fine regardless.
@itsybitesyspider itsybitesyspider added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Aug 28, 2023
@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen and removed S-Needs-Triage This issue needs to be labelled labels Aug 28, 2023
github-merge-queue bot pushed a commit that referenced this issue Oct 8, 2023
# Objective

fix #9605

spotlight culling uses an incorrect cluster aabb for orthographic
projections: it does not take into account the near and far cluster
bounds at all.

## Solution

use z_near and z_far to determine cluster aabb in orthographic mode.

i'm not 100% sure this is the only change that's needed, but i am sure
this change is needed, and the example seems to work well now
(CLUSTERED_FORWARD_DEBUG_CLUSTER_LIGHT_COMPLEXITY shows good bounds
around the cone for a variety of orthographic setups).
regnarock pushed a commit to regnarock/bevy that referenced this issue Oct 13, 2023
# Objective

fix bevyengine#9605

spotlight culling uses an incorrect cluster aabb for orthographic
projections: it does not take into account the near and far cluster
bounds at all.

## Solution

use z_near and z_far to determine cluster aabb in orthographic mode.

i'm not 100% sure this is the only change that's needed, but i am sure
this change is needed, and the example seems to work well now
(CLUSTERED_FORWARD_DEBUG_CLUSTER_LIGHT_COMPLEXITY shows good bounds
around the cone for a variety of orthographic setups).
ameknite pushed a commit to ameknite/bevy that referenced this issue Nov 6, 2023
# Objective

fix bevyengine#9605

spotlight culling uses an incorrect cluster aabb for orthographic
projections: it does not take into account the near and far cluster
bounds at all.

## Solution

use z_near and z_far to determine cluster aabb in orthographic mode.

i'm not 100% sure this is the only change that's needed, but i am sure
this change is needed, and the example seems to work well now
(CLUSTERED_FORWARD_DEBUG_CLUSTER_LIGHT_COMPLEXITY shows good bounds
around the cone for a variety of orthographic setups).
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this issue Jan 9, 2024
# Objective

fix bevyengine#9605

spotlight culling uses an incorrect cluster aabb for orthographic
projections: it does not take into account the near and far cluster
bounds at all.

## Solution

use z_near and z_far to determine cluster aabb in orthographic mode.

i'm not 100% sure this is the only change that's needed, but i am sure
this change is needed, and the example seems to work well now
(CLUSTERED_FORWARD_DEBUG_CLUSTER_LIGHT_COMPLEXITY shows good bounds
around the cone for a variety of orthographic setups).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants