Skip to content

Camera.computed.target_info does not update when RenderTarget::None { size } is modified #23437

@OTOMariK

Description

@OTOMariK

Bevy version and features

  • 0.18.1
  • default features

What you did

  1. Create a 3d camera entity with RenderTarget::None
  2. print value of camera.computed.target_info.
  3. Update the RenderTarget::None { size }.

Or run code below:

use bevy::{camera::RenderTarget, prelude::*};
fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(Startup, setup)
        .add_systems(Update, update)
        .run();
}

fn setup(mut commands: Commands) {
    commands.spawn((
        Camera3d::default(),
        RenderTarget::None {
            size: UVec2::splat(512),
        },
    ));
}

fn update(query: Single<(&Camera, &mut RenderTarget)>, time: Res<Time>) {
    let (camera, mut target) = query.into_inner();
    bevy::log::info!("{:?}, {:?}", camera.computed.target_info, *target);
    let size = ((time.elapsed_secs().sin() + 2.0) * 100.0) as u32;
    *target = RenderTarget::None {
        size: UVec2::splat(size),
    };
}

What went wrong

the console outputs:

Some(RenderTargetInfo { physical_size: UVec2(512, 512), scale_factor: 1.0 }), None { size: UVec2(512, 512) }
Some(RenderTargetInfo { physical_size: UVec2(200, 200), scale_factor: 1.0 }), None { size: UVec2(200, 200) }
Some(RenderTargetInfo { physical_size: UVec2(200, 200), scale_factor: 1.0 }), None { size: UVec2(210, 210) }
Some(RenderTargetInfo { physical_size: UVec2(200, 200), scale_factor: 1.0 }), None { size: UVec2(234, 234) }
......
  • what were you expecting?
    physical_size should be same as RenderTarget::None { size }
  • what actually happened?
    after the second update tick, physical_size remains unchanged

Additional information

the is_changed() function of NormalizedRenderTarget always return false when it is NormalizedRenderTarget::None, making the camera_system failed to update the corresponding value.

I discovered this bug while examining the render_depth_to_texture example. When I modified the size value in RenderTarget::None { size }, the size of the corresponding ViewDepthTexture did not change accordingly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-BugAn unexpected or incorrect behaviorD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!

    Type

    No type

    Projects

    Status

    Needs SME Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions