@@ -23,7 +23,7 @@ use bevy_render::{
23
23
24
24
mod node;
25
25
26
- pub use node:: CASNode ;
26
+ pub use node:: CasNode ;
27
27
28
28
/// Applies a contrast adaptive sharpening (CAS) filter to the camera.
29
29
///
@@ -66,28 +66,28 @@ impl Default for ContrastAdaptiveSharpeningSettings {
66
66
67
67
#[ derive( Component , Default , Reflect , Clone ) ]
68
68
#[ reflect( Component ) ]
69
- pub struct DenoiseCAS ( bool ) ;
69
+ pub struct DenoiseCas ( bool ) ;
70
70
71
71
/// The uniform struct extracted from [`ContrastAdaptiveSharpeningSettings`] attached to a [`Camera`].
72
72
/// Will be available for use in the CAS shader.
73
73
#[ doc( hidden) ]
74
74
#[ derive( Component , ShaderType , Clone ) ]
75
- pub struct CASUniform {
75
+ pub struct CasUniform {
76
76
sharpness : f32 ,
77
77
}
78
78
79
79
impl ExtractComponent for ContrastAdaptiveSharpeningSettings {
80
80
type QueryData = & ' static Self ;
81
81
type QueryFilter = With < Camera > ;
82
- type Out = ( DenoiseCAS , CASUniform ) ;
82
+ type Out = ( DenoiseCas , CasUniform ) ;
83
83
84
84
fn extract_component ( item : QueryItem < Self :: QueryData > ) -> Option < Self :: Out > {
85
85
if !item. enabled || item. sharpening_strength == 0.0 {
86
86
return None ;
87
87
}
88
88
Some ( (
89
- DenoiseCAS ( item. denoise ) ,
90
- CASUniform {
89
+ DenoiseCas ( item. denoise ) ,
90
+ CasUniform {
91
91
// above 1.0 causes extreme artifacts and fireflies
92
92
sharpness : item. sharpening_strength . clamp ( 0.0 , 1.0 ) ,
93
93
} ,
@@ -99,9 +99,9 @@ const CONTRAST_ADAPTIVE_SHARPENING_SHADER_HANDLE: Handle<Shader> =
99
99
Handle :: weak_from_u128 ( 6925381244141981602 ) ;
100
100
101
101
/// Adds Support for Contrast Adaptive Sharpening (CAS).
102
- pub struct CASPlugin ;
102
+ pub struct CasPlugin ;
103
103
104
- impl Plugin for CASPlugin {
104
+ impl Plugin for CasPlugin {
105
105
fn build ( & self , app : & mut App ) {
106
106
load_internal_asset ! (
107
107
app,
@@ -113,19 +113,19 @@ impl Plugin for CASPlugin {
113
113
app. register_type :: < ContrastAdaptiveSharpeningSettings > ( ) ;
114
114
app. add_plugins ( (
115
115
ExtractComponentPlugin :: < ContrastAdaptiveSharpeningSettings > :: default ( ) ,
116
- UniformComponentPlugin :: < CASUniform > :: default ( ) ,
116
+ UniformComponentPlugin :: < CasUniform > :: default ( ) ,
117
117
) ) ;
118
118
119
119
let Some ( render_app) = app. get_sub_app_mut ( RenderApp ) else {
120
120
return ;
121
121
} ;
122
122
render_app
123
- . init_resource :: < SpecializedRenderPipelines < CASPipeline > > ( )
123
+ . init_resource :: < SpecializedRenderPipelines < CasPipeline > > ( )
124
124
. add_systems ( Render , prepare_cas_pipelines. in_set ( RenderSet :: Prepare ) ) ;
125
125
126
126
{
127
127
render_app
128
- . add_render_graph_node :: < CASNode > ( Core3d , Node3d :: ContrastAdaptiveSharpening )
128
+ . add_render_graph_node :: < CasNode > ( Core3d , Node3d :: ContrastAdaptiveSharpening )
129
129
. add_render_graph_edge (
130
130
Core3d ,
131
131
Node3d :: Tonemapping ,
@@ -142,7 +142,7 @@ impl Plugin for CASPlugin {
142
142
}
143
143
{
144
144
render_app
145
- . add_render_graph_node :: < CASNode > ( Core2d , Node2d :: ContrastAdaptiveSharpening )
145
+ . add_render_graph_node :: < CasNode > ( Core2d , Node2d :: ContrastAdaptiveSharpening )
146
146
. add_render_graph_edge (
147
147
Core2d ,
148
148
Node2d :: Tonemapping ,
@@ -163,17 +163,17 @@ impl Plugin for CASPlugin {
163
163
let Some ( render_app) = app. get_sub_app_mut ( RenderApp ) else {
164
164
return ;
165
165
} ;
166
- render_app. init_resource :: < CASPipeline > ( ) ;
166
+ render_app. init_resource :: < CasPipeline > ( ) ;
167
167
}
168
168
}
169
169
170
170
#[ derive( Resource ) ]
171
- pub struct CASPipeline {
171
+ pub struct CasPipeline {
172
172
texture_bind_group : BindGroupLayout ,
173
173
sampler : Sampler ,
174
174
}
175
175
176
- impl FromWorld for CASPipeline {
176
+ impl FromWorld for CasPipeline {
177
177
fn from_world ( render_world : & mut World ) -> Self {
178
178
let render_device = render_world. resource :: < RenderDevice > ( ) ;
179
179
let texture_bind_group = render_device. create_bind_group_layout (
@@ -184,28 +184,28 @@ impl FromWorld for CASPipeline {
184
184
texture_2d ( TextureSampleType :: Float { filterable : true } ) ,
185
185
sampler ( SamplerBindingType :: Filtering ) ,
186
186
// CAS Settings
187
- uniform_buffer :: < CASUniform > ( true ) ,
187
+ uniform_buffer :: < CasUniform > ( true ) ,
188
188
) ,
189
189
) ,
190
190
) ;
191
191
192
192
let sampler = render_device. create_sampler ( & SamplerDescriptor :: default ( ) ) ;
193
193
194
- CASPipeline {
194
+ CasPipeline {
195
195
texture_bind_group,
196
196
sampler,
197
197
}
198
198
}
199
199
}
200
200
201
201
#[ derive( PartialEq , Eq , Hash , Clone , Copy ) ]
202
- pub struct CASPipelineKey {
202
+ pub struct CasPipelineKey {
203
203
texture_format : TextureFormat ,
204
204
denoise : bool ,
205
205
}
206
206
207
- impl SpecializedRenderPipeline for CASPipeline {
208
- type Key = CASPipelineKey ;
207
+ impl SpecializedRenderPipeline for CasPipeline {
208
+ type Key = CasPipelineKey ;
209
209
210
210
fn specialize ( & self , key : Self :: Key ) -> RenderPipelineDescriptor {
211
211
let mut shader_defs = vec ! [ ] ;
@@ -237,15 +237,15 @@ impl SpecializedRenderPipeline for CASPipeline {
237
237
fn prepare_cas_pipelines (
238
238
mut commands : Commands ,
239
239
pipeline_cache : Res < PipelineCache > ,
240
- mut pipelines : ResMut < SpecializedRenderPipelines < CASPipeline > > ,
241
- sharpening_pipeline : Res < CASPipeline > ,
242
- views : Query < ( Entity , & ExtractedView , & DenoiseCAS ) , With < CASUniform > > ,
240
+ mut pipelines : ResMut < SpecializedRenderPipelines < CasPipeline > > ,
241
+ sharpening_pipeline : Res < CasPipeline > ,
242
+ views : Query < ( Entity , & ExtractedView , & DenoiseCas ) , With < CasUniform > > ,
243
243
) {
244
244
for ( entity, view, cas_settings) in & views {
245
245
let pipeline_id = pipelines. specialize (
246
246
& pipeline_cache,
247
247
& sharpening_pipeline,
248
- CASPipelineKey {
248
+ CasPipelineKey {
249
249
denoise : cas_settings. 0 ,
250
250
texture_format : if view. hdr {
251
251
ViewTarget :: TEXTURE_FORMAT_HDR
@@ -255,9 +255,9 @@ fn prepare_cas_pipelines(
255
255
} ,
256
256
) ;
257
257
258
- commands. entity ( entity) . insert ( ViewCASPipeline ( pipeline_id) ) ;
258
+ commands. entity ( entity) . insert ( ViewCasPipeline ( pipeline_id) ) ;
259
259
}
260
260
}
261
261
262
262
#[ derive( Component ) ]
263
- pub struct ViewCASPipeline ( CachedRenderPipelineId ) ;
263
+ pub struct ViewCasPipeline ( CachedRenderPipelineId ) ;
0 commit comments