Skip to content
Snippets Groups Projects
Commit 3344300c authored by NiseVoid's avatar NiseVoid
Browse files

Fix HDR

parent 9dbe7813
No related branches found
No related tags found
No related merge requests found
......@@ -156,7 +156,7 @@ pub fn update_opacity_layer_cameras(
WindowRef::Primary => primary_window.get_single().unwrap(),
};
if let Ok(camera_window) = windows.get(window_entity) {
opacity_layers.add_or_update(&camera_entity, camera_window, &mut images);
opacity_layers.add_or_update(&camera_entity, &camera, camera_window, &mut images);
}
}
}
......
......@@ -7,6 +7,7 @@ use bevy::{
TextureView,
},
texture::BevyDefault,
view::ViewTarget,
},
utils::HashMap,
window::Window,
......@@ -22,14 +23,15 @@ impl OpacityLayerManager {
pub(crate) fn add_or_update(
&mut self,
camera_entity: &Entity,
camera: &Camera,
window: &Window,
images: &mut Assets<Image>,
) {
if let Some(opacity_camera) = self.camera_layers.get_mut(camera_entity) {
opacity_camera.update_images(window, images);
opacity_camera.update_images(window, camera, images);
} else {
self.camera_layers
.insert(*camera_entity, OpacityCamera::new(window, images));
.insert(*camera_entity, OpacityCamera::new(window, camera, images));
}
}
}
......@@ -44,8 +46,12 @@ pub const MAX_OPACITY_LAYERS: u32 = 5;
impl OpacityCamera {
/// Creates as new opacity layer render target manager
pub(crate) fn new(window: &Window, images: &mut Assets<Image>) -> Self {
let main_texture_format = TextureFormat::bevy_default();
pub(crate) fn new(window: &Window, camera: &Camera, images: &mut Assets<Image>) -> Self {
let main_texture_format = if camera.hdr {
ViewTarget::TEXTURE_FORMAT_HDR
} else {
TextureFormat::bevy_default()
};
let mut layers = HashMap::default();
for layer in 1..MAX_OPACITY_LAYERS {
......@@ -82,8 +88,17 @@ impl OpacityCamera {
}
}
pub(crate) fn update_images(&mut self, window: &Window, images: &mut Assets<Image>) {
let main_texture_format = TextureFormat::bevy_default();
pub(crate) fn update_images(
&mut self,
window: &Window,
camera: &Camera,
images: &mut Assets<Image>,
) {
let main_texture_format = if camera.hdr {
ViewTarget::TEXTURE_FORMAT_HDR
} else {
TextureFormat::bevy_default()
};
let new_size = Extent3d {
width: window.resolution.physical_width(),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment