pub struct ChannelTexture {
pub texture: Option<Texture>,
pub view: TextureView,
pub sampler: Sampler,
pub width: u32,
pub height: u32,
}Expand description
A texture channel that can be bound to a custom shader
Fields§
§texture: Option<Texture>The GPU texture (kept alive to ensure view/sampler remain valid) When using an external texture (e.g., background image), this is None
view: TextureViewView for binding to shaders
sampler: SamplerSampler for texture filtering
width: u32Texture width in pixels
height: u32Texture height in pixels
Implementations§
Source§impl ChannelTexture
impl ChannelTexture
Sourcepub fn placeholder(device: &Device, queue: &Queue) -> Self
pub fn placeholder(device: &Device, queue: &Queue) -> Self
Create a 1x1 transparent black placeholder texture
This is used when no texture is configured for a channel, ensuring the shader can still sample from it without errors.
Sourcepub fn from_view(
view: TextureView,
sampler: Sampler,
width: u32,
height: u32,
) -> Self
pub fn from_view( view: TextureView, sampler: Sampler, width: u32, height: u32, ) -> Self
Create a ChannelTexture from an existing texture view and sampler.
This is used when sharing a texture from another source (e.g., background image) without creating a new copy. The caller is responsible for keeping the source texture alive while this ChannelTexture is in use.
§Arguments
view- The texture view to usesampler- The sampler for texture filteringwidth- Texture width in pixelsheight- Texture height in pixels
Sourcepub fn from_view_and_texture(
view: TextureView,
sampler: Sampler,
width: u32,
height: u32,
texture: Texture,
) -> Self
pub fn from_view_and_texture( view: TextureView, sampler: Sampler, width: u32, height: u32, texture: Texture, ) -> Self
Create a ChannelTexture from a view, sampler, and owned texture.
This is used when creating a new texture that should be kept alive by this ChannelTexture instance (e.g., solid color textures).
§Arguments
view- The texture view to usesampler- The sampler for texture filteringwidth- Texture width in pixelsheight- Texture height in pixelstexture- The owned texture to keep alive
Sourcepub fn resolution(&self) -> [f32; 4]
pub fn resolution(&self) -> [f32; 4]
Get the resolution as a vec4 [width, height, 1.0, 0.0]
This format matches Shadertoy’s iChannelResolution uniform.
Auto Trait Implementations§
impl Freeze for ChannelTexture
impl !RefUnwindSafe for ChannelTexture
impl Send for ChannelTexture
impl Sync for ChannelTexture
impl Unpin for ChannelTexture
impl UnsafeUnpin for ChannelTexture
impl !UnwindSafe for ChannelTexture
Blanket Implementations§
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
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> DowncastSync for T
impl<T> DowncastSync for 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 more