pub enum ImageSampler {
Default,
Descriptor(ImageSamplerDescriptor),
}bevy_image only.Expand description
Used in Image, this determines what image sampler to use when rendering. The default setting,
ImageSampler::Default, will read the sampler from the ImagePlugin at setup.
Setting this to ImageSampler::Descriptor will override the global default descriptor for this Image.
Variants§
Default
Default image sampler, derived from the ImagePlugin setup.
Descriptor(ImageSamplerDescriptor)
Custom sampler for this image which will override global default.
Implementations§
Source§impl ImageSampler
impl ImageSampler
Sourcepub fn linear() -> ImageSampler
pub fn linear() -> ImageSampler
Returns an image sampler with ImageFilterMode::Linear min and mag filters
Examples found in repository?
50fn setup(
51 mut commands: Commands,
52 rpg_sprite_handles: Res<RpgSpriteFolder>,
53 asset_server: Res<AssetServer>,
54 mut texture_atlases: ResMut<Assets<TextureAtlasLayout>>,
55 loaded_folders: Res<Assets<LoadedFolder>>,
56 mut textures: ResMut<Assets<Image>>,
57) {
58 let loaded_folder = loaded_folders.get(&rpg_sprite_handles.0).unwrap();
59
60 // Create texture atlases with different padding and sampling
61
62 let (texture_atlas_linear, linear_sources, linear_texture) = create_texture_atlas(
63 loaded_folder,
64 None,
65 Some(ImageSampler::linear()),
66 &mut textures,
67 );
68 let atlas_linear_handle = texture_atlases.add(texture_atlas_linear);
69
70 let (texture_atlas_nearest, nearest_sources, nearest_texture) = create_texture_atlas(
71 loaded_folder,
72 None,
73 Some(ImageSampler::nearest()),
74 &mut textures,
75 );
76 let atlas_nearest_handle = texture_atlases.add(texture_atlas_nearest);
77
78 let (texture_atlas_linear_padded, linear_padded_sources, linear_padded_texture) =
79 create_texture_atlas(
80 loaded_folder,
81 Some(UVec2::new(6, 6)),
82 Some(ImageSampler::linear()),
83 &mut textures,
84 );
85 let atlas_linear_padded_handle = texture_atlases.add(texture_atlas_linear_padded.clone());
86
87 let (texture_atlas_nearest_padded, nearest_padded_sources, nearest_padded_texture) =
88 create_texture_atlas(
89 loaded_folder,
90 Some(UVec2::new(6, 6)),
91 Some(ImageSampler::nearest()),
92 &mut textures,
93 );
94 let atlas_nearest_padded_handle = texture_atlases.add(texture_atlas_nearest_padded);
95
96 commands.spawn(Camera2d);
97
98 // Padded textures are to the right, unpadded to the left
99
100 // Draw unpadded texture atlas
101 commands.spawn((
102 Sprite::from_image(linear_texture.clone()),
103 Transform {
104 translation: Vec3::new(-250.0, -160.0, 0.0),
105 scale: Vec3::splat(0.5),
106 ..default()
107 },
108 ));
109
110 // Draw padded texture atlas
111 commands.spawn((
112 Sprite::from_image(linear_padded_texture.clone()),
113 Transform {
114 translation: Vec3::new(250.0, -160.0, 0.0),
115 scale: Vec3::splat(0.5),
116 ..default()
117 },
118 ));
119
120 let font = asset_server.load("fonts/FiraSans-Bold.ttf");
121
122 // Padding label text style
123 let text_style: TextFont = TextFont {
124 font: font.clone().into(),
125 font_size: FontSize::Px(42.0),
126 ..default()
127 };
128
129 // Labels to indicate padding
130
131 // No padding
132 create_label(
133 &mut commands,
134 (-250.0, 250.0, 0.0),
135 "No padding",
136 text_style.clone(),
137 );
138
139 // Padding
140 create_label(&mut commands, (250.0, 250.0, 0.0), "Padding", text_style);
141
142 // Get handle to a sprite to render
143 let vendor_handle: Handle<Image> = asset_server
144 .get_handle("textures/rpg/chars/vendor/generic-rpg-vendor.png")
145 .unwrap();
146
147 // Configuration array to render sprites through iteration
148 let configurations: [(
149 &str,
150 Handle<TextureAtlasLayout>,
151 TextureAtlasSources,
152 Handle<Image>,
153 f32,
154 ); 4] = [
155 (
156 "Linear",
157 atlas_linear_handle,
158 linear_sources,
159 linear_texture,
160 -350.0,
161 ),
162 (
163 "Nearest",
164 atlas_nearest_handle,
165 nearest_sources,
166 nearest_texture,
167 -150.0,
168 ),
169 (
170 "Linear",
171 atlas_linear_padded_handle,
172 linear_padded_sources,
173 linear_padded_texture,
174 150.0,
175 ),
176 (
177 "Nearest",
178 atlas_nearest_padded_handle,
179 nearest_padded_sources,
180 nearest_padded_texture,
181 350.0,
182 ),
183 ];
184
185 // Label text style
186 let sampling_label_style = TextFont {
187 font: font.into(),
188 font_size: FontSize::Px(25.0),
189 ..default()
190 };
191
192 let base_y = 80.0; // y position of the sprites
193
194 for (sampling, atlas_handle, atlas_sources, atlas_texture, x) in configurations {
195 // Render a sprite from the texture_atlas
196 create_sprite_from_atlas(
197 &mut commands,
198 (x, base_y, 0.0),
199 atlas_texture,
200 atlas_sources,
201 atlas_handle,
202 &vendor_handle,
203 );
204
205 // Render a label to indicate the sampling setting
206 create_label(
207 &mut commands,
208 (x, base_y + 110.0, 0.0), // Offset to y position of the sprite
209 sampling,
210 sampling_label_style.clone(),
211 );
212 }
213}Sourcepub fn nearest() -> ImageSampler
pub fn nearest() -> ImageSampler
Returns an image sampler with ImageFilterMode::Nearest min and mag filters
Examples found in repository?
17fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
18 let image = asset_server
19 .load_builder()
20 .with_settings(|settings: &mut ImageLoaderSettings| {
21 // Need to use nearest filtering to avoid bleeding between the slices with tiling
22 settings.sampler = ImageSampler::nearest();
23 })
24 .load("textures/fantasy_ui_borders/numbered_slices.png");
25
26 let slicer = TextureSlicer {
27 // `numbered_slices.png` is 48 pixels square. `BorderRect::square(16.)` insets the slicing line from each edge by 16 pixels, resulting in nine slices that are each 16 pixels square.
28 border: BorderRect::all(16.),
29 // With `SliceScaleMode::Tile` the side and center slices are tiled to fill the side and center sections of the target.
30 // And with a `stretch_value` of `1.` the tiles will have the same size as the corresponding slices in the source image.
31 center_scale_mode: SliceScaleMode::Tile { stretch_value: 1. },
32 sides_scale_mode: SliceScaleMode::Tile { stretch_value: 1. },
33 ..default()
34 };
35
36 // ui camera
37 commands.spawn(Camera2d);
38
39 commands
40 .spawn(Node {
41 width: percent(100),
42 height: percent(100),
43 justify_content: JustifyContent::Center,
44 align_content: AlignContent::Center,
45 flex_wrap: FlexWrap::Wrap,
46 column_gap: px(10),
47 row_gap: px(10),
48 ..default()
49 })
50 .with_children(|parent| {
51 for [columns, rows] in [[3, 3], [4, 4], [5, 4], [4, 5], [5, 5]] {
52 for (flip_x, flip_y) in [(false, false), (false, true), (true, false), (true, true)]
53 {
54 parent.spawn((
55 ImageNode {
56 image: image.clone(),
57 flip_x,
58 flip_y,
59 image_mode: NodeImageMode::Sliced(slicer.clone()),
60 ..default()
61 },
62 Node {
63 width: px(16 * columns),
64 height: px(16 * rows),
65 ..default()
66 },
67 ));
68 }
69 }
70 });
71}More examples
85fn setup(
86 mut commands: Commands,
87 asset_server: Res<AssetServer>,
88 mut images: ResMut<Assets<Image>>,
89) {
90 commands.spawn((
91 Camera2d,
92 Projection::Orthographic(OrthographicProjection {
93 scaling_mode: ScalingMode::FixedVertical {
94 viewport_height: 125.0,
95 },
96 ..OrthographicProjection::default_2d()
97 }),
98 ));
99
100 commands.spawn(Text(
101 r"Select a color from the palette at the bottom
102LMB - Draw with selected color
103F5 - Save image"
104 .into(),
105 ));
106
107 let handle = asset_server
108 .load_builder()
109 .with_settings(|settings: &mut ImageLoaderSettings| {
110 settings.sampler = ImageSampler::nearest();
111 })
112 .load(ASSET_PATH);
113 commands.spawn((
114 Sprite {
115 image: handle.clone(),
116 ..Default::default()
117 },
118 SpriteToSave,
119 Pickable::default(),
120 ));
121
122 // We're doing something a little cursed here: we initiate a load, and then insert a default
123 // image into that handle. If the load succeeds, the image will be replaced with the loaded
124 // contents. If it fails, the default image will remain. In real code, you likely want to poll
125 // `AssetServer::load_state` and only insert this on load failure.
126 images
127 .insert(&handle, {
128 let mut image = Image::new_fill(
129 Extent3d {
130 width: 100,
131 height: 100,
132 depth_or_array_layers: 1,
133 },
134 TextureDimension::D2,
135 &[0, 0, 0, 255],
136 TextureFormat::Rgba8Unorm,
137 RenderAssetUsages::all(),
138 );
139 image.sampler = ImageSampler::nearest();
140 image
141 })
142 .unwrap();
143
144 commands.insert_resource(ImageToSave(handle));
145
146 let container = commands
147 .spawn((
148 Node {
149 width: percent(100),
150 height: percent(100),
151 align_items: AlignItems::End,
152 justify_content: JustifyContent::Center,
153 ..Default::default()
154 },
155 Pickable::IGNORE,
156 ))
157 .id();
158
159 for color in [
160 Color::WHITE,
161 Color::Srgba(tailwind::RED_500),
162 Color::Srgba(tailwind::ORANGE_500),
163 Color::Srgba(tailwind::YELLOW_500),
164 Color::Srgba(tailwind::GREEN_500),
165 Color::Srgba(tailwind::BLUE_500),
166 Color::Srgba(tailwind::INDIGO_500),
167 Color::Srgba(tailwind::VIOLET_500),
168 Color::BLACK,
169 ] {
170 let mut entity = commands.spawn((
171 Node {
172 width: vw(5),
173 height: vh(5),
174 border: px(5).all(),
175 ..Default::default()
176 },
177 SelectableColor,
178 BackgroundColor(color),
179 BorderColor::all(NORMAL_COLOR),
180 ChildOf(container),
181 ));
182 if color == Color::WHITE {
183 entity.insert((Selected, BorderColor::all(SELECTED_COLOR)));
184 }
185 }
186}21fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
22 // Without any .meta file specifying settings, the default sampler [ImagePlugin::default()] is used for loading images.
23 // If you are using a very small image and rendering it larger like seen here, the default linear filtering will result in a blurry image.
24 // Useful note: The default sampler specified by the ImagePlugin is *not* the same as the default implementation of sampler. This is why
25 // everything uses linear by default but if you look at the default of sampler, it uses nearest.
26 commands.spawn((
27 Sprite {
28 image: asset_server.load("bevy_pixel_dark.png"),
29 custom_size: Some(Vec2 { x: 160.0, y: 120.0 }),
30 ..Default::default()
31 },
32 Transform::from_xyz(-100.0, 0.0, 0.0),
33 ));
34
35 // When a .meta file is added with the same name as the asset and a '.meta' extension
36 // you can (and must) specify all fields of the asset loader's settings for that
37 // particular asset, in this case [ImageLoaderSettings]. Take a look at
38 // examples/asset/files/bevy_pixel_dark_with_meta.png.meta
39 // for the format and you'll notice, the only non-default option is setting Nearest
40 // filtering. This tends to work much better for pixel art assets.
41 // A good reference when filling this out is to check out [ImageLoaderSettings::default()]
42 // and follow to the default implementation of each fields type.
43 // https://docs.rs/bevy/latest/bevy/image/struct.ImageLoaderSettings.html
44 commands.spawn((
45 Sprite {
46 image: asset_server.load("bevy_pixel_dark_with_meta.png"),
47 custom_size: Some(Vec2 { x: 160.0, y: 120.0 }),
48 ..Default::default()
49 },
50 Transform::from_xyz(100.0, 0.0, 0.0),
51 ));
52
53 // Another option is to use the LoadBuilder::with_settings function.
54 // With this you can specify the same settings upon loading your asset with a
55 // couple of differences. A big one is that you aren't required to set *every*
56 // setting, just modify the ones that you need. It works by passing in a function
57 // (in this case an anonymous closure) that takes a reference to the settings type
58 // that is then modified in the function.
59 // Do note that if you want to load the same asset with different settings, the
60 // settings changes from any loads after the first of the same asset will be ignored.
61 // This is why this one loads a differently named copy of the asset instead of using
62 // same one as without a .meta file.
63 commands.spawn((
64 Sprite {
65 image: asset_server
66 .load_builder()
67 .with_settings(|settings: &mut ImageLoaderSettings| {
68 settings.sampler = ImageSampler::nearest();
69 })
70 .load("bevy_pixel_dark_with_settings.png"),
71 custom_size: Some(Vec2 { x: 160.0, y: 120.0 }),
72 ..Default::default()
73 },
74 Transform::from_xyz(0.0, 150.0, 0.0),
75 ));
76
77 commands.spawn(Camera2d);
78}460 pub fn setup(
461 mut commands: Commands,
462 mut textures: ResMut<Assets<Image>>,
463 mut texture_atlases: ResMut<Assets<TextureAtlasLayout>>,
464 ) {
465 commands.spawn((Camera2d, DespawnOnExit(super::Scene::TextureAtlasBuilder)));
466
467 for (i, padding) in [UVec2::ZERO, PADDING_SIZE].into_iter().enumerate() {
468 // generate solid red green and blue and yellow images
469 let images = [
470 [255, 0, 0, 255],
471 [0, 255, 0, 255],
472 [0, 0, 255, 255],
473 [255, 255, 0, 255],
474 ]
475 .map(|pixel| {
476 Image::new_fill(
477 Extent3d {
478 width: 28,
479 height: 28,
480 depth_or_array_layers: 1,
481 },
482 TextureDimension::D2,
483 &pixel,
484 TextureFormat::Rgba8UnormSrgb,
485 RenderAssetUsages::MAIN_WORLD | RenderAssetUsages::RENDER_WORLD,
486 )
487 });
488
489 let mut texture_atlas_builder = TextureAtlasBuilder::default();
490 texture_atlas_builder
491 .initial_size(ATLAS_SIZE)
492 .max_size(ATLAS_SIZE)
493 .padding(padding);
494 for image in &images {
495 texture_atlas_builder.add_texture(None, image);
496 }
497
498 let (atlas_layout, _, atlas_texture) = texture_atlas_builder.build().expect(
499 "The images are 28 pixels square, so they should fit with 4 pixels left over",
500 );
501 let atlas_layout = texture_atlases.add(atlas_layout);
502
503 let mut nearest_atlas_image = atlas_texture.clone();
504 nearest_atlas_image.sampler = ImageSampler::nearest();
505
506 let atlas_handle = textures.add(atlas_texture);
507 let nearest_atlas_handle = textures.add(nearest_atlas_image);
508
509 let position = ((2. * i as f32 - 1.) * (0.625 * ATLAS_SIZE.x as f32 * ATLAS_SCALE))
510 .round()
511 * Vec3::X;
512
513 commands.spawn((
514 Sprite {
515 image: nearest_atlas_handle,
516 custom_size: Some(ATLAS_SIZE.as_vec2() * ATLAS_SCALE),
517 ..default()
518 },
519 Anchor::BOTTOM_CENTER,
520 ShowAabbGizmo {
521 color: Some(Color::WHITE),
522 },
523 DespawnOnExit(super::Scene::TextureAtlasBuilder),
524 Transform::from_translation(position),
525 ));
526
527 for (index, anchor) in [
528 Anchor::BOTTOM_RIGHT,
529 Anchor::BOTTOM_LEFT,
530 Anchor::TOP_LEFT,
531 Anchor::TOP_RIGHT,
532 ]
533 .into_iter()
534 .enumerate()
535 {
536 commands.spawn((
537 Sprite {
538 image: atlas_handle.clone(),
539 texture_atlas: Some(TextureAtlas {
540 layout: atlas_layout.clone(),
541 index,
542 }),
543 custom_size: Some(IMAGE_SIZE.as_vec2() * IMAGE_SCALE),
544 ..default()
545 },
546 Transform::from_translation(
547 position
548 + -2.
549 * IMAGE_SCALE
550 * (Vec3::Y * IMAGE_SIZE.y as f32 + anchor.as_vec().extend(0.)),
551 ),
552 anchor,
553 DespawnOnExit(super::Scene::TextureAtlasBuilder),
554 ));
555 }
556 }
557 }50fn setup(
51 mut commands: Commands,
52 rpg_sprite_handles: Res<RpgSpriteFolder>,
53 asset_server: Res<AssetServer>,
54 mut texture_atlases: ResMut<Assets<TextureAtlasLayout>>,
55 loaded_folders: Res<Assets<LoadedFolder>>,
56 mut textures: ResMut<Assets<Image>>,
57) {
58 let loaded_folder = loaded_folders.get(&rpg_sprite_handles.0).unwrap();
59
60 // Create texture atlases with different padding and sampling
61
62 let (texture_atlas_linear, linear_sources, linear_texture) = create_texture_atlas(
63 loaded_folder,
64 None,
65 Some(ImageSampler::linear()),
66 &mut textures,
67 );
68 let atlas_linear_handle = texture_atlases.add(texture_atlas_linear);
69
70 let (texture_atlas_nearest, nearest_sources, nearest_texture) = create_texture_atlas(
71 loaded_folder,
72 None,
73 Some(ImageSampler::nearest()),
74 &mut textures,
75 );
76 let atlas_nearest_handle = texture_atlases.add(texture_atlas_nearest);
77
78 let (texture_atlas_linear_padded, linear_padded_sources, linear_padded_texture) =
79 create_texture_atlas(
80 loaded_folder,
81 Some(UVec2::new(6, 6)),
82 Some(ImageSampler::linear()),
83 &mut textures,
84 );
85 let atlas_linear_padded_handle = texture_atlases.add(texture_atlas_linear_padded.clone());
86
87 let (texture_atlas_nearest_padded, nearest_padded_sources, nearest_padded_texture) =
88 create_texture_atlas(
89 loaded_folder,
90 Some(UVec2::new(6, 6)),
91 Some(ImageSampler::nearest()),
92 &mut textures,
93 );
94 let atlas_nearest_padded_handle = texture_atlases.add(texture_atlas_nearest_padded);
95
96 commands.spawn(Camera2d);
97
98 // Padded textures are to the right, unpadded to the left
99
100 // Draw unpadded texture atlas
101 commands.spawn((
102 Sprite::from_image(linear_texture.clone()),
103 Transform {
104 translation: Vec3::new(-250.0, -160.0, 0.0),
105 scale: Vec3::splat(0.5),
106 ..default()
107 },
108 ));
109
110 // Draw padded texture atlas
111 commands.spawn((
112 Sprite::from_image(linear_padded_texture.clone()),
113 Transform {
114 translation: Vec3::new(250.0, -160.0, 0.0),
115 scale: Vec3::splat(0.5),
116 ..default()
117 },
118 ));
119
120 let font = asset_server.load("fonts/FiraSans-Bold.ttf");
121
122 // Padding label text style
123 let text_style: TextFont = TextFont {
124 font: font.clone().into(),
125 font_size: FontSize::Px(42.0),
126 ..default()
127 };
128
129 // Labels to indicate padding
130
131 // No padding
132 create_label(
133 &mut commands,
134 (-250.0, 250.0, 0.0),
135 "No padding",
136 text_style.clone(),
137 );
138
139 // Padding
140 create_label(&mut commands, (250.0, 250.0, 0.0), "Padding", text_style);
141
142 // Get handle to a sprite to render
143 let vendor_handle: Handle<Image> = asset_server
144 .get_handle("textures/rpg/chars/vendor/generic-rpg-vendor.png")
145 .unwrap();
146
147 // Configuration array to render sprites through iteration
148 let configurations: [(
149 &str,
150 Handle<TextureAtlasLayout>,
151 TextureAtlasSources,
152 Handle<Image>,
153 f32,
154 ); 4] = [
155 (
156 "Linear",
157 atlas_linear_handle,
158 linear_sources,
159 linear_texture,
160 -350.0,
161 ),
162 (
163 "Nearest",
164 atlas_nearest_handle,
165 nearest_sources,
166 nearest_texture,
167 -150.0,
168 ),
169 (
170 "Linear",
171 atlas_linear_padded_handle,
172 linear_padded_sources,
173 linear_padded_texture,
174 150.0,
175 ),
176 (
177 "Nearest",
178 atlas_nearest_padded_handle,
179 nearest_padded_sources,
180 nearest_padded_texture,
181 350.0,
182 ),
183 ];
184
185 // Label text style
186 let sampling_label_style = TextFont {
187 font: font.into(),
188 font_size: FontSize::Px(25.0),
189 ..default()
190 };
191
192 let base_y = 80.0; // y position of the sprites
193
194 for (sampling, atlas_handle, atlas_sources, atlas_texture, x) in configurations {
195 // Render a sprite from the texture_atlas
196 create_sprite_from_atlas(
197 &mut commands,
198 (x, base_y, 0.0),
199 atlas_texture,
200 atlas_sources,
201 atlas_handle,
202 &vendor_handle,
203 );
204
205 // Render a label to indicate the sampling setting
206 create_label(
207 &mut commands,
208 (x, base_y + 110.0, 0.0), // Offset to y position of the sprite
209 sampling,
210 sampling_label_style.clone(),
211 );
212 }
213}Sourcepub fn get_or_init_descriptor(&mut self) -> &mut ImageSamplerDescriptor
pub fn get_or_init_descriptor(&mut self) -> &mut ImageSamplerDescriptor
Initialize the descriptor if it is not already initialized.
Descriptor is typically initialized by Bevy when the image is loaded, so this is convenient shortcut for updating the descriptor.
Examples found in repository?
190fn mipmap_material(
191 standard_materials: &mut Assets<StandardMaterial>,
192 images: &mut Assets<Image>,
193) -> Handle<StandardMaterial> {
194 let mip_colors = [
195 Srgba::rgb(1.0, 0.0, 0.0),
196 Srgba::rgb(0.0, 1.0, 0.0),
197 Srgba::rgb(0.0, 0.0, 1.0),
198 Srgba::rgb(1.0, 1.0, 0.0),
199 Srgba::rgb(0.0, 1.0, 1.0),
200 Srgba::rgb(1.0, 0.0, 1.0),
201 ];
202
203 let size = 256;
204
205 let mut image = Image::new_uninit(
206 Extent3d {
207 width: size as u32,
208 height: size as u32,
209 depth_or_array_layers: 1,
210 },
211 TextureDimension::D2,
212 TextureFormat::Rgba8UnormSrgb,
213 RenderAssetUsages::default(),
214 );
215
216 image.texture_descriptor.mip_level_count = mip_colors.len() as u32;
217
218 image
219 .sampler
220 .get_or_init_descriptor()
221 .set_filter(ImageFilterMode::Linear)
222 .set_address_mode(ImageAddressMode::Repeat);
223
224 image.data = Some(
225 mip_colors
226 .iter()
227 .enumerate()
228 .flat_map(|(level, color)| checkerboard(size / 2_usize.pow(level as u32), *color))
229 .collect(),
230 );
231
232 standard_materials.add(StandardMaterial {
233 base_color_texture: Some(images.add(image)),
234 perceptual_roughness: 1.0,
235 ..default()
236 })
237}More examples
297fn spawn_room(
298 commands: &mut Commands,
299 asset_server: &AssetServer,
300 meshes: &mut Assets<Mesh>,
301 materials: &mut Assets<StandardMaterial>,
302) {
303 let mut floor_mesh = raytraced(Plane3d::new(Vec3::Y, Vec2::new(9.0, 10.5)));
304 match floor_mesh.attribute_mut(Mesh::ATTRIBUTE_UV_0).unwrap() {
305 VertexAttributeValues::Float32x2(items) => {
306 items.iter_mut().flatten().for_each(|x| *x *= 9.0);
307 }
308 _ => unreachable!(),
309 }
310 let floor = meshes.add(floor_mesh);
311 commands.spawn((
312 RaytracingMesh3d(floor.clone()),
313 Mesh3d(floor),
314 MeshMaterial3d(
315 materials.add(StandardMaterial {
316 base_color_texture: Some(
317 asset_server
318 .load_builder()
319 .with_settings::<ImageLoaderSettings>(|settings| {
320 settings
321 .sampler
322 .get_or_init_descriptor()
323 .set_address_mode(ImageAddressMode::Repeat);
324 })
325 .load("textures/uv_checker_bw.png"),
326 ),
327 perceptual_roughness: 0.9,
328 ..default()
329 }),
330 ),
331 Transform::from_xyz(0.0, 0.0, 1.5),
332 ));
333
334 let neutral = materials.add(StandardMaterial {
335 base_color: Color::srgb(0.55, 0.54, 0.52),
336 perceptual_roughness: 0.9,
337 ..default()
338 });
339
340 for (z, normal) in [(-9.0, Vec3::Z), (12.0, Vec3::NEG_Z)] {
341 let wall = meshes.add(raytraced(Plane3d::new(normal, Vec2::new(9.0, 4.0))));
342 commands.spawn((
343 RaytracingMesh3d(wall.clone()),
344 Mesh3d(wall),
345 MeshMaterial3d(neutral.clone()),
346 Transform::from_xyz(0.0, 4.0, z),
347 ));
348 }
349
350 for (x, normal, tint) in [
351 (-9.0, Vec3::X, Color::srgb(0.6, 0.25, 0.22)),
352 (9.0, Vec3::NEG_X, Color::srgb(0.22, 0.3, 0.6)),
353 ] {
354 let wall = meshes.add(raytraced(Plane3d::new(normal, Vec2::new(4.0, 10.5))));
355 commands.spawn((
356 RaytracingMesh3d(wall.clone()),
357 Mesh3d(wall),
358 MeshMaterial3d(materials.add(StandardMaterial {
359 base_color: tint,
360 perceptual_roughness: 0.9,
361 ..default()
362 })),
363 Transform::from_xyz(x, 4.0, 1.5),
364 ));
365 }
366
367 let ceiling = meshes.add(raytraced(Plane3d::new(Vec3::NEG_Y, Vec2::splat(10.5))));
368 commands.spawn((
369 RaytracingMesh3d(ceiling.clone()),
370 Mesh3d(ceiling),
371 MeshMaterial3d(neutral),
372 Transform::from_xyz(0.0, 8.0, 1.5),
373 ));
374
375 let lamp = meshes.add(raytraced(Plane3d::new(Vec3::NEG_Y, Vec2::splat(1.75))));
376 commands.spawn((
377 RaytracingMesh3d(lamp.clone()),
378 Mesh3d(lamp),
379 MeshMaterial3d(materials.add(StandardMaterial {
380 emissive: LinearRgba::rgb(40000.0, 38000.0, 34000.0),
381 ..default()
382 })),
383 Transform::from_xyz(0.0, 7.8, 0.5),
384 ));
385}203fn setup_many_lights(
204 mut commands: Commands,
205 asset_server: Res<AssetServer>,
206 mut meshes: ResMut<Assets<Mesh>>,
207 mut materials: ResMut<Assets<StandardMaterial>>,
208 args: Res<Args>,
209 #[cfg(all(feature = "dlss", not(feature = "force_disable_dlss")))] dlss_rr_supported: Option<
210 Res<DlssRayReconstructionSupported>,
211 >,
212) {
213 let mut rng = ChaCha8Rng::seed_from_u64(42);
214
215 let mut plane_mesh = Plane3d::default()
216 .mesh()
217 .size(400.0, 400.0)
218 .build()
219 .with_generated_tangents()
220 .unwrap();
221 match plane_mesh.attribute_mut(Mesh::ATTRIBUTE_UV_0).unwrap() {
222 VertexAttributeValues::Float32x2(items) => {
223 items.iter_mut().flatten().for_each(|x| *x *= 3.0);
224 }
225 _ => unreachable!(),
226 }
227 let plane_mesh = meshes.add(plane_mesh);
228 let cube_mesh = meshes.add(
229 Cuboid::default()
230 .mesh()
231 .build()
232 .with_generated_tangents()
233 .unwrap(),
234 );
235 let sphere_mesh = meshes.add(
236 Sphere::new(1.0)
237 .mesh()
238 .build()
239 .with_generated_tangents()
240 .unwrap(),
241 );
242
243 commands
244 .spawn((
245 RaytracingMesh3d(plane_mesh.clone()),
246 MeshMaterial3d(
247 materials.add(StandardMaterial {
248 base_color_texture: Some(
249 asset_server
250 .load_builder()
251 .with_settings::<ImageLoaderSettings>(|settings| {
252 settings
253 .sampler
254 .get_or_init_descriptor()
255 .set_address_mode(ImageAddressMode::Repeat);
256 })
257 .load("textures/uv_checker_bw.png"),
258 ),
259 perceptual_roughness: 0.0,
260 ..default()
261 }),
262 ),
263 ))
264 .insert_if(Mesh3d(plane_mesh), || args.pathtracer != Some(true));
265
266 for _ in 0..8000 {
267 commands
268 .spawn((
269 RaytracingMesh3d(cube_mesh.clone()),
270 MeshMaterial3d(materials.add(StandardMaterial {
271 base_color: Color::srgb(rng.random(), rng.random(), rng.random()),
272 perceptual_roughness: rng.random(),
273 ..default()
274 })),
275 Transform::default()
276 .with_scale(Vec3 {
277 x: rng.random_range(0.2..=2.0),
278 y: rng.random_range(0.2..=2.0),
279 z: rng.random_range(0.2..=2.0),
280 })
281 .with_translation(Vec3::new(
282 rng.random_range(-180.0..=180.0),
283 0.2,
284 rng.random_range(-180.0..=180.0),
285 )),
286 ))
287 .insert_if(Mesh3d(cube_mesh.clone()), || args.pathtracer != Some(true));
288 }
289
290 for x in -10..=10 {
291 for y in -10..=10 {
292 commands
293 .spawn((
294 RaytracingMesh3d(sphere_mesh.clone()),
295 MeshMaterial3d(
296 materials.add(StandardMaterial {
297 emissive: Color::linear_rgb(
298 rng.random::<f32>() * 60000.0,
299 rng.random::<f32>() * 60000.0,
300 rng.random::<f32>() * 60000.0,
301 )
302 .into(),
303 ..default()
304 }),
305 ),
306 Transform::default().with_translation(Vec3::new(
307 (x * 20) as f32,
308 7.0,
309 (y * 20) as f32,
310 )),
311 ))
312 .insert_if(Mesh3d(sphere_mesh.clone()), || {
313 args.pathtracer != Some(true)
314 });
315 }
316 }
317
318 let mut camera = commands.spawn((
319 Camera3d::default(),
320 Camera {
321 clear_color: ClearColorConfig::Custom(Color::BLACK),
322 ..default()
323 },
324 FreeCamera {
325 walk_speed: 3.0,
326 run_speed: 10.0,
327 ..Default::default()
328 },
329 Transform::from_translation(Vec3::new(6.11329, 166.74896, 451.8226)).with_rotation(
330 Quat::from_xyzw(-0.183938, 0.009093744, 0.0017017953, 0.9828943),
331 ),
332 // Msaa::Off and CameraMainTextureUsages with STORAGE_BINDING are required for Solari
333 CameraMainTextureUsages::default().with(TextureUsages::STORAGE_BINDING),
334 Msaa::Off,
335 Bloom {
336 intensity: 0.1,
337 ..Bloom::NATURAL
338 },
339 ));
340
341 if args.pathtracer == Some(true) {
342 camera.insert(Pathtracer::default());
343 } else {
344 camera.insert(SolariLighting::default());
345 }
346
347 // Using DLSS Ray Reconstruction for denoising (and cheaper rendering via upscaling) is _highly_ recommended when using Solari
348 #[cfg(all(feature = "dlss", not(feature = "force_disable_dlss")))]
349 if dlss_rr_supported.is_some() {
350 camera.insert(Dlss::<DlssRayReconstructionFeature>::default());
351 }
352
353 commands.spawn((
354 ControlText,
355 Text::default(),
356 Node {
357 position_type: PositionType::Absolute,
358 bottom: px(12.0),
359 left: px(12.0),
360 ..default()
361 },
362 ));
363
364 commands.spawn((
365 Node {
366 position_type: PositionType::Absolute,
367 right: px(0.0),
368 padding: px(4.0).all(),
369 border_radius: BorderRadius::bottom_left(px(4.0)),
370 ..default()
371 },
372 BackgroundColor(Color::srgba(0.10, 0.10, 0.10, 0.8)),
373 children![(
374 PerformanceText,
375 Text::default(),
376 TextFont {
377 font_size: FontSize::Px(8.0),
378 ..default()
379 },
380 )],
381 ));
382}Trait Implementations§
Source§impl Clone for ImageSampler
impl Clone for ImageSampler
Source§fn clone(&self) -> ImageSampler
fn clone(&self) -> ImageSampler
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ImageSampler
impl Debug for ImageSampler
Source§impl Default for ImageSampler
impl Default for ImageSampler
Source§fn default() -> ImageSampler
fn default() -> ImageSampler
Source§impl<'de> Deserialize<'de> for ImageSampler
impl<'de> Deserialize<'de> for ImageSampler
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ImageSampler, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ImageSampler, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Enum for ImageSampler
impl Enum for ImageSampler
Source§fn field(&self, __name_param: &str) -> Option<&(dyn PartialReflect + 'static)>
fn field(&self, __name_param: &str) -> Option<&(dyn PartialReflect + 'static)>
Source§fn field_at(
&self,
__index_param: usize,
) -> Option<&(dyn PartialReflect + 'static)>
fn field_at( &self, __index_param: usize, ) -> Option<&(dyn PartialReflect + 'static)>
Source§fn field_mut(
&mut self,
__name_param: &str,
) -> Option<&mut (dyn PartialReflect + 'static)>
fn field_mut( &mut self, __name_param: &str, ) -> Option<&mut (dyn PartialReflect + 'static)>
Source§fn field_at_mut(
&mut self,
__index_param: usize,
) -> Option<&mut (dyn PartialReflect + 'static)>
fn field_at_mut( &mut self, __index_param: usize, ) -> Option<&mut (dyn PartialReflect + 'static)>
Source§fn index_of(&self, __name_param: &str) -> Option<usize>
fn index_of(&self, __name_param: &str) -> Option<usize>
Source§fn name_at(&self, __index_param: usize) -> Option<&str>
fn name_at(&self, __index_param: usize) -> Option<&str>
Source§fn iter_fields(&self) -> VariantFieldIter<'_> ⓘ
fn iter_fields(&self) -> VariantFieldIter<'_> ⓘ
Source§fn variant_name(&self) -> &str
fn variant_name(&self) -> &str
Source§fn variant_index(&self) -> usize
fn variant_index(&self) -> usize
Source§fn variant_type(&self) -> VariantType
fn variant_type(&self) -> VariantType
Source§fn to_dynamic_enum(&self) -> Result<DynamicEnum, ReflectCloneError>
fn to_dynamic_enum(&self) -> Result<DynamicEnum, ReflectCloneError>
DynamicEnum from this enum. Read moreSource§fn is_variant(&self, variant_type: VariantType) -> bool
fn is_variant(&self, variant_type: VariantType) -> bool
Source§fn variant_path(&self) -> String
fn variant_path(&self) -> String
Source§impl FromArg for ImageSampler
impl FromArg for ImageSampler
Source§impl FromReflect for ImageSampler
impl FromReflect for ImageSampler
Source§fn from_reflect(
__param0: &(dyn PartialReflect + 'static),
) -> Option<ImageSampler>
fn from_reflect( __param0: &(dyn PartialReflect + 'static), ) -> Option<ImageSampler>
Self from a reflected value.Source§fn take_from_reflect(
reflect: Box<dyn PartialReflect>,
) -> Result<Self, Box<dyn PartialReflect>>
fn take_from_reflect( reflect: Box<dyn PartialReflect>, ) -> Result<Self, Box<dyn PartialReflect>>
Self using,
constructing the value using from_reflect if that fails. Read moreSource§impl GetOwnership for ImageSampler
impl GetOwnership for ImageSampler
Source§impl GetTypeRegistration for ImageSampler
impl GetTypeRegistration for ImageSampler
Source§fn get_type_registration() -> TypeRegistration
fn get_type_registration() -> TypeRegistration
TypeRegistration for this type.Source§fn register_type_dependencies(registry: &mut TypeRegistry)
fn register_type_dependencies(registry: &mut TypeRegistry)
Source§impl IntoReturn for ImageSampler
impl IntoReturn for ImageSampler
Source§fn into_return<'into_return>(self) -> Return<'into_return>where
ImageSampler: 'into_return,
fn into_return<'into_return>(self) -> Return<'into_return>where
ImageSampler: 'into_return,
Source§impl PartialEq for ImageSampler
impl PartialEq for ImageSampler
Source§impl PartialReflect for ImageSampler
impl PartialReflect for ImageSampler
Source§fn get_represented_type_info(&self) -> Option<&'static TypeInfo>
fn get_represented_type_info(&self) -> Option<&'static TypeInfo>
Source§fn try_apply(
&mut self,
__value_param: &(dyn PartialReflect + 'static),
) -> Result<(), ApplyError>
fn try_apply( &mut self, __value_param: &(dyn PartialReflect + 'static), ) -> Result<(), ApplyError>
Source§fn reflect_kind(&self) -> ReflectKind
fn reflect_kind(&self) -> ReflectKind
Source§fn reflect_ref(&self) -> ReflectRef<'_>
fn reflect_ref(&self) -> ReflectRef<'_>
Source§fn reflect_mut(&mut self) -> ReflectMut<'_>
fn reflect_mut(&mut self) -> ReflectMut<'_>
Source§fn reflect_owned(self: Box<ImageSampler>) -> ReflectOwned
fn reflect_owned(self: Box<ImageSampler>) -> ReflectOwned
Source§fn try_into_reflect(
self: Box<ImageSampler>,
) -> Result<Box<dyn Reflect>, Box<dyn PartialReflect>>
fn try_into_reflect( self: Box<ImageSampler>, ) -> Result<Box<dyn Reflect>, Box<dyn PartialReflect>>
Source§fn try_as_reflect(&self) -> Option<&(dyn Reflect + 'static)>
fn try_as_reflect(&self) -> Option<&(dyn Reflect + 'static)>
Source§fn try_as_reflect_mut(&mut self) -> Option<&mut (dyn Reflect + 'static)>
fn try_as_reflect_mut(&mut self) -> Option<&mut (dyn Reflect + 'static)>
Source§fn into_partial_reflect(self: Box<ImageSampler>) -> Box<dyn PartialReflect>
fn into_partial_reflect(self: Box<ImageSampler>) -> Box<dyn PartialReflect>
Source§fn as_partial_reflect(&self) -> &(dyn PartialReflect + 'static)
fn as_partial_reflect(&self) -> &(dyn PartialReflect + 'static)
Source§fn as_partial_reflect_mut(&mut self) -> &mut (dyn PartialReflect + 'static)
fn as_partial_reflect_mut(&mut self) -> &mut (dyn PartialReflect + 'static)
Source§fn reflect_hash(&self) -> Option<u64>
fn reflect_hash(&self) -> Option<u64>
Source§fn reflect_partial_eq(
&self,
value: &(dyn PartialReflect + 'static),
) -> Option<bool>
fn reflect_partial_eq( &self, value: &(dyn PartialReflect + 'static), ) -> Option<bool>
Source§fn reflect_partial_cmp(
&self,
value: &(dyn PartialReflect + 'static),
) -> Option<Ordering>
fn reflect_partial_cmp( &self, value: &(dyn PartialReflect + 'static), ) -> Option<Ordering>
Source§fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>
Source§fn reflect_clone(&self) -> Result<Box<dyn Reflect>, ReflectCloneError>
fn reflect_clone(&self) -> Result<Box<dyn Reflect>, ReflectCloneError>
Self using reflection. Read moreSource§fn apply(&mut self, value: &(dyn PartialReflect + 'static))
fn apply(&mut self, value: &(dyn PartialReflect + 'static))
Source§fn to_dynamic(&self) -> Result<Box<dyn PartialReflect>, ReflectCloneError>
fn to_dynamic(&self) -> Result<Box<dyn PartialReflect>, ReflectCloneError>
Source§fn reflect_clone_and_take<T>(&self) -> Result<T, ReflectCloneError>
fn reflect_clone_and_take<T>(&self) -> Result<T, ReflectCloneError>
PartialReflect, combines reflect_clone and
take in a useful fashion, automatically constructing an appropriate
ReflectCloneError if the downcast fails.Source§fn is_dynamic(&self) -> bool
fn is_dynamic(&self) -> bool
Source§impl Reflect for ImageSampler
impl Reflect for ImageSampler
Source§fn into_any(self: Box<ImageSampler>) -> Box<dyn Any>
fn into_any(self: Box<ImageSampler>) -> Box<dyn Any>
Box<dyn Any>. Read moreSource§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut dyn Any. Read moreSource§fn into_reflect(self: Box<ImageSampler>) -> Box<dyn Reflect>
fn into_reflect(self: Box<ImageSampler>) -> Box<dyn Reflect>
Source§fn as_reflect(&self) -> &(dyn Reflect + 'static)
fn as_reflect(&self) -> &(dyn Reflect + 'static)
Source§fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)
fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)
Source§impl Serialize for ImageSampler
impl Serialize for ImageSampler
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for ImageSampler
Source§impl TypePath for ImageSampler
impl TypePath for ImageSampler
Source§fn type_path() -> &'static str
fn type_path() -> &'static str
Source§fn short_type_path() -> &'static str
fn short_type_path() -> &'static str
Source§fn type_ident() -> Option<&'static str>
fn type_ident() -> Option<&'static str>
Source§fn crate_name() -> Option<&'static str>
fn crate_name() -> Option<&'static str>
Auto Trait Implementations§
impl Freeze for ImageSampler
impl RefUnwindSafe for ImageSampler
impl Send for ImageSampler
impl Sync for ImageSampler
impl Unpin for ImageSampler
impl UnsafeUnpin for ImageSampler
impl UnwindSafe for ImageSampler
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T ShaderType for self. When used in AsBindGroup
derives, it is safe to assume that all images in self exist.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> Brush for T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ConditionalSend for Twhere
T: Send,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<T> DynamicTypePath for Twhere
T: TypePath,
impl<T> DynamicTypePath for Twhere
T: TypePath,
Source§fn reflect_type_path(&self) -> &str
fn reflect_type_path(&self) -> &str
TypePath::type_path.Source§fn reflect_short_type_path(&self) -> &str
fn reflect_short_type_path(&self) -> &str
Source§fn reflect_type_ident(&self) -> Option<&str>
fn reflect_type_ident(&self) -> Option<&str>
TypePath::type_ident.Source§fn reflect_crate_name(&self) -> Option<&str>
fn reflect_crate_name(&self) -> Option<&str>
TypePath::crate_name.Source§fn reflect_module_path(&self) -> Option<&str>
fn reflect_module_path(&self) -> Option<&str>
Source§impl<T> DynamicTyped for Twhere
T: Typed,
impl<T> DynamicTyped for Twhere
T: Typed,
Source§fn reflect_type_info(&self) -> &'static TypeInfo
fn reflect_type_info(&self) -> &'static TypeInfo
Typed::type_info.impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> FromTemplate for T
impl<T> FromTemplate for T
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
Source§impl<T> GetPath for T
impl<T> GetPath for T
Source§fn reflect_path<'p>(
&self,
path: impl ReflectPath<'p>,
) -> Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>>
fn reflect_path<'p>( &self, path: impl ReflectPath<'p>, ) -> Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>>
path. Read moreSource§fn reflect_path_mut<'p>(
&mut self,
path: impl ReflectPath<'p>,
) -> Result<&mut (dyn PartialReflect + 'static), ReflectPathError<'p>>
fn reflect_path_mut<'p>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut (dyn PartialReflect + 'static), ReflectPathError<'p>>
path. Read moreSource§fn path<'p, T>(
&self,
path: impl ReflectPath<'p>,
) -> Result<&T, ReflectPathError<'p>>where
T: Reflect,
fn path<'p, T>(
&self,
path: impl ReflectPath<'p>,
) -> Result<&T, ReflectPathError<'p>>where
T: Reflect,
path. Read moreSource§fn path_mut<'p, T>(
&mut self,
path: impl ReflectPath<'p>,
) -> Result<&mut T, ReflectPathError<'p>>where
T: Reflect,
fn path_mut<'p, T>(
&mut self,
path: impl ReflectPath<'p>,
) -> Result<&mut T, ReflectPathError<'p>>where
T: Reflect,
path. Read moreSource§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T> HitDataExtra for T
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Source§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<G> PatchFromTemplate for Gwhere
G: FromTemplate,
impl<G> PatchFromTemplate for Gwhere
G: FromTemplate,
Source§fn patch<F>(func: F) -> TemplatePatch<F, <G as PatchFromTemplate>::Template>
fn patch<F>(func: F) -> TemplatePatch<F, <G as PatchFromTemplate>::Template>
func, and turns it into a TemplatePatch.Source§impl<T> PatchTemplate for Twhere
T: Template,
impl<T> PatchTemplate for Twhere
T: Template,
Source§fn patch_template<F>(func: F) -> TemplatePatch<F, T>
fn patch_template<F>(func: F) -> TemplatePatch<F, T>
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().impl<T> Reflectable for T
Source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
impl<T> Settings for T
Source§impl<Ret> SpawnIfAsync<(), Ret> for Ret
impl<Ret> SpawnIfAsync<(), Ret> for Ret
Source§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
Source§fn super_from(input: T) -> O
fn super_from(input: T) -> O
Source§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
Source§fn super_into(self) -> O
fn super_into(self) -> O
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.Source§impl<T> Template for T
impl<T> Template for T
Source§fn build_template(
&self,
_context: &mut TemplateContext<'_, '_>,
) -> Result<<T as Template>::Output, BevyError>
fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>
entity context to produce a Template::Output.Source§fn clone_template(&self) -> T
fn clone_template(&self) -> T
Clone.Source§impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
fn to_sample_(self) -> U
Source§impl<T> TypeData for T
impl<T> TypeData for T
Source§fn clone_type_data(&self) -> Box<dyn TypeData>
fn clone_type_data(&self) -> Box<dyn TypeData>
self.