pub struct CubemapSpec {
pub size: u32,
pub format: TextureFormat,
pub faces: Option<[Vec<u8>; 6]>,
}Fields§
§size: u32§format: TextureFormat§faces: Option<[Vec<u8>; 6]>Some uploads 6 faces of pixel data up front (wgpu’s expected
order: +X, -X, +Y, -Y, +Z, -Z). None allocates an empty cubemap
meant to be filled later by rendering into per-face views — e.g. an
environment-map capture pass — in which case wgpu_descriptor
adds RENDER_ATTACHMENT usage instead of requiring upload data.
Implementations§
Source§impl CubemapSpec
impl CubemapSpec
pub fn wgpu_descriptor(&self) -> TextureDescriptor<'static>
Sourcepub fn view_descriptor(&self) -> TextureViewDescriptor<'static>
pub fn view_descriptor(&self) -> TextureViewDescriptor<'static>
The one part that’s easy to get wrong by hand: a cubemap’s VIEW
must be created with TextureViewDimension::Cube, not the
default. This is the view you sample from; use
face_view_descriptor to get a
single-layer D2 view for rendering into one face.
Sourcepub fn face_view_descriptor(&self, face: u32) -> TextureViewDescriptor<'static>
pub fn face_view_descriptor(&self, face: u32) -> TextureViewDescriptor<'static>
A single-face D2 view over layer face (0..6, wgpu’s +X, -X, +Y,
-Y, +Z, -Z order) — what you attach as a RenderPassColorAttachment
to draw into that one face of an empty cubemap.
Sourcepub fn upload(&self, device: &Device, queue: &Queue) -> (Texture, TextureView)
pub fn upload(&self, device: &Device, queue: &Queue) -> (Texture, TextureView)
Create the texture and, if faces is Some, upload
all 6 faces. Returns the texture and a Cube-dimension view over it
(suitable for sampling). For an empty cubemap,
create per-face views yourself with face_view_descriptor
to render into it.
Source§impl CubemapSpec
impl CubemapSpec
pub fn new(size: u32, faces: [Vec<u8>; 6]) -> Self
Sourcepub fn empty(size: u32) -> Self
pub fn empty(size: u32) -> Self
An empty cubemap with no data uploaded — allocated with
RENDER_ATTACHMENT usage so it can be filled later by rendering
into each face (via face_view_descriptor),
e.g. an environment-map capture pass.