-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add HDR support As HDR uses a different texture format, we need to set it on a per view basis. As the pipeline is currently more of a "one and done" construct, we need to make use of a specialized pipeline. It allows us to dynamically create the render pipeline descriptor, giving us a place to hook into if each view has HDR enabled. On the view node side of things, we need to ensure we're grabbing the specialized pipeline ID from the view entity, as we are no longer constructing a "static" variant of the pipeline. * Update CHANGELOG.md
- Loading branch information
Showing
6 changed files
with
107 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,30 @@ | ||
mod node; | ||
mod pipeline; | ||
mod prepare; | ||
|
||
use bevy::{ | ||
asset::Handle, | ||
render::{render_graph::RenderLabel, render_resource::Shader}, | ||
ecs::component::Component, | ||
render::{ | ||
render_graph::RenderLabel, | ||
render_resource::{CachedRenderPipelineId, Shader}, | ||
}, | ||
}; | ||
|
||
pub use node::LightingNode; | ||
pub use pipeline::LightingPipeline; | ||
pub use prepare::prepare_lighting_pipelines; | ||
|
||
pub const LIGHTING_SHADER: Handle<Shader> = | ||
Handle::weak_from_u128(111120241052143214281687226997564407636); | ||
|
||
#[derive(Debug, Hash, PartialEq, Eq, Clone, RenderLabel)] | ||
pub struct LightingPass; | ||
|
||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] | ||
pub struct LightingPipelineKey { | ||
pub hdr: bool, | ||
} | ||
|
||
#[derive(Component)] | ||
pub struct LightingPipelineId(pub CachedRenderPipelineId); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use bevy::{ | ||
ecs::{ | ||
entity::Entity, | ||
query::With, | ||
system::{Commands, Query, Res, ResMut}, | ||
}, | ||
render::{ | ||
render_resource::{PipelineCache, SpecializedRenderPipelines}, | ||
view::ExtractedView, | ||
}, | ||
}; | ||
|
||
use crate::render::extract::ExtractedAmbientLight2d; | ||
|
||
use super::{LightingPipeline, LightingPipelineId, LightingPipelineKey}; | ||
|
||
pub fn prepare_lighting_pipelines( | ||
mut commands: Commands, | ||
pipeline_cache: Res<PipelineCache>, | ||
mut pipelines: ResMut<SpecializedRenderPipelines<LightingPipeline>>, | ||
lighting_pipeline: Res<LightingPipeline>, | ||
view_targets: Query<(Entity, &ExtractedView), With<ExtractedAmbientLight2d>>, | ||
) { | ||
for (entity, view) in view_targets.iter() { | ||
let pipeline_id = pipelines.specialize( | ||
&pipeline_cache, | ||
&lighting_pipeline, | ||
LightingPipelineKey { hdr: view.hdr }, | ||
); | ||
|
||
commands | ||
.entity(entity) | ||
.insert(LightingPipelineId(pipeline_id)); | ||
} | ||
} |