Skip to content

Commit

Permalink
use in post_processing example
Browse files Browse the repository at this point in the history
  • Loading branch information
IceSentry committed Oct 22, 2023
1 parent 0530e82 commit 5369d6b
Showing 1 changed file with 18 additions and 37 deletions.
55 changes: 18 additions & 37 deletions examples/shader/post_processing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ use bevy::{
NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner,
},
render_resource::{
BindGroupEntries, BindGroupLayout, BindGroupLayoutDescriptor, BindGroupLayoutEntry,
BindingType, CachedRenderPipelineId, ColorTargetState, ColorWrites, FragmentState,
MultisampleState, Operations, PipelineCache, PrimitiveState, RenderPassColorAttachment,
RenderPassDescriptor, RenderPipelineDescriptor, Sampler, SamplerBindingType,
SamplerDescriptor, ShaderStages, ShaderType, TextureFormat, TextureSampleType,
TextureViewDimension,
sampler, texture_2d_f32, uniform_buffer, BindGroupEntries, BindGroupLayout,
BindGroupLayoutDescriptor, BindGroupLayoutEntries, CachedRenderPipelineId,
ColorTargetState, ColorWrites, FragmentState, MultisampleState, Operations,
PipelineCache, PrimitiveState, RenderPassColorAttachment, RenderPassDescriptor,
RenderPipelineDescriptor, Sampler, SamplerBindingType, SamplerDescriptor, ShaderStages,
ShaderType, TextureFormat,
},
renderer::{RenderContext, RenderDevice},
texture::BevyDefault,
Expand Down Expand Up @@ -228,37 +228,18 @@ impl FromWorld for PostProcessPipeline {
// We need to define the bind group layout used for our pipeline
let layout = render_device.create_bind_group_layout(&BindGroupLayoutDescriptor {
label: Some("post_process_bind_group_layout"),
entries: &[
// The screen texture
BindGroupLayoutEntry {
binding: 0,
visibility: ShaderStages::FRAGMENT,
ty: BindingType::Texture {
sample_type: TextureSampleType::Float { filterable: true },
view_dimension: TextureViewDimension::D2,
multisampled: false,
},
count: None,
},
// The sampler that will be used to sample the screen texture
BindGroupLayoutEntry {
binding: 1,
visibility: ShaderStages::FRAGMENT,
ty: BindingType::Sampler(SamplerBindingType::Filtering),
count: None,
},
// The settings uniform that will control the effect
BindGroupLayoutEntry {
binding: 2,
visibility: ShaderStages::FRAGMENT,
ty: BindingType::Buffer {
ty: bevy::render::render_resource::BufferBindingType::Uniform,
has_dynamic_offset: false,
min_binding_size: Some(PostProcessSettings::min_size()),
},
count: None,
},
],
entries: &BindGroupLayoutEntries::sequential(
// The layout entries will only be visible in the fragment stage
ShaderStages::FRAGMENT,
(
// The screen texture
texture_2d_f32(),
// The sampler that will be used to sample the screen texture
sampler(SamplerBindingType::Filtering),
// The settings uniform that will control the effect
uniform_buffer(false, Some(PostProcessSettings::min_size())),
),
),
});

// We can create the sampler here since it won't change at runtime and doesn't depend on the view
Expand Down

0 comments on commit 5369d6b

Please sign in to comment.