diff options
Diffstat (limited to 'src/resources.rs')
-rw-r--r-- | src/resources.rs | 67 |
1 files changed, 43 insertions, 24 deletions
diff --git a/src/resources.rs b/src/resources.rs index d755dc2..24aeeec 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -1,4 +1,18 @@ -use bevy::{prelude::*, render::{render_resource::{Sampler, BindGroupLayout, BindGroupLayoutEntries, ShaderStages, binding_types::{texture_2d, sampler, uniform_buffer}, TextureSampleType, SamplerBindingType, SamplerDescriptor, PipelineCache, RenderPipelineDescriptor, CachedRenderPipelineId, PrimitiveState, MultisampleState, FragmentState, ColorTargetState, TextureFormat, ColorWrites}, renderer::RenderDevice, texture::BevyDefault}, core_pipeline::fullscreen_vertex_shader::fullscreen_shader_vertex_state}; +use bevy::{ + core_pipeline::fullscreen_vertex_shader::fullscreen_shader_vertex_state, + prelude::*, + render::{ + render_resource::{ + binding_types::{sampler, texture_2d, uniform_buffer}, + BindGroupLayout, BindGroupLayoutEntries, CachedRenderPipelineId, ColorTargetState, + ColorWrites, FragmentState, MultisampleState, PipelineCache, PrimitiveState, + RenderPipelineDescriptor, Sampler, SamplerBindingType, SamplerDescriptor, ShaderStages, + TextureFormat, TextureSampleType, + }, + renderer::RenderDevice, + texture::BevyDefault, + }, +}; use super::components; @@ -19,9 +33,9 @@ impl FromWorld for OutlinePostProcessPipeline { &BindGroupLayoutEntries::sequential( ShaderStages::FRAGMENT, ( - texture_2d(TextureSampleType::Float{ filterable: true }), + texture_2d(TextureSampleType::Float { filterable: true }), sampler(SamplerBindingType::Filtering), - texture_2d(TextureSampleType::Float{ filterable: true }), + texture_2d(TextureSampleType::Float { filterable: true }), sampler(SamplerBindingType::Filtering), uniform_buffer::<components::OutlinePostProcessSettings>(false), ), @@ -31,27 +45,32 @@ impl FromWorld for OutlinePostProcessPipeline { let screen_sampler = render_device.create_sampler(&SamplerDescriptor::default()); let normal_sampler = render_device.create_sampler(&SamplerDescriptor::default()); - let shader = world.resource::<AssetServer>().load::<Shader>("embedded://grex_outline_post_process/../assets/shaders/outline_post_process.wgsl"); - - let pipeline_id = world.resource_mut::<PipelineCache>().queue_render_pipeline(RenderPipelineDescriptor { - label: Some("outline_post_process_render_pipeline".into()), - layout: vec![layout.clone()], - push_constant_ranges: vec![], - vertex: fullscreen_shader_vertex_state(), - primitive: PrimitiveState::default(), - depth_stencil: None, - multisample: MultisampleState::default(), - fragment: Some(FragmentState { - shader, - shader_defs: vec![], - entry_point: "fragment".into(), - targets: vec![Some(ColorTargetState { - format: TextureFormat::bevy_default(), - blend: None, - write_mask: ColorWrites::ALL, - })], - }), - }); + let shader = world.resource::<AssetServer>().load::<Shader>( + "embedded://bevy_outline_post_process/../assets/shaders/outline_post_process.wgsl", + ); + + let pipeline_id = + world + .resource_mut::<PipelineCache>() + .queue_render_pipeline(RenderPipelineDescriptor { + label: Some("outline_post_process_render_pipeline".into()), + layout: vec![layout.clone()], + push_constant_ranges: vec![], + vertex: fullscreen_shader_vertex_state(), + primitive: PrimitiveState::default(), + depth_stencil: None, + multisample: MultisampleState::default(), + fragment: Some(FragmentState { + shader, + shader_defs: vec![], + entry_point: "fragment".into(), + targets: vec![Some(ColorTargetState { + format: TextureFormat::bevy_default(), + blend: None, + write_mask: ColorWrites::ALL, + })], + }), + }); Self { layout, |