Skip to main content

CustomShaderRenderer

Struct CustomShaderRenderer 

Source
pub struct CustomShaderRenderer { /* private fields */ }
Expand description

Custom shader renderer that applies post-processing effects

Implementations§

Source§

impl CustomShaderRenderer

Source

pub fn update_cursor( &mut self, col: usize, row: usize, opacity: f32, cursor_color: [f32; 4], style: CursorStyle, )

Update cursor position and appearance for shader effects

This method tracks cursor movement and records the time of change, enabling Ghostty-compatible cursor trail effects and animations.

§Arguments
  • col - Cursor column position (0-based)
  • row - Cursor row position (0-based)
  • opacity - Cursor opacity (0.0 = invisible, 1.0 = fully visible)
  • cursor_color - Cursor RGBA color
  • style - Cursor style (Block, Beam, Underline)
Source

pub fn update_cell_dimensions( &mut self, cell_width: f32, cell_height: f32, padding: f32, )

Update cell dimensions for cursor pixel position calculation

§Arguments
  • cell_width - Cell width in pixels
  • cell_height - Cell height in pixels
  • padding - Window padding in pixels
Source

pub fn set_content_offset_y(&mut self, offset: f32)

Set vertical content offset (e.g., tab bar height)

Source

pub fn set_content_offset_x(&mut self, offset: f32)

Set horizontal content offset (e.g., tab bar on left)

Source

pub fn set_scale_factor(&mut self, scale_factor: f32)

Set display scale factor for DPI-aware cursor sizing

Source

pub fn cursor_needs_animation(&self) -> bool

Check if cursor animation might need continuous rendering

Returns true if a cursor trail animation is likely still in progress (within 1 second of the last cursor movement).

Source

pub fn update_cursor_shader_config( &mut self, color: [u8; 3], trail_duration: f32, glow_radius: f32, glow_intensity: f32, )

Update cursor shader configuration from config values

§Arguments
  • color - Cursor color for shader effects [R, G, B] (0-255)
  • trail_duration - Duration of cursor trail effect in seconds
  • glow_radius - Radius of cursor glow effect in pixels
  • glow_intensity - Intensity of cursor glow effect (0.0-1.0)
Source§

impl CustomShaderRenderer

Source

pub fn new( device: &Device, queue: &Queue, surface_format: TextureFormat, shader_path: &Path, width: u32, height: u32, animation_enabled: bool, animation_speed: f32, window_opacity: f32, full_content_mode: bool, channel_paths: &[Option<PathBuf>; 4], cubemap_path: Option<&Path>, ) -> Result<Self>

Create a new custom shader renderer from a GLSL shader file

Source

pub fn intermediate_texture_view(&self) -> &TextureView

Get a view of the intermediate texture for rendering terminal content into

Source

pub fn clear_intermediate_texture(&self, device: &Device, queue: &Queue)

Clear the intermediate texture (e.g., when switching to split pane mode)

This prevents old single-pane content from showing through the shader.

Source

pub fn resize(&mut self, device: &Device, width: u32, height: u32)

Resize the intermediate texture when window size changes

Source

pub fn render( &mut self, device: &Device, queue: &Queue, output_view: &TextureView, apply_opacity: bool, ) -> Result<()>

Render the custom shader effect to the output texture

§Arguments
  • device - The GPU device
  • queue - The command queue
  • output_view - The texture view to render to
  • apply_opacity - Whether to apply window opacity. Set to false when rendering to an intermediate texture that will be processed by another shader (to avoid double-applying opacity).
Source

pub fn render_with_clear_color( &mut self, device: &Device, queue: &Queue, output_view: &TextureView, apply_opacity: bool, clear_color: Color, ) -> Result<()>

Render the custom shader with a specified clear color. Use this for solid background colors where the clear color provides the background.

Source

pub fn animation_enabled(&self) -> bool

Check if animation is enabled

Source

pub fn set_animation_enabled(&mut self, enabled: bool)

Set animation enabled state

Source

pub fn set_animation_speed(&mut self, speed: f32)

Update animation speed multiplier

Source

pub fn set_opacity(&mut self, opacity: f32)

Update window opacity

Source

pub fn set_brightness(&mut self, brightness: f32)

Update shader brightness multiplier

Source

pub fn set_full_content_mode(&mut self, enabled: bool)

Update full content mode

Source

pub fn full_content_mode(&self) -> bool

Check if full content mode is enabled

Source

pub fn set_keep_text_opaque(&mut self, keep_opaque: bool)

Set whether text should always be rendered at full opacity When true, overrides text_opacity to 1.0

Source

pub fn set_mouse_position(&mut self, x: f32, y: f32)

Update mouse position in pixel coordinates

Source

pub fn set_mouse_button(&mut self, pressed: bool, x: f32, y: f32)

Update mouse button state and click position

Source

pub fn update_key_press(&mut self)

Update key press time for shader effects

Call this when a key is pressed to enable key-press-based shader effects like screen pulses or typing animations.

Source

pub fn update_channel_texture( &mut self, device: &Device, queue: &Queue, channel: u8, path: Option<&Path>, ) -> Result<()>

Update a channel texture at runtime

Source

pub fn update_cubemap( &mut self, device: &Device, queue: &Queue, path: Option<&Path>, ) -> Result<()>

Update the cubemap texture at runtime

Source

pub fn set_use_background_as_channel0(&mut self, use_background: bool)

Set whether to use the background image as iChannel0.

When enabled and a background texture is set, the background image will be used as iChannel0 instead of the configured channel0 texture file.

Note: This only updates the flag. Use update_use_background_as_channel0 if you also need to recreate the bind group.

Source

pub fn use_background_as_channel0(&self) -> bool

Check if using background image as iChannel0.

Source

pub fn set_background_texture( &mut self, device: &Device, texture: Option<ChannelTexture>, )

Set the background texture to use as iChannel0 when enabled.

Call this whenever the background image changes to update the shader’s channel0 binding. The device parameter is needed to recreate the bind group.

When use_background_as_channel0 is enabled, the background texture takes priority over any configured channel0 texture.

§Arguments
  • device - The wgpu device
  • texture - The background texture (view, sampler, dimensions), or None to clear
Source

pub fn set_background_color(&mut self, color: [f32; 3], active: bool)

Set the solid background color for shader compositing.

When set (alpha > 0), the shader uses this color as background instead of shader output. This allows solid background colors to show through properly with window transparency.

§Arguments
  • color - RGB color values [R, G, B] (0.0-1.0, NOT premultiplied)
  • active - Whether solid color mode is active (sets alpha to 1.0 or 0.0)
Source

pub fn update_progress( &mut self, state: f32, percent: f32, is_active: f32, active_count: f32, )

Update progress bar state for shader effects.

§Arguments
  • state - Progress state (0=hidden, 1=normal, 2=error, 3=indeterminate, 4=warning)
  • percent - Progress percentage as 0.0-1.0
  • is_active - 1.0 if any progress bar is active, 0.0 otherwise
  • active_count - Total count of active bars (simple + named)
Source

pub fn update_use_background_as_channel0( &mut self, device: &Device, use_background: bool, )

Update the use_background_as_channel0 setting and recreate bind group if needed.

Call this when the setting changes in the UI or config.

Source

pub fn reload_from_source( &mut self, device: &Device, source: &str, name: &str, ) -> Result<()>

Reload the shader from a source string

Source

pub fn set_content_inset_right(&mut self, inset: f32)

Set the right content inset (e.g., AI Inspector panel).

When non-zero, the shader will render to a viewport that excludes the right inset area, ensuring effects don’t appear under the panel.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,